diff --git a/src/app/(main)/[lang]/[...path]/page.tsx b/src/app/(main)/[lang]/[...path]/page.tsx index 2f29273c6..627003cfe 100644 --- a/src/app/(main)/[lang]/[...path]/page.tsx +++ b/src/app/(main)/[lang]/[...path]/page.tsx @@ -93,7 +93,9 @@ async function Page({ params }: Props) { case "customerCase": return ( // TODO: implement customer case detail page -
+        
           {JSON.stringify(pageData, null, 2)}
         
); @@ -103,6 +105,15 @@ async function Page({ params }: Props) { ) : ( ); + case "employeesPage": + return ( + // TODO: implement employees page +
+          {JSON.stringify(pageData, null, 2)}
+        
+ ); } return Page404; diff --git a/src/utils/pageData.ts b/src/utils/pageData.ts index d29653cef..54d1de33e 100644 --- a/src/utils/pageData.ts +++ b/src/utils/pageData.ts @@ -3,6 +3,7 @@ import { QueryResponseInitial } from "@sanity/react-loader"; import { CompanyLocation } from "studio/lib/interfaces/companyDetails"; import { CompensationsPage } from "studio/lib/interfaces/compensations"; +import { EmployeesPage } from "studio/lib/interfaces/employeesPage"; import { LegalDocument } from "studio/lib/interfaces/legalDocuments"; import { LocaleDocument } from "studio/lib/interfaces/locale"; import { PageBuilder } from "studio/lib/interfaces/pages"; @@ -16,12 +17,14 @@ import { PAGE_BY_SLUG_QUERY } from "studio/lib/queries/pages"; import { COMPENSATIONS_PAGE_QUERY, CUSTOMER_CASES_PAGE_QUERY, + EMPLOYEES_PAGE_QUERY, } from "studio/lib/queries/specialPages"; import { loadStudioQuery } from "studio/lib/store"; import { legalDocumentID } from "studio/schemas/documents/admin/legalDocuments"; import { compensationsId } from "studio/schemas/documents/compensations"; import { pageBuilderID } from "studio/schemas/documents/pageBuilder"; import { customerCasesPageID } from "studio/schemas/documents/specialPages/customerCasesPage"; +import { employeesPageId } from "studio/schemas/documents/specialPages/employeesPage"; import { CustomerCase } from "studioShared/lib/interfaces/customerCases"; import { CUSTOMER_CASE_QUERY } from "studioShared/lib/queries/customerCases"; import { loadSharedQuery } from "studioShared/lib/store"; @@ -231,6 +234,40 @@ async function fetchLegalDocument({ }; } +async function fetchEmployeesPage({ + language, + path, + perspective, +}: PageDataParams): Promise, + typeof employeesPageId +> | null> { + if (path.length === 0) { + return null; + } + const queryParams = { + slug: path[0], + language, + }; + const employeesPageResult = await loadStudioQuery( + EMPLOYEES_PAGE_QUERY, + queryParams, + { perspective }, + ); + if (employeesPageResult.data === null) { + return null; + } + return { + query: EMPLOYEES_PAGE_QUERY, + queryParams, + queryResponse: { + ...employeesPageResult, + data: employeesPageResult.data, + }, + docType: employeesPageId, + }; +} + export interface PageDataParams { language: string; path: string[]; @@ -242,6 +279,7 @@ export async function fetchPageDataFromParams(params: PageDataParams) { (await fetchDynamicPage(params)) ?? (await fetchCompensationsPage(params)) ?? (await fetchCustomerCase(params)) ?? - (await fetchLegalDocument(params)) + (await fetchLegalDocument(params)) ?? + (await fetchEmployeesPage(params)) ); } diff --git a/studio/deskStructure.ts b/studio/deskStructure.ts index a72c47273..5a703bfca 100644 --- a/studio/deskStructure.ts +++ b/studio/deskStructure.ts @@ -28,6 +28,7 @@ import { brokenLinkID } from "./schemas/documents/siteSettings/brokenLink"; import { localeID } from "./schemas/documents/siteSettings/locale"; import { soMeLinksID } from "./schemas/documents/siteSettings/socialMediaProfiles"; import { customerCasesPageID } from "./schemas/documents/specialPages/customerCasesPage"; +import { employeesPageId } from "./schemas/documents/specialPages/employeesPage"; // Admin Section const adminSection = (S: StructureBuilder) => @@ -172,6 +173,15 @@ const specialPagesSection = (S: StructureBuilder) => .documentId(customerCasesPageID) .title("Customer Cases"), ), + S.listItem() + .title("Employees") + .icon(UsersIcon) + .child( + S.document() + .schemaType(employeesPageId) + .documentId(employeesPageId) + .title("Employees"), + ), ]), ); diff --git a/studio/lib/interfaces/employeesPage.ts b/studio/lib/interfaces/employeesPage.ts new file mode 100644 index 000000000..3a8f56ca5 --- /dev/null +++ b/studio/lib/interfaces/employeesPage.ts @@ -0,0 +1,10 @@ +export interface EmployeesPage { + _createdAt: string; + _id: string; + _rev: string; + _type: string; + _updatedAt: string; + language: string; + basicTitle: string; + slug: string; +} diff --git a/studio/lib/queries/specialPages.ts b/studio/lib/queries/specialPages.ts index add8e9364..e69df5aa8 100644 --- a/studio/lib/queries/specialPages.ts +++ b/studio/lib/queries/specialPages.ts @@ -1,12 +1,13 @@ import { groq } from "next-sanity"; +import { LANGUAGE_FIELD_FRAGMENT } from "./i18n"; import { translatedFieldFragment } from "./utils/i18n"; //Compensations export const COMPENSATIONS_PAGE_QUERY = groq` *[_type == "compensations" && ${translatedFieldFragment("slug")} == $slug][0] { ..., - "language": $language, + ${LANGUAGE_FIELD_FRAGMENT}, "slug": ${translatedFieldFragment("slug")}, "basicTitle": ${translatedFieldFragment("basicTitle")}, "benefitsByLocation": benefitsByLocation[] { @@ -24,3 +25,13 @@ export const COMPENSATIONS_PAGE_QUERY = groq` //Customer Cases export const CUSTOMER_CASES_PAGE_QUERY = groq` *[_type == "customerCasesPage" && slug.current == $slug][0]`; + +//Employees Page +export const EMPLOYEES_PAGE_QUERY = groq` + *[_type == "employeesPage" && ${translatedFieldFragment("slug")} == $slug][0] { + ..., + ${LANGUAGE_FIELD_FRAGMENT}, + "slug": ${translatedFieldFragment("slug")}, + "basicTitle": ${translatedFieldFragment("basicTitle")}, + } +`; diff --git a/studio/schema.ts b/studio/schema.ts index 51c3e0f4f..33c1bee5f 100644 --- a/studio/schema.ts +++ b/studio/schema.ts @@ -15,6 +15,7 @@ import locale from "./schemas/documents/siteSettings/locale"; import navigationManager from "./schemas/documents/siteSettings/navigationManager"; import socialMediaLinks from "./schemas/documents/siteSettings/socialMediaProfiles"; import customerCasesPage from "./schemas/documents/specialPages/customerCasesPage"; +import employeesPage from "./schemas/documents/specialPages/employeesPage"; import callToActionField from "./schemas/fields/callToActionFields"; import categories from "./schemas/fields/categories"; import { richText } from "./schemas/fields/text"; @@ -49,5 +50,6 @@ export const schema: { types: SchemaTypeDefinition[] } = { locale, richText, seo, + employeesPage, ], }; diff --git a/studio/schemas/documents/specialPages/employeesPage.ts b/studio/schemas/documents/specialPages/employeesPage.ts new file mode 100644 index 000000000..2559c9440 --- /dev/null +++ b/studio/schemas/documents/specialPages/employeesPage.ts @@ -0,0 +1,44 @@ +import { defineType } from "sanity"; + +import { isInternationalizedString } from "studio/lib/interfaces/global"; +import { title, titleID } from "studio/schemas/fields/text"; +import { titleSlug } from "studio/schemas/schemaTypes/slug"; +import { firstTranslation } from "studio/utils/i18n"; + +export const employeesPageId = "employeesPage"; + +const employeesPage = defineType({ + name: employeesPageId, + type: "document", + title: "Employees Page", + fields: [ + { + name: titleID.basic, + type: "internationalizedArrayString", + title: "Page Title", + description: + "Enter the primary title that will be displayed at the top of the employees page. This is what users will see when they visit the page.", + }, + { + ...titleSlug, + type: "internationalizedArrayString", + }, + ], + preview: { + select: { + title: title.name, + }, + prepare({ title }) { + if (!isInternationalizedString(title)) { + throw new TypeError( + `Expected 'title' to be InternationalizedString, was ${typeof title}`, + ); + } + return { + title: firstTranslation(title) ?? undefined, + }; + }, + }, +}); + +export default employeesPage;