Skip to content

Commit

Permalink
feat(customerCase): fields for top section in customer cases
Browse files Browse the repository at this point in the history
Co-authored-by: Mathias Oterhals Myklebust <[email protected]>
  • Loading branch information
anemne and mathiazom committed Oct 16, 2024
1 parent 6467d13 commit 19ecb7c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 9 deletions.
18 changes: 17 additions & 1 deletion studioShared/lib/queries/customerCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,23 @@ export const CUSTOMER_CASES_QUERY = groq`
}
`;

export const CUSTOMER_CASE_QUERY = groq`*[_type == "customerCase" && slug.current == $slug && language == $language][0]`;
export const CUSTOMER_CASE_QUERY = groq`
*[_type == "customerCase" && ${translatedFieldFragment("slug")} == $slug][0] {
${LANGUAGE_FIELD_FRAGMENT},
"slug": ${translatedFieldFragment("slug")},
"basicTitle": ${translatedFieldFragment("basicTitle")},
"description": ${translatedFieldFragment("description")},
"richText": ${translatedFieldFragment("richText")},
"projectInfo": projectInfo {
customer,
"name": ${translatedFieldFragment("name")},
"duration": ${translatedFieldFragment("duration")},
"sector": ${translatedFieldFragment("sector")},
"delivery": ${translatedFieldFragment("delivery")},
consultants
}
}
`;

export const CUSTOMER_CASES_SITEMAP_QUERY = groq`
*[_type == "customerCase"] {
Expand Down
24 changes: 17 additions & 7 deletions studioShared/schemas/documents/customerCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { isInternationalizedString } from "studio/lib/interfaces/global";
import { richTextID, titleID } from "studio/schemas/fields/text";
import { titleSlug } from "studio/schemas/schemaTypes/slug";
import { firstTranslation } from "studio/utils/i18n";
import { customerCaseProjectInfo } from "studioShared/schemas/fields/customerCaseProjectInfo";

export const customerCaseID = "customerCase";

Expand All @@ -12,15 +13,24 @@ const customerCase = defineType({
type: "document",
title: "Customer Case",
fields: [
{
name: titleID.basic,
type: "internationalizedArrayString",
title: "Customer Case Title",
},
{
defineField({
...titleSlug,
type: "internationalizedArrayString",
},
}),
defineField({
name: titleID.basic,
type: "internationalizedArrayString",
title: "Title",
}),
defineField({
name: "description",
type: "internationalizedArrayText",
title: "Description",
description:
"Short paragraph displayed at the top of the customer case page",
}),
customerCaseProjectInfo,
//TODO: Block section
defineField({
name: richTextID,
title: "Body",
Expand Down
44 changes: 44 additions & 0 deletions studioShared/schemas/fields/customerCaseProjectInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { defineField } from "sanity";

export const customerCaseProjectInfo = defineField({
name: "projectInfo",
title: "Project Info",
description: "General information about the project",
type: "object",
fields: [
defineField({
name: "customer",
description: "The customer for the project",
type: "string",
}),
defineField({
name: "name",
description: "The name of the project",
type: "internationalizedArrayString",
}),
defineField({
name: "duration",
description: "The duration of the project (e.g. 'Q2 2023 – Q1 2024')",
type: "internationalizedArrayString",
}),
defineField({
// TODO: pick from global sector tags
name: "sector",
description: "The sector of the project",
type: "internationalizedArrayString",
}),
defineField({
// TODO: pick from global delivery tags
name: "delivery",
description: "The delivery of the project",
type: "internationalizedArrayString",
}),
defineField({
// TODO: We should be able to select the consultants from a list
name: "consultants",
description: "The consultants for the project",
type: "array",
of: [{ type: "string" }],
}),
],
});
2 changes: 1 addition & 1 deletion studioShared/studioConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const config: WorkspaceOptions = {
media(),
internationalizedArray({
languages: supportedLanguages,
fieldTypes: ["string", "richText"],
fieldTypes: ["string", "richText", "text"],
}),
],
};
Expand Down

0 comments on commit 19ecb7c

Please sign in to comment.