Skip to content

Commit

Permalink
feat(cow-fi): change greenhouse to ashbyhq (#4849)
Browse files Browse the repository at this point in the history
(cherry picked from commit 966b1da)
  • Loading branch information
fairlighteth authored and shoom3301 committed Sep 3, 2024
1 parent 74fbdcc commit 73ff905
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 38 deletions.
4 changes: 1 addition & 3 deletions apps/cow-fi/const/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export const CONFIG = {
grants: 'https://grants.cow.fi',
mevBlocker: 'https://mevblocker.io/',
},
greenhouse: {
api: 'https://boards-api.greenhouse.io/v1/boards/cowswap/jobs?content=true',
},
ashbyHqApi: 'https://jobs.ashbyhq.com/api/non-user-graphql',
social: {
twitter: { label: 'Twitter', account: '@CoWSwap', url: 'https://twitter.com/CoWSwap' },
discord: { label: 'Discord', url: 'https://discord.com/invite/cowprotocol' },
Expand Down
48 changes: 32 additions & 16 deletions apps/cow-fi/pages/careers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getJobs } from 'services/greenhouse'
import { getJobs } from 'services/ashByHq'
import { GetStaticProps } from 'next'
import { Font, Color, ProductLogo, ProductVariant } from '@cowprotocol/ui'

Expand Down Expand Up @@ -63,14 +63,18 @@ export default function Page({ siteConfigData, jobsData }: PageProps) {
</SectionTitleText>
</SectionTitleWrapper>

{jobsCount < 1 && <p>There are currently no open positions.</p>}
{jobsCount < 1 && (
<SectionTitleWrapper maxWidth={900} margin="0 auto">
<SectionTitleText fontSize={32}>There are currently no open positions.</SectionTitleText>
</SectionTitleWrapper>
)}

<TopicList columns={2} columnsTablet={2} maxWidth={900} margin="16px auto 0">
{jobsCount > 0 &&
(department === 'All'
? Object.keys(jobsData).map((deptName: string) => (
<>
{jobsData[deptName].map(({ absolute_url, title, location }: any, index: number) => (
{jobsData[deptName].map(({ id, title, locationName }: any, index: number) => (
<TopicCard
key={index}
contentAlign={'left'}
Expand All @@ -86,12 +90,12 @@ export default function Page({ siteConfigData, jobsData }: PageProps) {
</TopicTitle>
<TopicTitle fontSize={34}>{title}</TopicTitle>
<TopicDescription fontSize={18} color={Color.neutral40} margin="0 0 24px">
{location.name}
{locationName}
</TopicDescription>
<Link
external
linkType={LinkType.TopicButton}
href={absolute_url}
href={`https://jobs.ashbyhq.com/cow-dao/${id}`}
utmContent={`job-${title}`}
margin="auto auto 0 0"
marginTablet="auto auto 0"
Expand All @@ -107,7 +111,7 @@ export default function Page({ siteConfigData, jobsData }: PageProps) {
: jobsCount > 0 && (
<>
<h4>{department}</h4>
{jobsData[department].map(({ absolute_url, title, location }: any, index: number) => (
{jobsData[department].map(({ id, title, locationName }: any, index: number) => (
<TopicCard
key={index}
contentAlign={'left'}
Expand All @@ -119,12 +123,12 @@ export default function Page({ siteConfigData, jobsData }: PageProps) {
<TopicCardInner contentAlign="left">
<TopicTitle>{title}</TopicTitle>
<TopicDescription fontSize={18} color={Color.neutral40} margin="0">
{location.name}
{locationName}
</TopicDescription>
<Link
external
linkType={LinkType.TopicButton}
href={absolute_url}
href={`https://jobs.ashbyhq.com/cow-dao/${id}`}
utmContent={`job-${title}`}
onClick={() => clickOnCareers(`click-job-${title}`)}
>
Expand Down Expand Up @@ -184,13 +188,25 @@ export default function Page({ siteConfigData, jobsData }: PageProps) {

export const getStaticProps: GetStaticProps<PageProps> = async () => {
const siteConfigData = CONFIG
const jobsData = await getJobs()

return {
props: {
siteConfigData,
jobsData,
},
revalidate: DATA_CACHE_TIME_SECONDS,
console.log('Fetching jobs data...')
try {
const jobsData = (await getJobs()) || {}
console.log('Jobs data fetched:', jobsData)
return {
props: {
siteConfigData,
jobsData,
},
revalidate: DATA_CACHE_TIME_SECONDS,
}
} catch (error) {
console.error('Error fetching jobs data:', error)
return {
props: {
siteConfigData,
jobsData: {},
},
revalidate: DATA_CACHE_TIME_SECONDS,
}
}
}
78 changes: 78 additions & 0 deletions apps/cow-fi/services/ashByHq/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { CONFIG } from '@/const/meta'

interface AshbyResponse {
data: {
jobBoard: {
teams: { id: string; name: string; parentTeamId: string | null }[]
jobPostings: {
id: string
title: string
teamId: string
locationName: string
employmentType: string
}[]
}
}
}

export async function getJobs() {
console.log('getJobs function called')
const jobsData: any = {}
const { ashbyHqApi } = CONFIG

console.log('Ashby HQ API URL:', ashbyHqApi)

try {
console.log('Fetching data from Ashby HQ API...')
const response = await fetch(ashbyHqApi, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apollographql-client-name': 'frontend_non_user',
'apollographql-client-version': '0.1.0',
},
body: JSON.stringify({
operationName: 'ApiJobBoardWithTeams',
variables: { organizationHostedJobsPageName: 'cow-dao' },
query: `
query ApiJobBoardWithTeams($organizationHostedJobsPageName: String!) {
jobBoard: jobBoardWithTeams(
organizationHostedJobsPageName: $organizationHostedJobsPageName
) {
teams {
id
name
parentTeamId
}
jobPostings {
id
title
teamId
locationName
employmentType
}
}
}
`,
}),
})
console.log('Response status:', response.status)
const data = (await response.json()) as AshbyResponse
console.log('Ashby HQ API response:', JSON.stringify(data, null, 2))

if (data.data?.jobBoard?.jobPostings) {
data.data.jobBoard.jobPostings.forEach((job) => {
const team = data.data.jobBoard.teams.find((t) => t.id === job.teamId)
const deptName = team ? team.name : 'Other'
jobsData[deptName] ? jobsData[deptName].push(job) : (jobsData[deptName] = [job])
})
} else {
console.error('Unexpected API response structure:', JSON.stringify(data, null, 2))
}
} catch (error) {
console.error('Error fetching jobs:', error)
}

console.log('Processed job data:', JSON.stringify(jobsData, null, 2))
return jobsData
}
19 changes: 0 additions & 19 deletions apps/cow-fi/services/greenhouse/index.ts

This file was deleted.

0 comments on commit 73ff905

Please sign in to comment.