diff --git a/src/app/(main)/[slug]/page.tsx b/src/app/(main)/[slug]/page.tsx index 0e9deffa3..cf9988578 100644 --- a/src/app/(main)/[slug]/page.tsx +++ b/src/app/(main)/[slug]/page.tsx @@ -2,12 +2,12 @@ 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 SalaryAndBenefits from "src/salaryAndBenefits/SalaryAndBenefits"; 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 { SalaryAndBenefits as SalaryAndBenefitsPayload } from 'studio/lib/payloads/salaryAndBenefits'; +import { SalaryAndBenefitsPage } from "studio/lib/payloads/salaryAndBenefits"; import { BLOG_PAGE_QUERY, POSTS_QUERY, @@ -36,13 +36,22 @@ async function Page({ params }: Props) { const { slug } = params; const { perspective, isDraftMode } = getDraftModeInfo(); - const [initialPage, initialBlogPage, initialSalaryAndBenefitsPage] = await Promise.all([ - loadQuery(SLUG_QUERY, { slug }, { perspective }), - loadQuery(BLOG_PAGE_QUERY, { slug }, { perspective }), - loadQuery(SALARY_AND_BENEFITS_PAGE_QUERY, { slug }, { perspective }), - ]); + const [initialPage, initialBlogPage, initialSalaryAndBenefitsPage] = + await Promise.all([ + loadQuery(SLUG_QUERY, { slug }, { perspective }), + loadQuery(BLOG_PAGE_QUERY, { slug }, { perspective }), + loadQuery( + SALARY_AND_BENEFITS_PAGE_QUERY, + { slug }, + { perspective }, + ), + ]); - if (!initialPage.data && !initialBlogPage.data && !initialSalaryAndBenefitsPage.data) { + if ( + !initialPage.data && + !initialBlogPage.data && + !initialSalaryAndBenefitsPage.data + ) { console.log(`Page ${slug} not found`); // TODO: add error snackbar redirect("/"); @@ -53,7 +62,7 @@ async function Page({ params }: Props) { const initialPosts = await loadQuery( POSTS_QUERY, { slug }, - { perspective } + { perspective }, ); if (!initialPosts) { @@ -95,9 +104,13 @@ async function Page({ params }: Props) { if (initialSalaryAndBenefitsPage.data) { return isDraftMode ? ( - + ) : ( - + ); } diff --git a/src/salaryAndBenefits/SalaryAndBenefits.tsx b/src/salaryAndBenefits/SalaryAndBenefits.tsx index a462e8086..5a1e6fad1 100644 --- a/src/salaryAndBenefits/SalaryAndBenefits.tsx +++ b/src/salaryAndBenefits/SalaryAndBenefits.tsx @@ -1,23 +1,26 @@ import styles from "./salaryAndBenefits.module.css"; import Text from "src/components/text/Text"; -import {SalaryAndBenefits as SalaryAndBenefitsPayload} from "studio/lib/payloads/salaryAndBenefits"; -import Benefit from './components/benefit/Benefit'; +import { SalaryAndBenefitsPage } from "studio/lib/payloads/salaryAndBenefits"; +import { RichText } from "src/components/richText/RichText"; interface SalaryAndBenefitsProps { - salaryAndBenefits: SalaryAndBenefitsPayload + salaryAndBenefits: SalaryAndBenefitsPage; } -const SalaryAndBenefits = ({salaryAndBenefits}: SalaryAndBenefitsProps) => { +const SalaryAndBenefits = ({ salaryAndBenefits }: SalaryAndBenefitsProps) => { return (
{salaryAndBenefits.basicTitle}
{salaryAndBenefits.benefits.map((benefit) => ( - +
+ {benefit.basicTitle} + +
))}
- ) -} + ); +}; -export default SalaryAndBenefits; \ No newline at end of file +export default SalaryAndBenefits; diff --git a/src/salaryAndBenefits/SalaryAndBenefitsPreview.tsx b/src/salaryAndBenefits/SalaryAndBenefitsPreview.tsx index 3994dc4d4..246d209fa 100644 --- a/src/salaryAndBenefits/SalaryAndBenefitsPreview.tsx +++ b/src/salaryAndBenefits/SalaryAndBenefitsPreview.tsx @@ -2,17 +2,17 @@ import { Suspense } from "react"; import SalaryAndBenefits from "./SalaryAndBenefits"; import { QueryResponseInitial, useQuery } from "@sanity/react-loader"; -import { SalaryAndBenefits as SalaryAndBenefitsPayload } from "studio/lib/payloads/salaryAndBenefits"; +import { SalaryAndBenefitsPage } from "studio/lib/payloads/salaryAndBenefits"; import { SALARY_AND_BENEFITS_PAGE_QUERY } from "studio/lib/queries/pages"; interface SalaryAndBenefitsPreviewProps { - initialSalaryAndBenefits: QueryResponseInitial; + initialSalaryAndBenefits: QueryResponseInitial; } const SalaryAndBenefitsPreview = ({ initialSalaryAndBenefits, }: SalaryAndBenefitsPreviewProps) => { - const { data: newData } = useQuery( + const { data: newData } = useQuery( SALARY_AND_BENEFITS_PAGE_QUERY, { slug: initialSalaryAndBenefits.data.slug.current }, { initial: initialSalaryAndBenefits }, diff --git a/src/salaryAndBenefits/components/benefit/Benefit.tsx b/src/salaryAndBenefits/components/benefit/Benefit.tsx deleted file mode 100644 index ca31af62f..000000000 --- a/src/salaryAndBenefits/components/benefit/Benefit.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import Text from "src/components/text/Text"; -import { RichText } from '../../../components/richText/RichText'; -import {Benefit as BenefitPayload} from 'studio/lib/payloads/salaryAndBenefits'; -import styles from "./benefit.module.css"; - - -interface BenefitProps { - benefit: BenefitPayload; -} - -export default function Benefit({benefit}: BenefitProps) { - return ( -
- {benefit.basicTitle} - -
- ) -} \ No newline at end of file diff --git a/src/salaryAndBenefits/components/benefit/benefit.module.css b/src/salaryAndBenefits/components/benefit/benefit.module.css deleted file mode 100644 index e6df59537..000000000 --- a/src/salaryAndBenefits/components/benefit/benefit.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: flex; - flex-direction: column; - gap: 1rem; -} \ No newline at end of file diff --git a/src/salaryAndBenefits/salaryAndBenefits.module.css b/src/salaryAndBenefits/salaryAndBenefits.module.css index e07e765c4..c53fdbc23 100644 --- a/src/salaryAndBenefits/salaryAndBenefits.module.css +++ b/src/salaryAndBenefits/salaryAndBenefits.module.css @@ -10,4 +10,10 @@ flex-direction: column; gap: 5rem; max-width: var(--max-content-width-medium); +} + +.benefitWrapper { + display: flex; + flex-direction: column; + gap: 1rem; } \ No newline at end of file diff --git a/studio/lib/payloads/salaryAndBenefits.ts b/studio/lib/payloads/salaryAndBenefits.ts index f80dfb46d..cc847e3cc 100644 --- a/studio/lib/payloads/salaryAndBenefits.ts +++ b/studio/lib/payloads/salaryAndBenefits.ts @@ -1,5 +1,5 @@ -import { PortableTextBlock } from 'src/components/richText/RichText'; -import { Slug } from './global'; +import { PortableTextBlock } from "src/components/richText/RichText"; +import { Slug } from "./global"; export interface Benefit { _type: string; @@ -8,8 +8,7 @@ export interface Benefit { richText: PortableTextBlock[]; } - -export interface SalaryAndBenefits { +export interface SalaryAndBenefitsPage { _createdAt: string; _id: string; _rev: string; @@ -19,4 +18,4 @@ export interface SalaryAndBenefits { page: string; slug: Slug; benefits: Benefit[]; -} \ No newline at end of file +}