From 466cea124b1666474ef024a45081c8fcf5db0719 Mon Sep 17 00:00:00 2001 From: Ida Marie Andreassen Date: Thu, 12 Dec 2024 08:52:00 +0100 Subject: [PATCH 1/4] Add title to customer case entry block --- .../customerCasesEntry/CustomerCasesEntry.tsx | 11 +++++++++- src/utils/renderSection.tsx | 4 ++-- studio/lib/queries/pages.ts | 3 +++ .../objects/sections/customerCasesEntry.ts | 22 ++++++++++++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/components/sections/customerCasesEntry/CustomerCasesEntry.tsx b/src/components/sections/customerCasesEntry/CustomerCasesEntry.tsx index c1fec4869..0a7e99a2d 100644 --- a/src/components/sections/customerCasesEntry/CustomerCasesEntry.tsx +++ b/src/components/sections/customerCasesEntry/CustomerCasesEntry.tsx @@ -1,21 +1,25 @@ import { headers } from "next/headers"; +import Text from "src/components/text/Text"; import { Locale } from "src/i18n/routing"; import { getDraftModeInfo } from "src/utils/draftmode"; import { domainFromHostname } from "src/utils/url"; +import { CustomerCasesEntrySection } from "studio/lib/interfaces/pages"; import { CUSTOMER_CASES_PAGE_SITEMAP_QUERY } from "studio/lib/queries/specialPages"; import { loadStudioQuery } from "studio/lib/store"; import { CustomerCaseEntry } from "studioShared/lib/interfaces/customerCases"; import { CUSTOMER_CASE_ENTRY_QUERY } from "studioShared/lib/queries/customerCases"; import { loadSharedQuery } from "studioShared/lib/store"; +import styles from "./customerCasesEntry.module.css"; import CustomerCasesList from "./CustomerCasesList"; interface CustomerCasesProps { language: Locale; + section: CustomerCasesEntrySection; } -async function CustomerCasesEntry({ language }: CustomerCasesProps) { +async function CustomerCasesEntry({ language, section }: CustomerCasesProps) { const { perspective } = getDraftModeInfo(); const domain = domainFromHostname(headers().get("host")); @@ -42,6 +46,11 @@ async function CustomerCasesEntry({ language }: CustomerCasesProps) { return ( customerCaseResult && (
+
+ + {section.basicTitle} + +
{ return isDraftMode ? ( - + ) : ( - + ); }; diff --git a/studio/lib/queries/pages.ts b/studio/lib/queries/pages.ts index 69766a785..e1991303e 100644 --- a/studio/lib/queries/pages.ts +++ b/studio/lib/queries/pages.ts @@ -85,6 +85,9 @@ const SECTIONS_FRAGMENT = groq` _type == "employeeHighlight" => { "basicTitle": ${translatedFieldFragment("basicTitle")}, "description": ${translatedFieldFragment("description")}, + }, + _type == "customerCasesEntry" => { + "basicTitle":${translatedFieldFragment("basicTitle")}, } } `; diff --git a/studio/schemas/objects/sections/customerCasesEntry.ts b/studio/schemas/objects/sections/customerCasesEntry.ts index 8334f2eb8..26e2b887b 100644 --- a/studio/schemas/objects/sections/customerCasesEntry.ts +++ b/studio/schemas/objects/sections/customerCasesEntry.ts @@ -1,16 +1,36 @@ +import { CaseIcon } from "@sanity/icons"; import { defineField } from "sanity"; +import { isInternationalizedString } from "studio/lib/interfaces/global"; +import { firstTranslation } from "studio/utils/i18n"; + export const customerCasesEntry = defineField({ name: "customerCasesEntry", title: "Customer Cases Entry", type: "object", + icon: CaseIcon, fields: [ { name: "basicTitle", title: "Basic Title", - type: "string", + type: "internationalizedArrayString", description: "This will be the title of the customer cases entry section. Make it engaging to capture the attention of your audience.", }, ], + preview: { + select: { + title: "basicTitle", + }, + prepare({ title }) { + if (!isInternationalizedString(title)) { + throw new TypeError( + `Expected 'title' to be InternationalizedString, was ${typeof title}`, + ); + } + return { + title: firstTranslation(title) ?? undefined, + }; + }, + }, }); From 775cc14679e1aa1ad9c3387b25915fd02b79bbdc Mon Sep 17 00:00:00 2001 From: Ida Marie Andreassen Date: Thu, 12 Dec 2024 08:52:26 +0100 Subject: [PATCH 2/4] Add styling to title --- .../customerCasesEntry.module.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/sections/customerCasesEntry/customerCasesEntry.module.css b/src/components/sections/customerCasesEntry/customerCasesEntry.module.css index b4c362d06..a5f395bae 100644 --- a/src/components/sections/customerCasesEntry/customerCasesEntry.module.css +++ b/src/components/sections/customerCasesEntry/customerCasesEntry.module.css @@ -128,3 +128,16 @@ content: "ยท"; margin: 0.5rem; } + +.titleWrapper { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + padding-bottom: 1.5rem; +} + +.title { + max-width: var(--max-content-width-medium); + width: 100%; +} From a1518ac308768c2f4df49c72e76eaaef3192eead Mon Sep 17 00:00:00 2001 From: Ida Marie Andreassen Date: Thu, 12 Dec 2024 08:54:01 +0100 Subject: [PATCH 3/4] Add translations to deliveries --- .../sections/customerCasesEntry/CustomerCasesList.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/sections/customerCasesEntry/CustomerCasesList.tsx b/src/components/sections/customerCasesEntry/CustomerCasesList.tsx index fa04f868f..c9eec8169 100644 --- a/src/components/sections/customerCasesEntry/CustomerCasesList.tsx +++ b/src/components/sections/customerCasesEntry/CustomerCasesList.tsx @@ -28,9 +28,9 @@ const CustomerCaseList = ({ const deliveryNames = [ selectedCustomerCase?.projectInfo.deliveries.projectManagement && - "Project Management", - selectedCustomerCase?.projectInfo.deliveries.design && "Design", - selectedCustomerCase?.projectInfo.deliveries.development && "Development", + "project_management", + selectedCustomerCase?.projectInfo.deliveries.design && "design", + selectedCustomerCase?.projectInfo.deliveries.development && "development", ].filter(Boolean); return ( @@ -90,7 +90,7 @@ function CardInfo({
{deliveryNames.map((deliveryName, index) => ( - {deliveryName} + {t(deliveryName)} ))}
From 002ee75a13dafcea371b324f010ae37b092bb7ab Mon Sep 17 00:00:00 2001 From: Ida Marie Andreassen Date: Thu, 12 Dec 2024 08:54:35 +0100 Subject: [PATCH 4/4] Remove console log from the past --- .../customerCase/contactInformation/ContactSelector.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/customerCases/customerCase/contactInformation/ContactSelector.tsx b/src/components/customerCases/customerCase/contactInformation/ContactSelector.tsx index 9ff75782a..507db68d1 100644 --- a/src/components/customerCases/customerCase/contactInformation/ContactSelector.tsx +++ b/src/components/customerCases/customerCase/contactInformation/ContactSelector.tsx @@ -39,7 +39,6 @@ export default function ContactSelector({ } const selectedOrDefaultLocationId = selectedLocationId ?? locationIds[0]; - console.log(selectedLocationId); return ( <>