Skip to content

Commit

Permalink
add richtextfield to customer case type
Browse files Browse the repository at this point in the history
  • Loading branch information
anemne committed Sep 19, 2024
1 parent b7f1032 commit 3f5fb55
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 27 deletions.
8 changes: 6 additions & 2 deletions src/app/(main)/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ async function Page({ params }: Props) {
{ slug },
{ perspective },
),
loadStudioQuery<CompanyLocation[]>(COMPANY_LOCATIONS_QUERY, {}, { perspective }),
loadStudioQuery<CompanyLocation[]>(
COMPANY_LOCATIONS_QUERY,
{},
{ perspective },
),
loadStudioQuery<CustomerCasePage>(
CUSTOMER_CASES_PAGE_QUERY,
{ slug },
{ perspective },
),
loadSharedQuery<CustomerCase>(CUSTOMER_CASES_QUERY, {}, { perspective }),
loadSharedQuery<CustomerCase[]>(CUSTOMER_CASES_QUERY, {}, { perspective }),
]);

if (initialPage.data) {
Expand Down
12 changes: 10 additions & 2 deletions src/app/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@ export default async function Layout({
] = await Promise.all([
loadStudioQuery<Navigation>(NAV_QUERY, {}, { perspective }),
loadStudioQuery<CompanyInfo>(COMPANY_INFO_QUERY, {}, { perspective }),
loadStudioQuery<SocialMediaProfiles>(SOMEPROFILES_QUERY, {}, { perspective }),
loadStudioQuery<LegalDocument[]>(LEGAL_DOCUMENTS_QUERY, {}, { perspective }),
loadStudioQuery<SocialMediaProfiles>(
SOMEPROFILES_QUERY,
{},
{ perspective },
),
loadStudioQuery<LegalDocument[]>(
LEGAL_DOCUMENTS_QUERY,
{},
{ perspective },
),
loadStudioQuery<BrandAssets>(BRAND_ASSETS_QUERY, {}, { perspective }),
]);

Expand Down
12 changes: 10 additions & 2 deletions src/customerCases/CustomerCases.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Text from "src/components/text/Text";
import { CustomerCasePage } from "studio/lib/interfaces/specialPages";
import { CustomerCase } from "studioShared/lib/interfaces/customerCases";

import { RichText } from "src/components/richText/RichText";
import styles from "./customerCases.module.css";

interface CustomerCasesProps {
customerCases: CustomerCasePage;
sharedCustomerCases: CustomerCase;
sharedCustomerCases: CustomerCase[];
}

const CustomerCases = async ({
Expand All @@ -16,6 +16,14 @@ const CustomerCases = async ({
return (
<div className={styles.wrapper}>
<Text type="h1"> {customerCases.basicTitle} </Text>
{sharedCustomerCases.map((customerCase: CustomerCase) => (
<div>
<Text key={customerCase._id} type="h2">
{customerCase.basicTitle}
</Text>
{customerCase.richText && <RichText value={customerCase.richText} />}
</div>
))}
</div>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/customerCases/CustomerCasesPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CustomerCases from "./CustomerCases";

interface CustomerCasesPreviewProps {
initialCustomerCases: QueryResponseInitial<CustomerCasePage>;
initialSharedCustomerCases: QueryResponseInitial<CustomerCase>;
initialSharedCustomerCases: QueryResponseInitial<CustomerCase[]>;
}

const CustomerCasesPreview = ({
Expand All @@ -23,7 +23,7 @@ const CustomerCasesPreview = ({
{ initial: initialCustomerCases },
);

const { data: sharedCustomerCases } = useQuery<CustomerCase>(
const { data: sharedCustomerCases } = useQuery<CustomerCase[]>(
CUSTOMER_CASES_QUERY,
{},
{ initial: initialSharedCustomerCases },
Expand Down
11 changes: 5 additions & 6 deletions src/customerCases/customerCases.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.wrapper {
display: flex;
flex-direction: column;
padding: 10rem 5rem;
gap: 5rem;
}

display: flex;
flex-direction: column;
padding: 10rem 5rem;
gap: 5rem;
}
14 changes: 7 additions & 7 deletions studio/lib/store.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {createQueryStore} from "@sanity/react-loader";
import { createQueryStore } from "@sanity/react-loader";

import { client } from "./client";
import { token } from "./token";

const {
loadQuery: loadStudioQuery,
setServerClient,
} = createQueryStore({client: false, ssr: true})
const { loadQuery: loadStudioQuery, setServerClient } = createQueryStore({
client: false,
ssr: true,
});

setServerClient(client.withConfig({ token }));
setServerClient(client.withConfig({ token }));

export { loadStudioQuery }
export { loadStudioQuery };
2 changes: 2 additions & 0 deletions studioShared/lib/interfaces/customerCases.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PortableTextBlock } from "src/components/richText/RichText";
import { Slug } from "./global";

export interface CustomerCase {
Expand All @@ -9,4 +10,5 @@ export interface CustomerCase {
_createdAt: string;
_rev: string;
_type: string;
richText: PortableTextBlock[];
}
12 changes: 6 additions & 6 deletions studioShared/lib/store.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {createQueryStore} from "@sanity/react-loader";
import { createQueryStore } from "@sanity/react-loader";

import { sharedClient } from "./client";
import { token } from "./token";

const {
loadQuery: loadSharedQuery,
setServerClient,
} = createQueryStore({client: false, ssr: true})
const { loadQuery: loadSharedQuery, setServerClient } = createQueryStore({
client: false,
ssr: true,
});

setServerClient(sharedClient.withConfig({ token }));

export { loadSharedQuery };
export { loadSharedQuery };

0 comments on commit 3f5fb55

Please sign in to comment.