-
Notifications
You must be signed in to change notification settings - Fork 0
Replace Prismic open positions with Ashby-sourced roles #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
samweaver
wants to merge
1
commit into
main
Choose a base branch
from
careers-ashby-job-board
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| /// <reference types="next" /> | ||
| /// <reference types="next/image-types/global" /> | ||
| import "./.next/dev/types/routes.d.ts"; | ||
| import "./.next/types/routes.d.ts"; | ||
|
|
||
| // NOTE: This file should not be edited | ||
| // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
106 changes: 106 additions & 0 deletions
106
src/slices/main/OpenPositions/components/OpenPositionsList.tsx
This file contains hidden or 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,106 @@ | ||
| 'use client' | ||
|
|
||
| import { useMemo, useState } from 'react' | ||
|
|
||
| import type { AshbyJob } from '@/utils/ashby' | ||
|
|
||
| import FilterButtonGroup from '@/components/FilterButtonGroup' | ||
| import SvgArrowDownAccordion from '@/components/svg/SvgArrowDownAccordion' | ||
| import { Button } from '@/components/ui/Button' | ||
|
|
||
| const VIEW_ALL = 'View All' | ||
|
|
||
| export type OpenPositionsListProps = { | ||
| jobs: AshbyJob[] | ||
| } | ||
|
|
||
| export default function OpenPositionsList({ jobs }: OpenPositionsListProps) { | ||
| const [selectedCategory, setSelectedCategory] = useState<string>(VIEW_ALL) | ||
|
|
||
| const categories = useMemo( | ||
| () => [ | ||
| VIEW_ALL, | ||
| ...new Set(jobs.map(({ category }) => category).filter(Boolean)), | ||
| ], | ||
| [jobs] | ||
| ) | ||
|
|
||
| const onCategoryButtonClick = (category: string) => () => | ||
| setSelectedCategory(category) | ||
|
|
||
| const filteredJobs = useMemo( | ||
| () => | ||
| selectedCategory === VIEW_ALL | ||
| ? jobs | ||
| : jobs.filter(({ category }) => category === selectedCategory), | ||
| [jobs, selectedCategory] | ||
| ) | ||
|
|
||
| if (jobs.length === 0) { | ||
| return ( | ||
| <p className="text-body-small text-neutral-000/70 mt-6"> | ||
| There are no open positions right now — check back soon. | ||
| </p> | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <FilterButtonGroup<string> | ||
| buttons={categories} | ||
| onButtonClick={onCategoryButtonClick} | ||
| selectedButtons={selectedCategory} | ||
| /> | ||
| <div className="mt-6 flex flex-col"> | ||
| {filteredJobs.map( | ||
| ({ id, title, location, category, compensation, url }) => ( | ||
| <a | ||
| key={id} | ||
| href={url} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <div className="group border-neutral-000/10 grid cursor-pointer grid-cols-[1fr_2.5rem] gap-2 border-b py-5 transition lg:grid-cols-[3.5fr_1.5fr_2fr_2.5rem] lg:items-center lg:px-4 lg:hover:bg-neutral-800"> | ||
| <div> | ||
| <h4 className="text-title-large">{title}</h4> | ||
| {compensation && ( | ||
| <span className="text-caption text-neutral-000/50 mt-1 block"> | ||
| {compensation} | ||
| </span> | ||
| )} | ||
| </div> | ||
| <span className="text-caption text-neutral-000 hidden lg:block"> | ||
| {location} | ||
| </span> | ||
| <span className="text-caption text-neutral-000/70 hidden lg:block"> | ||
| {category} | ||
| </span> | ||
| <Button | ||
| className="row-span-2 h-10 w-10 self-center justify-self-end p-0 group-hover:border-white/24 lg:row-span-1" | ||
| variant="secondary" | ||
| > | ||
| <SvgArrowDownAccordion className="rotate-[-90deg] transform text-white" /> | ||
| </Button> | ||
| <div className="flex items-center gap-0.5 lg:hidden"> | ||
| <span className="text-caption text-neutral-000"> | ||
| {location} | ||
| </span> | ||
| {category && ( | ||
| <> | ||
| <span className="text-caption text-neutral-000/70 h-[0.8125rem] w-4"> | ||
| ・ | ||
| </span> | ||
| <span className="text-caption text-neutral-000/70"> | ||
| {category} | ||
| </span> | ||
| </> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </a> | ||
| ) | ||
| )} | ||
| </div> | ||
| </> | ||
| ) | ||
| } | ||
This file contains hidden or 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,93 @@ | ||
| /** | ||
| * Server-side fetch of open roles from Ashby's public Job Posting API. | ||
| * | ||
| * Docs: https://developers.ashbyhq.com/reference/job-posting-api | ||
| * The board name is the slug in your Ashby board URL (jobs.ashbyhq.com/<name>). | ||
| */ | ||
|
|
||
| const ASHBY_JOB_BOARD_NAME = | ||
| process.env.NEXT_PUBLIC_ASHBY_JOB_BOARD_NAME?.trim() || 'Plural' | ||
|
|
||
| const ASHBY_POSTING_API = `https://api.ashbyhq.com/posting-api/job-board/${ASHBY_JOB_BOARD_NAME}?includeCompensation=true` | ||
|
|
||
| // Roles change often; re-fetch at most once an hour (ISR). | ||
| const REVALIDATE_SECONDS = 60 * 60 | ||
|
|
||
| /** Raw shape returned by the Ashby posting API (only the fields we use). */ | ||
| type AshbyApiJob = { | ||
| id: string | ||
| title: string | ||
| team?: string | ||
| department?: string | ||
| location?: string | ||
| workplaceType?: string | ||
| employmentType?: string | ||
| isRemote?: boolean | ||
| isListed?: boolean | ||
| jobUrl: string | ||
| applyUrl: string | ||
| compensation?: { | ||
| compensationTierSummary?: string | null | ||
| } | null | ||
| } | ||
|
|
||
| type AshbyApiResponse = { | ||
| jobs?: AshbyApiJob[] | ||
| } | ||
|
|
||
| /** Normalized job used by the UI. */ | ||
| export type AshbyJob = { | ||
| id: string | ||
| title: string | ||
| /** Team/department — used as the filterable category. */ | ||
| category: string | ||
| /** Human-readable location, e.g. "New York City · Hybrid". */ | ||
| location: string | ||
| /** Compensation summary, e.g. "$175K – $200K • Offers Equity", if published. */ | ||
| compensation: string | null | ||
| /** External Ashby posting URL (description + apply button). */ | ||
| url: string | ||
| } | ||
|
|
||
| function toLocationLabel(job: AshbyApiJob): string { | ||
| const parts = [job.location, job.workplaceType].filter(Boolean) | ||
| return parts.join(' · ') | ||
| } | ||
|
|
||
| function normalize(job: AshbyApiJob): AshbyJob { | ||
| return { | ||
| id: job.id, | ||
| title: job.title, | ||
| category: job.team || job.department || '', | ||
| location: toLocationLabel(job), | ||
| compensation: job.compensation?.compensationTierSummary ?? null, | ||
| url: job.jobUrl, | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Fetches the currently-listed open roles from Ashby. Runs on the server, | ||
| * so it avoids CORS and keeps the third-party script off the page. Returns an | ||
| * empty array on any error so the section degrades gracefully. | ||
| */ | ||
| export async function getAshbyJobs(): Promise<AshbyJob[]> { | ||
| try { | ||
| const res = await fetch(ASHBY_POSTING_API, { | ||
| next: { revalidate: REVALIDATE_SECONDS }, | ||
| }) | ||
|
|
||
| if (!res.ok) { | ||
| console.error(`Ashby posting API returned ${res.status}`) | ||
| return [] | ||
| } | ||
|
|
||
| const data = (await res.json()) as AshbyApiResponse | ||
|
|
||
| return (data.jobs ?? []) | ||
| .filter((job) => job.isListed !== false) | ||
| .map(normalize) | ||
| } catch (error) { | ||
| console.error('Failed to fetch Ashby jobs', error) | ||
| return [] | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each job-row anchor contains a
Buttonthat defaults to a native<button>, creating two nested focusable controls for one action and producing redundant focus stops and ambiguous semantics for keyboard and screen-reader users.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!