Merged in feat/SW-1555-jobylon-feed-filter (pull request #1494)

Feat/SW-1555 jobylon feed filter

* feat(SW-1555): Added jobylon feed component

* feat(SW-1555): Added filter functionality for Jobylon feed


Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-03-07 11:46:42 +00:00
parent c3be694874
commit 7fa86a2077
15 changed files with 424 additions and 52 deletions

View File

@@ -2,16 +2,22 @@ import { z } from "zod"
import { dt } from "@/lib/dt"
const categoriesSchema = z.array(
z
.object({ category: z.object({ id: z.number(), text: z.string() }) })
.transform(({ category }) => {
return {
id: category.id,
text: category.text,
}
})
)
const categoriesSchema = z
.array(
z
.object({ category: z.object({ id: z.number(), text: z.string() }) })
.transform(({ category }) => {
return {
id: category.id,
text: category.text,
}
})
)
.transform((categories) =>
categories.filter(
(category): category is NonNullable<typeof category> => !!category
)
)
const departmentsSchema = z
.array(
@@ -99,6 +105,8 @@ export const jobylonItemSchema = z
const now = dt.utc()
const fromDate = from_date ? dt(from_date) : null
const toDate = to_date ? dt(to_date) : null
// Transformed to string as Dayjs objects cannot be passed to client components
const toDateAsString = toDate?.toString() ?? null
return {
id,
@@ -109,7 +117,7 @@ export const jobylonItemSchema = z
(!toDate || now.isSameOrBefore(toDate)),
categories,
departments,
toDate,
toDate: toDateAsString,
locations,
url: urls,
}