From 98c36f47a1690743ae390a00252b5249947c0e1c Mon Sep 17 00:00:00 2001 From: anemne <63043552+anemne@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:31:39 +0200 Subject: [PATCH 01/29] v3 - InformationMessage Component + replacement in main/page.tsx (#532) * InformationMessageComponent + replacement in main/page.tsx * update role attribute in InformationMessage component * refactor: improve code formatting in InformationMessage component * Moved links to utils section * Rename informationMessage to informationSection * prettier fix --- src/app/(main)/page.tsx | 15 ++++---- src/blog/Blog.tsx | 5 ++- .../customErrorMessage/CustomErrorMessage.tsx | 20 +---------- .../informationSection/InformationSection.tsx | 34 +++++++++++++++++++ .../informationSection.module.css | 31 +++++++++++++++++ src/blog/components/utils/linkTypes.ts | 19 +++++++++++ 6 files changed, 95 insertions(+), 29 deletions(-) create mode 100644 src/blog/components/informationSection/InformationSection.tsx create mode 100644 src/blog/components/informationSection/informationSection.module.css create mode 100644 src/blog/components/utils/linkTypes.ts diff --git a/src/app/(main)/page.tsx b/src/app/(main)/page.tsx index bdb3885b5..91537a58b 100644 --- a/src/app/(main)/page.tsx +++ b/src/app/(main)/page.tsx @@ -6,13 +6,12 @@ import SectionRenderer from "src/utils/renderSection"; import { loadQuery } from "studio/lib/store"; import { Metadata } from "next"; import { fetchSeoData, generateMetadataFromSeo } from "src/utils/seo"; -import CustomErrorMessage from "src/blog/components/customErrorMessage/CustomErrorMessage"; +import InformationSection from "src/blog/components/informationSection/InformationSection"; import { LinkType } from "studio/lib/payloads/navigation"; export async function generateMetadata(): Promise { const { data: landingId } = await loadQuery(LANDING_QUERY); const seo = await fetchSeoData(SEO_PAGE_QUERY, { id: landingId }); - return generateMetadataFromSeo(seo); } @@ -43,9 +42,11 @@ const Home = async () => { if (!landingId) { return ( - ); @@ -59,9 +60,9 @@ const Home = async () => { if (!initialLandingPage.data) { return ( - ); diff --git a/src/blog/Blog.tsx b/src/blog/Blog.tsx index 871f2b873..125ce695c 100644 --- a/src/blog/Blog.tsx +++ b/src/blog/Blog.tsx @@ -8,9 +8,8 @@ import BlogHero from "./components/hero/BlogHero"; import PostPreview from "src/blog/components/postPreview/PostPreview"; import PostPreviewGrid from "./components/postPreviewGrid/PostPreviewGrid"; import LoadingNews from "./components/loadingNews/LoadingNews"; -import CustomErrorMessage, { - homeLink, -} from "./components/customErrorMessage/CustomErrorMessage"; +import CustomErrorMessage from "./components/customErrorMessage/CustomErrorMessage"; +import { homeLink } from "./components/utils/linkTypes"; interface BlogProps { blog: BlogPage; diff --git a/src/blog/components/customErrorMessage/CustomErrorMessage.tsx b/src/blog/components/customErrorMessage/CustomErrorMessage.tsx index f921152e1..2c3883102 100644 --- a/src/blog/components/customErrorMessage/CustomErrorMessage.tsx +++ b/src/blog/components/customErrorMessage/CustomErrorMessage.tsx @@ -1,27 +1,9 @@ import Button from "src/components/buttons/Button"; import LinkButton from "src/components/linkButton/LinkButton"; import Text from "src/components/text/Text"; -import { ILink, LinkType } from "studio/lib/payloads/navigation"; +import { ILink } from "studio/lib/payloads/navigation"; import styles from "./customErrorMessage.module.css"; -export const homeLink = { - _key: "return-home", - _type: "link", - linkTitle: "Return to home", - linkType: LinkType.Internal, - internalLink: { - _ref: "/", - }, -}; - -export const studioLink = { - _key: "go-to-studio", - _type: "link", - linkTitle: "Go to studio", - linkType: LinkType.Internal, - internalLink: { _ref: "/studio" }, -}; - interface CustomErrorMessageProps { title: string; body: string; diff --git a/src/blog/components/informationSection/InformationSection.tsx b/src/blog/components/informationSection/InformationSection.tsx new file mode 100644 index 000000000..ca63836cb --- /dev/null +++ b/src/blog/components/informationSection/InformationSection.tsx @@ -0,0 +1,34 @@ +import LinkButton from "src/components/linkButton/LinkButton"; +import Text from "src/components/text/Text"; +import { ILink } from "studio/lib/payloads/navigation"; +import styles from "./informationSection.module.css"; +import React from "react"; + +interface InformationSectionProps { + title: string; + body: string; + link?: ILink; +} + +const InformationSection = ({ title, body, link }: InformationSectionProps) => { + return ( +
+
+ {title} + + {body.split("\n").map((line, index) => ( + + {line} +
+
+ ))} +
+
+ {link && } +
+
+
+ ); +}; + +export default InformationSection; diff --git a/src/blog/components/informationSection/informationSection.module.css b/src/blog/components/informationSection/informationSection.module.css new file mode 100644 index 000000000..7f3d7d632 --- /dev/null +++ b/src/blog/components/informationSection/informationSection.module.css @@ -0,0 +1,31 @@ +.wrapper { + display: flex; + padding: 5rem 2rem; + align-items: center; + align-self: stretch; + @media (min-width: 640px) { + padding: 5rem 3rem; + justify-content: center; + } + + @media (min-width: 1024px) { + padding: 7.5rem; + } +} + +.info { + max-width: 88rem; + display: flex; + padding: 3rem; + flex-direction: column; + align-items: flex-start; + gap: 1.5rem; + align-self: stretch; + border-radius: 1rem; +} + +.buttonWrapper { + display: flex; + align-items: flex-start; + gap: 1.5rem; +} diff --git a/src/blog/components/utils/linkTypes.ts b/src/blog/components/utils/linkTypes.ts new file mode 100644 index 000000000..9c26c81ce --- /dev/null +++ b/src/blog/components/utils/linkTypes.ts @@ -0,0 +1,19 @@ +import { LinkType } from "studio/lib/payloads/navigation"; + +export const homeLink = { + _key: "return-home", + _type: "link", + linkTitle: "Return to home", + linkType: LinkType.Internal, + internalLink: { + _ref: "/", + }, +}; + +export const studioLink = { + _key: "go-to-studio", + _type: "link", + linkTitle: "Go to studio", + linkType: LinkType.Internal, + internalLink: { _ref: "/studio" }, +}; From 8e3f64e06c904b691bb26a90ea1416097b53ac9c Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust <24361490+mathiazom@users.noreply.github.com> Date: Fri, 30 Aug 2024 10:56:11 +0200 Subject: [PATCH 02/29] v3 - Office document type (#539) * feat: Office document * refactor(schema): move office schema to bottom of types list * feat(office): add description to Office document schema --- studio/schema.ts | 2 ++ studio/schemas/documents/office.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 studio/schemas/documents/office.ts diff --git a/studio/schema.ts b/studio/schema.ts index cae9dd39e..17c539428 100644 --- a/studio/schema.ts +++ b/studio/schema.ts @@ -13,6 +13,7 @@ import categories from "./schemas/fields/categories"; import legalDocument from "./schemas/documents/legalDocuments"; import benefit from "./schemas/documents/benefit"; import salaryAndBenefits from "./schemas/documents/salaryAndBenefits"; +import office from "./schemas/documents/office"; export const schema: { types: SchemaTypeDefinition[] } = { types: [ @@ -30,5 +31,6 @@ export const schema: { types: SchemaTypeDefinition[] } = { legalDocument, salaryAndBenefits, benefit, + office, ], }; diff --git a/studio/schemas/documents/office.ts b/studio/schemas/documents/office.ts new file mode 100644 index 000000000..c354ee2c7 --- /dev/null +++ b/studio/schemas/documents/office.ts @@ -0,0 +1,14 @@ +import { defineType } from "sanity"; +import { title } from "../fields/text"; + +export const officeId = "office"; + +const office = defineType({ + name: officeId, + type: "document", + title: "Office", + description: "Content related to an individual office within the company", + fields: [title], +}); + +export default office; From 1cabfb54c7782c7f4d4a78d24f9487a1c3e978c1 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust <24361490+mathiazom@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:00:11 +0200 Subject: [PATCH 03/29] v3 - replace SalaryAndBenefits with Compensations list (#551) * feat: Office document * refactor(compensations): rename salaryAndBenefits to compensations * feat(studio): move Compensations under Static Pages * feat(Compensations): document list for compensations * chore(salaryAndBenefits): add deprecation TODO --- src/app/(main)/[slug]/page.tsx | 26 ++++++-------- .../Compensations.tsx} | 18 +++++----- src/compensations/CompensationsPreview.tsx | 28 +++++++++++++++ .../compensations.module.css} | 0 .../salaryCalculator/SalaryCalculator.tsx | 2 +- .../salaryCalculator.module.css | 0 .../utils/calculateSalary.ts | 0 .../utils/salaryData.ts | 0 .../SalaryAndBenefitsPreview.tsx | 28 --------------- ...{salaryAndBenefits.ts => compensations.ts} | 2 +- studio/lib/queries/pages.ts | 4 +-- studio/schema.ts | 5 ++- studio/schemas/deskStructure.ts | 17 ++++------ studio/schemas/documents/compensations.ts | 34 +++++++++++++++++++ studio/schemas/documents/salaryAndBenefits.ts | 12 ++++--- studio/schemas/objects/link.ts | 4 +-- 16 files changed, 107 insertions(+), 73 deletions(-) rename src/{salaryAndBenefits/SalaryAndBenefits.tsx => compensations/Compensations.tsx} (81%) create mode 100644 src/compensations/CompensationsPreview.tsx rename src/{salaryAndBenefits/salaryAndBenefits.module.css => compensations/compensations.module.css} (100%) rename src/{salaryAndBenefits => compensations}/components/salaryCalculator/SalaryCalculator.tsx (96%) rename src/{salaryAndBenefits => compensations}/components/salaryCalculator/salaryCalculator.module.css (100%) rename src/{salaryAndBenefits => compensations}/utils/calculateSalary.ts (100%) rename src/{salaryAndBenefits => compensations}/utils/salaryData.ts (100%) delete mode 100644 src/salaryAndBenefits/SalaryAndBenefitsPreview.tsx rename studio/lib/payloads/{salaryAndBenefits.ts => compensations.ts} (91%) create mode 100644 studio/schemas/documents/compensations.ts diff --git a/src/app/(main)/[slug]/page.tsx b/src/app/(main)/[slug]/page.tsx index cf9988578..c16aa1c8b 100644 --- a/src/app/(main)/[slug]/page.tsx +++ b/src/app/(main)/[slug]/page.tsx @@ -2,21 +2,21 @@ import { Metadata } from "next"; import { redirect } from "next/navigation"; import { Blog } from "src/blog/Blog"; import BlogPreview from "src/blog/BlogPreview"; -import SalaryAndBenefits from "src/salaryAndBenefits/SalaryAndBenefits"; +import Compensations from "src/compensations/Compensations"; import { getDraftModeInfo } from "src/utils/draftmode"; import SectionRenderer from "src/utils/renderSection"; import { fetchSeoData, generateMetadataFromSeo } from "src/utils/seo"; import { BlogPage, PageBuilder, Post } from "studio/lib/payloads/pages"; -import { SalaryAndBenefitsPage } from "studio/lib/payloads/salaryAndBenefits"; +import { CompensationsPage } from "studio/lib/payloads/compensations"; import { BLOG_PAGE_QUERY, POSTS_QUERY, - SALARY_AND_BENEFITS_PAGE_QUERY, + COMPENSATIONS_PAGE_QUERY, SEO_SLUG_QUERY, SLUG_QUERY, } from "studio/lib/queries/pages"; import { loadQuery } from "studio/lib/store"; -import SalaryAndBenefitsPreview from "src/salaryAndBenefits/SalaryAndBenefitsPreview"; +import CompensationsPreview from "src/compensations/CompensationsPreview"; export const dynamic = "force-dynamic"; @@ -36,12 +36,12 @@ async function Page({ params }: Props) { const { slug } = params; const { perspective, isDraftMode } = getDraftModeInfo(); - const [initialPage, initialBlogPage, initialSalaryAndBenefitsPage] = + const [initialPage, initialBlogPage, initialCompensationsPage] = await Promise.all([ loadQuery(SLUG_QUERY, { slug }, { perspective }), loadQuery(BLOG_PAGE_QUERY, { slug }, { perspective }), - loadQuery( - SALARY_AND_BENEFITS_PAGE_QUERY, + loadQuery( + COMPENSATIONS_PAGE_QUERY, { slug }, { perspective }, ), @@ -50,7 +50,7 @@ async function Page({ params }: Props) { if ( !initialPage.data && !initialBlogPage.data && - !initialSalaryAndBenefitsPage.data + !initialCompensationsPage.data ) { console.log(`Page ${slug} not found`); // TODO: add error snackbar @@ -102,15 +102,11 @@ async function Page({ params }: Props) { ); } - if (initialSalaryAndBenefitsPage.data) { + if (initialCompensationsPage.data) { return isDraftMode ? ( - + ) : ( - + ); } diff --git a/src/salaryAndBenefits/SalaryAndBenefits.tsx b/src/compensations/Compensations.tsx similarity index 81% rename from src/salaryAndBenefits/SalaryAndBenefits.tsx rename to src/compensations/Compensations.tsx index 0beeed23a..3973125dd 100644 --- a/src/salaryAndBenefits/SalaryAndBenefits.tsx +++ b/src/compensations/Compensations.tsx @@ -1,7 +1,7 @@ "use client"; -import styles from "./salaryAndBenefits.module.css"; +import styles from "./compensations.module.css"; import Text from "src/components/text/Text"; -import { SalaryAndBenefitsPage } from "studio/lib/payloads/salaryAndBenefits"; +import { CompensationsPage } from "studio/lib/payloads/compensations"; import { RichText } from "src/components/richText/RichText"; import SalaryCalculator, { Degree, @@ -9,8 +9,8 @@ import SalaryCalculator, { import { useState } from "react"; import { calculatePension, calculateSalary } from "./utils/calculateSalary"; -interface SalaryAndBenefitsProps { - salaryAndBenefits: SalaryAndBenefitsPage; +interface CompensationsProps { + compensations: CompensationsPage; } interface SalaryCalculatorFormState { @@ -18,7 +18,7 @@ interface SalaryCalculatorFormState { selectedDegree: Degree; } -const SalaryAndBenefits = ({ salaryAndBenefits }: SalaryAndBenefitsProps) => { +const Compensations = ({ compensations }: CompensationsProps) => { const currentYear = new Date().getFullYear(); const [formState, setFormState] = useState({ @@ -54,8 +54,8 @@ const SalaryAndBenefits = ({ salaryAndBenefits }: SalaryAndBenefitsProps) => { return (
- {salaryAndBenefits.basicTitle} - {salaryAndBenefits.showSalaryCalculator && ( + {compensations.basicTitle} + {compensations.showSalaryCalculator && ( <> { )}
- {salaryAndBenefits.benefits.map((benefit) => ( + {compensations.benefits.map((benefit) => (
{benefit.basicTitle} @@ -86,4 +86,4 @@ const SalaryAndBenefits = ({ salaryAndBenefits }: SalaryAndBenefitsProps) => { ); }; -export default SalaryAndBenefits; +export default Compensations; diff --git a/src/compensations/CompensationsPreview.tsx b/src/compensations/CompensationsPreview.tsx new file mode 100644 index 000000000..deb2e89a7 --- /dev/null +++ b/src/compensations/CompensationsPreview.tsx @@ -0,0 +1,28 @@ +"use client"; +import { Suspense } from "react"; +import Compensations from "./Compensations"; +import { QueryResponseInitial, useQuery } from "@sanity/react-loader"; +import { CompensationsPage } from "studio/lib/payloads/compensations"; +import { COMPENSATIONS_PAGE_QUERY } from "studio/lib/queries/pages"; + +interface CompensationsPreviewProps { + initialCompensations: QueryResponseInitial; +} + +const CompensationsPreview = ({ + initialCompensations, +}: CompensationsPreviewProps) => { + const { data } = useQuery( + COMPENSATIONS_PAGE_QUERY, + { slug: initialCompensations.data.slug.current }, + { initial: initialCompensations }, + ); + + return ( + + + + ); +}; + +export default CompensationsPreview; diff --git a/src/salaryAndBenefits/salaryAndBenefits.module.css b/src/compensations/compensations.module.css similarity index 100% rename from src/salaryAndBenefits/salaryAndBenefits.module.css rename to src/compensations/compensations.module.css diff --git a/src/salaryAndBenefits/components/salaryCalculator/SalaryCalculator.tsx b/src/compensations/components/salaryCalculator/SalaryCalculator.tsx similarity index 96% rename from src/salaryAndBenefits/components/salaryCalculator/SalaryCalculator.tsx rename to src/compensations/components/salaryCalculator/SalaryCalculator.tsx index b13015c52..1a731e514 100644 --- a/src/salaryAndBenefits/components/salaryCalculator/SalaryCalculator.tsx +++ b/src/compensations/components/salaryCalculator/SalaryCalculator.tsx @@ -5,7 +5,7 @@ import { RadioButtonGroup, } from "src/components/forms/radioButtonGroup/RadioButtonGroup"; import Button from "src/components/buttons/Button"; -import { maxExperience } from "src/salaryAndBenefits/utils/calculateSalary"; +import { maxExperience } from "src/compensations/utils/calculateSalary"; export type Degree = "bachelor" | "master"; diff --git a/src/salaryAndBenefits/components/salaryCalculator/salaryCalculator.module.css b/src/compensations/components/salaryCalculator/salaryCalculator.module.css similarity index 100% rename from src/salaryAndBenefits/components/salaryCalculator/salaryCalculator.module.css rename to src/compensations/components/salaryCalculator/salaryCalculator.module.css diff --git a/src/salaryAndBenefits/utils/calculateSalary.ts b/src/compensations/utils/calculateSalary.ts similarity index 100% rename from src/salaryAndBenefits/utils/calculateSalary.ts rename to src/compensations/utils/calculateSalary.ts diff --git a/src/salaryAndBenefits/utils/salaryData.ts b/src/compensations/utils/salaryData.ts similarity index 100% rename from src/salaryAndBenefits/utils/salaryData.ts rename to src/compensations/utils/salaryData.ts diff --git a/src/salaryAndBenefits/SalaryAndBenefitsPreview.tsx b/src/salaryAndBenefits/SalaryAndBenefitsPreview.tsx deleted file mode 100644 index af89ce5fc..000000000 --- a/src/salaryAndBenefits/SalaryAndBenefitsPreview.tsx +++ /dev/null @@ -1,28 +0,0 @@ -"use client"; -import { Suspense } from "react"; -import SalaryAndBenefits from "./SalaryAndBenefits"; -import { QueryResponseInitial, useQuery } from "@sanity/react-loader"; -import { SalaryAndBenefitsPage } from "studio/lib/payloads/salaryAndBenefits"; -import { SALARY_AND_BENEFITS_PAGE_QUERY } from "studio/lib/queries/pages"; - -interface SalaryAndBenefitsPreviewProps { - initialSalaryAndBenefits: QueryResponseInitial; -} - -const SalaryAndBenefitsPreview = ({ - initialSalaryAndBenefits, -}: SalaryAndBenefitsPreviewProps) => { - const { data } = useQuery( - SALARY_AND_BENEFITS_PAGE_QUERY, - { slug: initialSalaryAndBenefits.data.slug.current }, - { initial: initialSalaryAndBenefits }, - ); - - return ( - - - - ); -}; - -export default SalaryAndBenefitsPreview; diff --git a/studio/lib/payloads/salaryAndBenefits.ts b/studio/lib/payloads/compensations.ts similarity index 91% rename from studio/lib/payloads/salaryAndBenefits.ts rename to studio/lib/payloads/compensations.ts index ff6636c49..468e3733b 100644 --- a/studio/lib/payloads/salaryAndBenefits.ts +++ b/studio/lib/payloads/compensations.ts @@ -8,7 +8,7 @@ export interface Benefit { richText: PortableTextBlock[]; } -export interface SalaryAndBenefitsPage { +export interface CompensationsPage { _createdAt: string; _id: string; _rev: string; diff --git a/studio/lib/queries/pages.ts b/studio/lib/queries/pages.ts index 37d140c10..6350cf0a1 100644 --- a/studio/lib/queries/pages.ts +++ b/studio/lib/queries/pages.ts @@ -87,8 +87,8 @@ export const BLOG_PAGE_QUERY = groq` *[_type == "blog" && slug.current == $slug][0] `; -export const SALARY_AND_BENEFITS_PAGE_QUERY = groq` - *[_type == "salaryAndBenefits" && slug.current == $slug][0] +export const COMPENSATIONS_PAGE_QUERY = groq` + *[_type == "compensations" && slug.current == $slug][0] `; export const POSTS_QUERY = groq` diff --git a/studio/schema.ts b/studio/schema.ts index 17c539428..0891cdcf2 100644 --- a/studio/schema.ts +++ b/studio/schema.ts @@ -12,11 +12,13 @@ import posts from "./schemas/documents/post"; import categories from "./schemas/fields/categories"; import legalDocument from "./schemas/documents/legalDocuments"; import benefit from "./schemas/documents/benefit"; -import salaryAndBenefits from "./schemas/documents/salaryAndBenefits"; import office from "./schemas/documents/office"; +import compensations from "./schemas/documents/compensations"; +import salaryAndBenefits from "./schemas/documents/salaryAndBenefits"; export const schema: { types: SchemaTypeDefinition[] } = { types: [ + office, siteSettings, navigationManager, socialMediaLinks, @@ -29,6 +31,7 @@ export const schema: { types: SchemaTypeDefinition[] } = { posts, categories, legalDocument, + compensations, salaryAndBenefits, benefit, office, diff --git a/studio/schemas/deskStructure.ts b/studio/schemas/deskStructure.ts index 5960f0092..7eae57d4d 100644 --- a/studio/schemas/deskStructure.ts +++ b/studio/schemas/deskStructure.ts @@ -14,7 +14,7 @@ import { soMeLinksID } from "./documents/socialMediaProfiles"; import { siteSettingsID } from "./documents/siteSettings"; import { postId } from "./documents/post"; import { legalDocumentID } from "./documents/legalDocuments"; -import { salaryAndBenefitsId } from "./documents/salaryAndBenefits"; +import { compensationsId } from "./documents/compensations"; export default (S: StructureBuilder) => S.list() @@ -66,15 +66,12 @@ export default (S: StructureBuilder) => .documentId(blogId) .title("Blog Overview & Settings"), ), + S.listItem() + .title("Compensations") + .icon(HeartIcon) + .child( + S.documentTypeList(compensationsId).title("Compensations"), + ), ]), ), - S.listItem() - .title("Salary and Benefits") - .icon(HeartIcon) - .child( - S.document() - .schemaType(salaryAndBenefitsId) - .documentId(salaryAndBenefitsId) - .title("Salary and Benefits"), - ), ]); diff --git a/studio/schemas/documents/compensations.ts b/studio/schemas/documents/compensations.ts new file mode 100644 index 000000000..098b49db4 --- /dev/null +++ b/studio/schemas/documents/compensations.ts @@ -0,0 +1,34 @@ +import { defineField, defineType } from "sanity"; +import { titleSlug } from "../schemaTypes/slug"; +import seo from "../objects/seo"; +import { title } from "../fields/text"; +import { benefitId } from "./benefit"; + +export const compensationsId = "compensations"; + +const compensations = defineType({ + name: compensationsId, + type: "document", + title: "Compensations", + fields: [ + title, + titleSlug, + seo, + defineField({ + name: "showSalaryCalculator", + title: "Show Salary Calculator", + description: "Should the salary calculator be visible on the page?", + type: "boolean", + initialValue: true, + }), + defineField({ + name: "benefits", + title: "Benefits", + description: "Manage benefits for the compensations page", + type: "array", + of: [{ type: benefitId }], + }), + ], +}); + +export default compensations; diff --git a/studio/schemas/documents/salaryAndBenefits.ts b/studio/schemas/documents/salaryAndBenefits.ts index 6268463af..afda357e8 100644 --- a/studio/schemas/documents/salaryAndBenefits.ts +++ b/studio/schemas/documents/salaryAndBenefits.ts @@ -1,15 +1,19 @@ import { defineField, defineType } from "sanity"; +import { title } from "../fields/text"; import { titleSlug } from "../schemaTypes/slug"; import seo from "../objects/seo"; -import { title } from "../fields/text"; import { benefitId } from "./benefit"; -export const salaryAndBenefitsId = "salaryAndBenefits"; +// TODO: deprecated, drop support once important deployments have updated const salaryAndBenefits = defineType({ - name: salaryAndBenefitsId, - type: "document", + name: "salaryAndBenefits", title: "Salary and Benefits", + type: "document", + deprecated: { + reason: "Use the Compensations document type instead", + }, + readOnly: true, fields: [ title, titleSlug, diff --git a/studio/schemas/objects/link.ts b/studio/schemas/objects/link.ts index d18095797..3ed110cd0 100644 --- a/studio/schemas/objects/link.ts +++ b/studio/schemas/objects/link.ts @@ -22,7 +22,7 @@ interface Parent { // Lazy reference to avoid circular dependency const lazyPageBuilderID = () => "pageBuilder"; const lazyBlogID = () => "blog"; -const lazySalaryAndBenefitsID = () => "salaryAndBenefits"; +const lazyCompensationsID = () => "compensations"; export const link = defineField({ name: linkID, @@ -61,7 +61,7 @@ export const link = defineField({ to: [ { type: lazyPageBuilderID() }, { type: lazyBlogID() }, - { type: lazySalaryAndBenefitsID() }, + { type: lazyCompensationsID() }, ], validation: (Rule: any) => Rule.custom((value: any, context: any) => { From 9825d7c4df046a1c7771a1cadfad4c509f074228 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust <24361490+mathiazom@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:00:42 +0200 Subject: [PATCH 04/29] v3 - rename Site Settings to Company Info (#550) * feat(studio): rename Site Settings to Company Info * feat(companyInfo): deprecate and hide analytics and tracking field * chore(siteSettings): remove deprecated field and add TODO notice * docs(companyInfo): add deprecation TODO to analytics field * feat: "Company Info" -> "Company Information" * feat(companyInfo): more descriptive description --- README.md | 10 +- src/app/(main)/layout.tsx | 20 +-- src/app/layout.tsx | 6 +- .../navigation/footer/Footer.stories.tsx | 4 +- src/components/navigation/footer/Footer.tsx | 10 +- .../navigation/footer/FooterPreview.tsx | 17 +-- src/components/navigation/header/Header.tsx | 2 +- .../navigation/header/HeaderPreview.tsx | 18 +-- src/components/navigation/mockData.ts | 4 +- src/utils/seo.ts | 14 +- .../{siteSettings.ts => companyInfo.ts} | 2 +- .../{siteSettings.ts => companyInfo.ts} | 2 +- studio/schema.ts | 5 +- studio/schemas/deskStructure.ts | 13 +- studio/schemas/documents/companyInfo.ts | 134 ++++++++++++++++++ studio/schemas/documents/siteSettings.ts | 3 +- 16 files changed, 199 insertions(+), 65 deletions(-) rename studio/lib/payloads/{siteSettings.ts => companyInfo.ts} (89%) rename studio/lib/queries/{siteSettings.ts => companyInfo.ts} (58%) create mode 100644 studio/schemas/documents/companyInfo.ts diff --git a/README.md b/README.md index 0eb8ec4ef..24b723a40 100644 --- a/README.md +++ b/README.md @@ -101,16 +101,16 @@ This project includes a customized Sanity Studio desk structure to enhance conte ## Managing Content -### Site Settings +### Company Information -The `Site Settings` menu allows you to configure global settings for your site, including brand assets, tracking codes, and default SEO settings. +The `Company Information` menu allows you to configure global settings for your site, including brand assets, tracking codes, and default SEO settings. -#### Social Media Profiles +### Social Media Profiles - **Adding Social Media Links**: Editors can manage social media links under the `Social Media Profiles` menu. This allows visitors to connect with the website on various social platforms. - **Supported Platforms**: The 9 supported platforms include Facebook, Instagram, and LinkedIn, but more can be added to `SoMePlatforms` if needed. -#### Navigation Management +### Navigation Management - **Setting the Landing Page**: The `Navigation Manager` allows editors to set the landing page for the site, which is crucial for determining the primary page visitors see upon arrival. - **Adding Menu Items**: Within the `Navigation Manager`, editors can add items to various pre-defined menus: @@ -118,7 +118,7 @@ The `Site Settings` menu allows you to configure global settings for your site, - **Footer Menu**: Add items to the footer menu, which consists of different sections. Each section can contain either social media links, custom links, text, or images (e.g., logos). - **Sidebar Menu**: Add links to the sidebar menu, which will appear on smaller screens to aid mobile navigation. -#### Pages +### Pages - **Creating Pages**: Content editors can create and manage pages under the `Pages` menu in the Sanity Studio. - **Adding Sections**: Each page can be customized with structured content that includes various predefined sections such as hero, article, testimonials, features, callToAction, grid, and callout. diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx index b78143f17..4affe6efd 100644 --- a/src/app/(main)/layout.tsx +++ b/src/app/(main)/layout.tsx @@ -1,9 +1,9 @@ import Footer from "src/components/navigation/footer/Footer"; import { NAV_QUERY } from "studio/lib/queries/navigation"; -import { SITESETTINGS_QUERY } from "studio/lib/queries/siteSettings"; +import { COMPANY_INFO_QUERY } from "studio/lib/queries/companyInfo"; import { Header } from "src/components/navigation/header/Header"; import { Navigation } from "studio/lib/payloads/navigation"; -import { SiteSettings } from "studio/lib/payloads/siteSettings"; +import { CompanyInfo } from "studio/lib/payloads/companyInfo"; import { loadQuery } from "studio/lib/store"; import HeaderPreview from "src/components/navigation/header/HeaderPreview"; import FooterPreview from "src/components/navigation/footer/FooterPreview"; @@ -24,22 +24,22 @@ export default async function Layout({ }>) { const { perspective, isDraftMode } = getDraftModeInfo(); - const [initialNav, initialSiteSettings, initialSoMe, initialLegal] = + const [initialNav, initialCompanyInfo, initialSoMe, initialLegal] = await Promise.all([ loadQuery(NAV_QUERY, {}, { perspective }), - loadQuery(SITESETTINGS_QUERY, {}, { perspective }), + loadQuery(COMPANY_INFO_QUERY, {}, { perspective }), loadQuery(SOMEPROFILES_QUERY, {}, { perspective }), loadQuery(LEGAL_DOCUMENTS_QUERY, {}, { perspective }), ]); const hasNavData = hasValidData(initialNav.data); - const hasSiteSettingsData = hasValidData(initialSiteSettings.data); + const hasCompanyInfoData = hasValidData(initialCompanyInfo.data); const hasHeaderData = hasNavData && (initialNav.data.main || initialNav.data.sidebar); const hasFooterData = hasNavData && initialNav.data.footer; - const hasMenuData = hasSiteSettingsData && (hasHeaderData || hasFooterData); + const hasMenuData = hasCompanyInfoData && (hasHeaderData || hasFooterData); if (!hasMenuData) { return ( @@ -55,12 +55,12 @@ export default async function Layout({ {hasHeaderData && isDraftMode ? ( ) : (
)}
@@ -69,14 +69,14 @@ export default async function Layout({ {hasFooterData && isDraftMode ? ( ) : (