-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Show
Jobs
section with job postings (#917)
* ✨ Add section for jobs Update query for fetching job postings * 💄 Add Jobs section * ♻️ Add IJobPostings interface * 📱 Make it responsive! * 👌 Use rem rather than px ♻️ Use &:: in .jobPosting * ✨ Add location filter for job postings * ♻️ jobPostingsFilterWrapper => filters * 💄 Display job locations as Badges * 💄 Add violet background to Tag component
- Loading branch information
Showing
15 changed files
with
354 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Badge from "src/components/badge/Badge"; | ||
import Text from "src/components/text/Text"; | ||
import { CompanyLocation } from "studio/lib/interfaces/companyDetails"; | ||
import { IJobPosting } from "studio/lib/interfaces/jobPosting"; | ||
|
||
import styles from "./jobPosting.module.css"; | ||
|
||
interface JobPostingProps { | ||
jobPosting: IJobPosting; | ||
} | ||
|
||
export default function JobPosting({ jobPosting }: JobPostingProps) { | ||
const jobPostingLocations = jobPosting.locations | ||
.map((location: CompanyLocation) => location.companyLocationName) | ||
.join(", "); | ||
|
||
return ( | ||
<a | ||
href={jobPosting.recruiteeAdUrl} | ||
target="_blank" | ||
className={styles.jobPosting} | ||
> | ||
<div className={styles.details}> | ||
<div className={styles.role}> | ||
<Text type={"h5"}>{jobPosting.role}</Text> | ||
</div> | ||
<Badge>{jobPostingLocations}</Badge> | ||
</div> | ||
</a> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.jobPosting { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
border-radius: 1.5rem; | ||
padding: 0.5rem 1.5rem; | ||
gap: 5rem; | ||
width: 100%; | ||
background-color: var(--text-primary-light); | ||
color: var(--text-primary); | ||
|
||
&::after { | ||
justify-self: end; | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
content: ""; | ||
-webkit-mask: url("/_assets/arrow-right.svg") no-repeat center; | ||
-webkit-mask-size: cover; | ||
mask: url("/_assets/arrow-right.svg") no-repeat center; | ||
mask-size: cover; | ||
background-color: var(--background-bg-dark); | ||
} | ||
} | ||
|
||
.details { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-start; | ||
align-items: center; | ||
gap: 0.5rem; | ||
width: 100%; | ||
} | ||
|
||
.role { | ||
width: 250px; | ||
@media (max-width: 640px) { | ||
width: 100%; | ||
} | ||
} | ||
|
||
.locations { | ||
border: solid; | ||
border-color: var(--text-primary); | ||
border-width: thin; | ||
border-radius: 25rem; | ||
padding: 0.375rem 0.75rem; | ||
text-align: center; | ||
@media (max-width: 640px) { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
"use client"; | ||
|
||
import { useEffect, useMemo, useState } from "react"; | ||
|
||
import JobPosting from "src/components/jobPosting/JobPosting"; | ||
import { Tag } from "src/components/tag"; | ||
import Text from "src/components/text/Text"; | ||
import { CompanyLocation } from "studio/lib/interfaces/companyDetails"; | ||
import { IJobPosting } from "studio/lib/interfaces/jobPosting"; | ||
|
||
import styles from "./jobs.module.css"; | ||
|
||
interface JobPostingListProps { | ||
jobPostings: IJobPosting[]; | ||
companyLocations: CompanyLocation[]; | ||
} | ||
|
||
export default function JobPostingList({ | ||
jobPostings, | ||
companyLocations, | ||
}: JobPostingListProps) { | ||
const [locationFilter, setLocationFilter] = useState<CompanyLocation | null>( | ||
null, | ||
); | ||
const [filteredJobPostings, setFilteredJobPostings] = | ||
useState<IJobPosting[]>(jobPostings); | ||
const jobPostingLocations = useMemo( | ||
() => | ||
Object.fromEntries( | ||
jobPostings.map((jobPosting) => [ | ||
jobPosting._key, | ||
jobPosting.locations.map((location) => location.companyLocationName), | ||
]), | ||
), | ||
[jobPostings], | ||
); | ||
|
||
useEffect(() => { | ||
if (locationFilter === null) { | ||
setFilteredJobPostings(jobPostings); | ||
} else { | ||
setFilteredJobPostings( | ||
jobPostings?.filter((jobPosting) => | ||
jobPostingLocations[jobPosting._key].includes( | ||
locationFilter.companyLocationName, | ||
), | ||
), | ||
); | ||
} | ||
}, [locationFilter, jobPostings, jobPostingLocations]); | ||
|
||
return ( | ||
<div className={styles.jobPostingsContainer}> | ||
<div className={styles.filters}> | ||
<Text type="labelRegular">Kontor</Text> | ||
<Tag | ||
active={!locationFilter} | ||
type="button" | ||
onClick={() => setLocationFilter(null)} | ||
text="Alle" | ||
background="violet" | ||
/> | ||
{companyLocations.map((location: CompanyLocation) => ( | ||
<Tag | ||
active={locationFilter === location} | ||
type="button" | ||
onClick={() => setLocationFilter(location)} | ||
text={location.companyLocationName} | ||
key={location._id} | ||
background="violet" | ||
/> | ||
))} | ||
</div> | ||
<div className={styles.jobPostings}> | ||
{filteredJobPostings?.map((jobPosting: IJobPosting) => ( | ||
<JobPosting jobPosting={jobPosting} key={jobPosting._key} /> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Text from "src/components/text/Text"; | ||
import { CompanyLocation } from "studio/lib/interfaces/companyDetails"; | ||
import { IJobPostings } from "studio/lib/interfaces/jobPosting"; | ||
import { JobsSection } from "studio/lib/interfaces/pages"; | ||
import { | ||
COMPANY_LOCATIONS_QUERY, | ||
JOB_POSTINGS_QUERY, | ||
} from "studio/lib/queries/admin"; | ||
import { loadStudioQuery } from "studio/lib/store"; | ||
|
||
import JobPostingList from "./JobPostingList"; | ||
import styles from "./jobs.module.css"; | ||
|
||
export interface JobsProps { | ||
language: string; | ||
section: JobsSection; | ||
} | ||
|
||
export default async function Jobs({ language, section }: JobsProps) { | ||
const { data: jobPostings } = await loadStudioQuery<IJobPostings | null>( | ||
JOB_POSTINGS_QUERY, | ||
{ | ||
language, | ||
}, | ||
); | ||
|
||
const { data: companyLocations } = await loadStudioQuery<CompanyLocation[]>( | ||
COMPANY_LOCATIONS_QUERY, | ||
{}, | ||
); | ||
|
||
return ( | ||
jobPostings && | ||
companyLocations && ( | ||
<div className={styles.wrapper}> | ||
<div className={styles.titleSection}> | ||
<Text type={"h2"}>{section.basicTitle}</Text> | ||
<Text type={"bodyNormal"}>{section.subtitle}</Text> | ||
</div> | ||
<JobPostingList | ||
jobPostings={jobPostings.jobPostingsArray} | ||
companyLocations={companyLocations} | ||
/> | ||
</div> | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
padding: 2rem 0.375rem 0.375rem 0.375rem; | ||
max-width: 53rem; | ||
margin: 5rem auto; | ||
border-radius: 0.75px; | ||
gap: 1.5rem; | ||
background-color: var(--Violet-700); | ||
color: var(--text-primary-light); | ||
} | ||
|
||
.titleSection { | ||
padding: 0px 24px; | ||
} | ||
|
||
.jobPostingsContainer { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
} | ||
|
||
.filters { | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
padding: 0rem 1.5rem; | ||
gap: 0.75rem; | ||
} | ||
|
||
.jobPostings { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
gap: 0.5rem; | ||
text-wrap: wrap; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,4 +155,5 @@ small { | |
|
||
a { | ||
color: var(--text-primary); | ||
text-decoration: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { CompanyLocation } from "studio/lib/interfaces/companyDetails"; | ||
|
||
export interface IJobPosting { | ||
_key: string; | ||
role: string; | ||
locations: CompanyLocation[]; | ||
recruiteeAdUrl: string; | ||
} | ||
|
||
export interface IJobPostings { | ||
jobPostingsArray: IJobPosting[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.