diff --git a/src/components/customerCases/CustomerCases.tsx b/src/components/customerCases/CustomerCases.tsx index fec733a4a..9049e4748 100644 --- a/src/components/customerCases/CustomerCases.tsx +++ b/src/components/customerCases/CustomerCases.tsx @@ -1,10 +1,9 @@ import LinkButton from "src/components/linkButton/LinkButton"; -import { RichText } from "src/components/richText/RichText"; import Text from "src/components/text/Text"; import { sharedCustomerCasesLink } from "src/components/utils/linkTypes"; import { getDraftModeInfo } from "src/utils/draftmode"; import { CustomerCasePage } from "studio/lib/interfaces/specialPages"; -import { CustomerCase } from "studioShared/lib/interfaces/customerCases"; +import { CustomerCaseBase } from "studioShared/lib/interfaces/customerCases"; import { CUSTOMER_CASES_QUERY } from "studioShared/lib/queries/customerCases"; import { loadSharedQuery } from "studioShared/lib/store"; @@ -18,7 +17,7 @@ const CustomerCases = async ({ customerCasesPage }: CustomerCasesProps) => { const { perspective } = getDraftModeInfo(); const [sharedCustomerCases] = await Promise.all([ - loadSharedQuery( + loadSharedQuery( CUSTOMER_CASES_QUERY, { language: customerCasesPage.language }, { perspective }, @@ -29,11 +28,11 @@ const CustomerCases = async ({ customerCasesPage }: CustomerCasesProps) => {
{customerCasesPage.basicTitle} {sharedCustomerCases && sharedCustomerCases.data.length > 0 ? ( - sharedCustomerCases.data.map((customerCase: CustomerCase) => ( + sharedCustomerCases.data.map((customerCase) => (
{customerCase.basicTitle} - {customerCase.richText && ( - + {customerCase.description && ( + {customerCase.description} )}
)) diff --git a/studioShared/lib/interfaces/customerCases.ts b/studioShared/lib/interfaces/customerCases.ts index 46e7152d7..48b41607d 100644 --- a/studioShared/lib/interfaces/customerCases.ts +++ b/studioShared/lib/interfaces/customerCases.ts @@ -1,13 +1,23 @@ import { PortableTextBlock, Slug } from "sanity"; -export interface CustomerCase { - language: string; +export interface CustomerCaseProjectInfo { + customer: string; + name: string; + duration: string; + sector: string; + delivery: string; + consultants: string[]; +} + +export interface CustomerCaseBase { _id: string; - basicTitle: string; - _updatedAt: string; + language: string; slug: Slug; - _createdAt: string; - _rev: string; - _type: string; + basicTitle: string; + description: string; +} + +export interface CustomerCase extends CustomerCaseBase { richText: PortableTextBlock[]; + projectInfo: CustomerCaseProjectInfo; } diff --git a/studioShared/lib/queries/customerCases.ts b/studioShared/lib/queries/customerCases.ts index c1373c03f..c621a3484 100644 --- a/studioShared/lib/queries/customerCases.ts +++ b/studioShared/lib/queries/customerCases.ts @@ -3,20 +3,23 @@ import { groq } from "next-sanity"; import { LANGUAGE_FIELD_FRAGMENT } from "studio/lib/queries/i18n"; import { translatedFieldFragment } from "studio/lib/queries/utils/i18n"; +const CUSTOMER_CASE_BASE_FRAGMENT = groq` + _id, + ${LANGUAGE_FIELD_FRAGMENT}, + "slug": ${translatedFieldFragment("slug")}, + "basicTitle": ${translatedFieldFragment("basicTitle")}, + "description": ${translatedFieldFragment("description")} +`; + export const CUSTOMER_CASES_QUERY = groq` *[_type == "customerCase"]{ - ${LANGUAGE_FIELD_FRAGMENT}, - "basicTitle": ${translatedFieldFragment("basicTitle")}, - "richText": ${translatedFieldFragment("richText")} + ${CUSTOMER_CASE_BASE_FRAGMENT} } `; export const CUSTOMER_CASE_QUERY = groq` *[_type == "customerCase" && ${translatedFieldFragment("slug")} == $slug][0] { - ${LANGUAGE_FIELD_FRAGMENT}, - "slug": ${translatedFieldFragment("slug")}, - "basicTitle": ${translatedFieldFragment("basicTitle")}, - "description": ${translatedFieldFragment("description")}, + ${CUSTOMER_CASE_BASE_FRAGMENT} "richText": ${translatedFieldFragment("richText")}, "projectInfo": projectInfo { customer,