Skip to content

Commit

Permalink
✨ Add schemas for job postings
Browse files Browse the repository at this point in the history
  • Loading branch information
petterhh committed Nov 26, 2024
1 parent 19c6f32 commit fbe61d8
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
10 changes: 10 additions & 0 deletions studio/deskStructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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")
),
]),
);

Expand Down
4 changes: 4 additions & 0 deletions studio/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -43,5 +45,7 @@ export const schema: { types: SchemaTypeDefinition[] } = {
richText,
seo,
announcement,
jobPosting,
jobPostings,
],
};
21 changes: 21 additions & 0 deletions studio/schemas/documents/admin/jobPostings.ts
Original file line number Diff line number Diff line change
@@ -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;
53 changes: 53 additions & 0 deletions studio/schemas/objects/jobPosting.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit fbe61d8

Please sign in to comment.