-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* created document for customer cases * add basic structure for customer cases component in web * retrieve data from sanity studio and add styling module * current work with retrieving data from shared * updated loadquery to create new for each studio to be able to fetch data correctly * add richtextfield to customer case type * fix linting issue * Update studio/schemas/documents/specialPages/customerCases.ts Co-authored-by: Mathias Oterhals Myklebust <[email protected]> * change to import slug from sanity * update variablename for customer case * updated customercases to customercasespage * added customer cases id to internal pages in link.ts * change the initial letter to lower case in customercase id * added ui if zero customer cases * Update src/customerCases/CustomerCases.tsx Co-authored-by: Mathias Oterhals Myklebust <[email protected]> --------- Co-authored-by: Mathias Oterhals Myklebust <[email protected]>
- Loading branch information
Showing
21 changed files
with
259 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { sharedCustomerCasesLink } from "src/blog/components/utils/linkTypes"; | ||
import LinkButton from "src/components/linkButton/LinkButton"; | ||
import { RichText } from "src/components/richText/RichText"; | ||
import Text from "src/components/text/Text"; | ||
import { getDraftModeInfo } from "src/utils/draftmode"; | ||
import { CustomerCasePage } from "studio/lib/interfaces/specialPages"; | ||
import { CustomerCase } from "studioShared/lib/interfaces/customerCases"; | ||
import { CUSTOMER_CASES_QUERY } from "studioShared/lib/queries/customerCases"; | ||
import { loadSharedQuery } from "studioShared/lib/store"; | ||
|
||
import styles from "./customerCases.module.css"; | ||
|
||
interface CustomerCasesProps { | ||
customerCasesPage: CustomerCasePage; | ||
} | ||
|
||
const CustomerCases = async ({ customerCasesPage }: CustomerCasesProps) => { | ||
const { perspective } = getDraftModeInfo(); | ||
|
||
const [sharedCustomerCases] = await Promise.all([ | ||
loadSharedQuery<CustomerCase[]>(CUSTOMER_CASES_QUERY, {}, { perspective }), | ||
]); | ||
|
||
return ( | ||
<div className={styles.wrapper}> | ||
<Text type="h1"> {customerCasesPage.basicTitle} </Text> | ||
{sharedCustomerCases && sharedCustomerCases.data.length > 0 ? ( | ||
sharedCustomerCases.data.map((customerCase: CustomerCase) => ( | ||
<div key={customerCase._id}> | ||
<Text type="h2">{customerCase.basicTitle}</Text> | ||
{customerCase.richText && ( | ||
<RichText value={customerCase.richText} /> | ||
)} | ||
</div> | ||
)) | ||
) : ( | ||
<div className={styles.section}> | ||
<Text> | ||
It looks like you haven't created any customer cases yet. | ||
Please visit the shared studio to add some. | ||
</Text> | ||
<LinkButton link={sharedCustomerCasesLink} /> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default CustomerCases; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { QueryResponseInitial, useQuery } from "@sanity/react-loader"; | ||
import { Suspense } from "react"; | ||
|
||
import { CustomerCasePage } from "studio/lib/interfaces/specialPages"; | ||
import { CUSTOMER_CASES_PAGE_QUERY } from "studio/lib/queries/specialPages"; | ||
|
||
import CustomerCases from "./CustomerCases"; | ||
|
||
interface CustomerCasesPreviewProps { | ||
initialCustomerCases: QueryResponseInitial<CustomerCasePage>; | ||
} | ||
|
||
const CustomerCasesPreview = ({ | ||
initialCustomerCases, | ||
}: CustomerCasesPreviewProps) => { | ||
const { data: customerCases } = useQuery<CustomerCasePage>( | ||
CUSTOMER_CASES_PAGE_QUERY, | ||
{ slug: initialCustomerCases.data.slug.current }, | ||
{ initial: initialCustomerCases }, | ||
); | ||
|
||
return ( | ||
customerCases && ( | ||
<Suspense> | ||
<CustomerCases customerCasesPage={customerCases} /> | ||
</Suspense> | ||
) | ||
); | ||
}; | ||
|
||
export default CustomerCasesPreview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 10rem 5rem; | ||
gap: 5rem; | ||
} | ||
|
||
.section { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Slug } from "./global"; | ||
|
||
export interface CustomerCasePage { | ||
_createdAt: string; | ||
_id: string; | ||
_rev: string; | ||
_type: string; | ||
_updatedAt: string; | ||
basicTitle: string; | ||
page: string; | ||
slug: Slug; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { groq } from "next-sanity"; | ||
|
||
export const CUSTOMER_CASES_PAGE_QUERY = groq` | ||
*[_type == "customerCases" && slug.current == $slug][0]`; | ||
|
||
export const COMPENSATIONS_PAGE_QUERY = groq` | ||
*[_type == "compensations" && slug.current == $slug][0] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import * as queryStore from "@sanity/react-loader"; | ||
import { createQueryStore } from "@sanity/react-loader"; | ||
|
||
import { client } from "./client"; | ||
import { token } from "./token"; | ||
|
||
queryStore.setServerClient(client.withConfig({ token })); | ||
const { loadQuery: loadStudioQuery, setServerClient } = createQueryStore({ | ||
client: false, | ||
ssr: true, | ||
}); | ||
|
||
export const { loadQuery } = queryStore; | ||
setServerClient(client.withConfig({ token })); | ||
|
||
export { loadStudioQuery }; |
Oops, something went wrong.