From fbe61d8d820a5b5a1243316b69cba0fbded7ebd7 Mon Sep 17 00:00:00 2001 From: Petter Hohle Date: Tue, 26 Nov 2024 08:48:24 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20schemas=20for=20job=20posting?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- studio/deskStructure.ts | 10 ++++ studio/schema.ts | 4 ++ studio/schemas/documents/admin/jobPostings.ts | 21 ++++++++ studio/schemas/objects/jobPosting.ts | 53 +++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 studio/schemas/documents/admin/jobPostings.ts create mode 100644 studio/schemas/objects/jobPosting.ts diff --git a/studio/deskStructure.ts b/studio/deskStructure.ts index 7db88f680..a2afd28e0 100644 --- a/studio/deskStructure.ts +++ b/studio/deskStructure.ts @@ -28,6 +28,7 @@ import { brandAssetsID } from "./schemas/documents/siteSettings/brandAssets"; import { localeID } from "./schemas/documents/siteSettings/locale"; import { soMeLinksID } from "./schemas/documents/siteSettings/socialMediaProfiles"; import { customerCasesPageID } from "./schemas/documents/specialPages/customerCasesPage"; +import { jobPostingsID } from "./schemas/documents/admin/jobPostings"; // Admin Section const adminSection = (S: StructureBuilder) => @@ -59,6 +60,15 @@ const adminSection = (S: StructureBuilder) => .child( S.documentTypeList(legalDocumentID).title("Legal Documents"), ), + S.listItem() + .title("Job Postings") + .icon(CaseIcon) + .child( + S.document() + .schemaType(jobPostingsID) + .documentId(jobPostingsID) + .title("Job Postings") + ), ]), ); diff --git a/studio/schema.ts b/studio/schema.ts index 324b8c11c..bb8a5e7ba 100644 --- a/studio/schema.ts +++ b/studio/schema.ts @@ -20,6 +20,8 @@ import { footerSection } from "./schemas/objects/footerSection"; import { link } from "./schemas/objects/link"; import seo from "./schemas/objects/seo"; import { socialMedia } from "./schemas/objects/socialMedia"; +import jobPosting from "./schemas/objects/jobPosting"; +import jobPostings from "./schemas/documents/admin/jobPostings"; export const schema: { types: SchemaTypeDefinition[] } = { types: [ @@ -43,5 +45,7 @@ export const schema: { types: SchemaTypeDefinition[] } = { richText, seo, announcement, + jobPosting, + jobPostings, ], }; diff --git a/studio/schemas/documents/admin/jobPostings.ts b/studio/schemas/documents/admin/jobPostings.ts new file mode 100644 index 000000000..146a9f6d2 --- /dev/null +++ b/studio/schemas/documents/admin/jobPostings.ts @@ -0,0 +1,21 @@ +import { defineType } from "sanity"; + +import { jobPostingID } from "studio/schemas/objects/jobPosting"; + +export const jobPostingsID = "jobPostings"; + +const jobPostings = defineType({ + name: jobPostingsID, + type: "document", + title: "Job Postings", + fields: [ + { + name: "jobPostings", + title: "Job Postings", + type: "array", + of: [{ type: jobPostingID }], + }, + ], +}); + +export default jobPostings; diff --git a/studio/schemas/objects/jobPosting.ts b/studio/schemas/objects/jobPosting.ts new file mode 100644 index 000000000..0eed8472d --- /dev/null +++ b/studio/schemas/objects/jobPosting.ts @@ -0,0 +1,53 @@ +import { defineType } from "sanity"; +import { isInternationalizedString } from "studio/lib/interfaces/global"; +import { firstTranslation } from "studio/utils/i18n"; + + +export const jobPostingID = "jobPosting"; + +const jobPosting = defineType({ + name: jobPostingID, + title: "Job Posting", + type: "object", + fields: [ + { + title: "Role", + name: "role", + type: "internationalizedArrayString", + description: "The name of the role", + }, + { + title: "Location", + name: "location", + type: "reference", + to: [{ type: 'companyLocation' }], + description: "Where is the role located?" + }, + { + title: "Recruitee ad URL", + name: "recruiteeAdUrl", + type: "url", + description: "URL to Recruitee ad", + }, + ], + preview: { + select: { + title: "role", + location: "location.companyLocationName", + }, + prepare(selection) { + const { title, location } = selection; + if (!isInternationalizedString(title)) { + throw new TypeError( + `Expected 'title' to be InternationalizedString, was ${typeof title}`, + ); + } + return { + title: firstTranslation(title) ?? undefined, + subtitle: location, + }; + }, + }, +}); + +export default jobPosting;