@@ -3,73 +3,65 @@ import { type LoaderFunctionArgs, json } from "@shopify/remix-oxygen";
33import invariant from "tiny-invariant" ;
44import { routeHeaders } from "~/data/cache" ;
55import { seoPayload } from "~/lib/seo.server" ;
6- import { PageHeader , Section } from "~/modules/text" ;
7- import { Button } from "~/modules/button" ;
6+ import type { PoliciesHandleQuery } from "storefrontapi.generated" ;
7+ import { Section } from "~/components/section" ;
8+ import { BreadCrumb } from "~/components/breadcrumb" ;
9+ import Link from "~/components/link" ;
810
9- export const headers = routeHeaders ;
11+ export let headers = routeHeaders ;
1012
1113export async function loader ( { request, params, context } : LoaderFunctionArgs ) {
1214 invariant ( params . policyHandle , "Missing policy handle" ) ;
1315
14- const policyName = params . policyHandle . replace (
16+ let policyName = params . policyHandle . replace (
1517 / - ( [ a - z ] ) / g,
1618 ( _ : unknown , m1 : string ) => m1 . toUpperCase ( ) ,
1719 ) as "privacyPolicy" | "shippingPolicy" | "termsOfService" | "refundPolicy" ;
1820
19- const data = await context . storefront . query ( POLICY_CONTENT_QUERY , {
20- variables : {
21- privacyPolicy : false ,
22- shippingPolicy : false ,
23- termsOfService : false ,
24- refundPolicy : false ,
25- [ policyName ] : true ,
26- language : context . storefront . i18n . language ,
21+ let data = await context . storefront . query < PoliciesHandleQuery > (
22+ POLICY_CONTENT_QUERY ,
23+ {
24+ variables : {
25+ privacyPolicy : false ,
26+ shippingPolicy : false ,
27+ termsOfService : false ,
28+ refundPolicy : false ,
29+ [ policyName ] : true ,
30+ language : context . storefront . i18n . language ,
31+ } ,
2732 } ,
28- } ) ;
33+ ) ;
2934
3035 invariant ( data , "No data returned from Shopify API" ) ;
31- const policy = data . shop ?. [ policyName ] ;
36+ let policy = data . shop ?. [ policyName ] ;
3237
3338 if ( ! policy ) {
3439 throw new Response ( null , { status : 404 } ) ;
3540 }
3641
37- const seo = seoPayload . policy ( { policy, url : request . url } ) ;
42+ let seo = seoPayload . policy ( { policy, url : request . url } ) ;
3843
3944 return json ( { policy, seo } ) ;
4045}
4146
4247export default function Policies ( ) {
43- const { policy } = useLoaderData < typeof loader > ( ) ;
48+ let { policy } = useLoaderData < typeof loader > ( ) ;
4449
4550 return (
46- < >
47- < Section
48- padding = "all"
49- display = "flex"
50- className = "flex-col items-baseline w-full gap-8 md:flex-row"
51- >
52- < PageHeader
53- heading = { policy . title }
54- className = "grid items-start flex-grow gap-4 md:sticky top-36 md:w-5/12"
55- >
56- < Button
57- className = "justify-self-start"
58- variant = "inline"
59- to = { "/policies" }
60- >
61- ← Back to Policies
62- </ Button >
63- </ PageHeader >
64- < div className = "flex-grow w-full md:w-7/12" >
65- < div
66- suppressHydrationWarning
67- dangerouslySetInnerHTML = { { __html : policy . body } }
68- className = "prose dark:prose-invert"
69- />
70- </ div >
71- </ Section >
72- </ >
51+ < Section verticalPadding = "medium" width = "fixed" >
52+ < BreadCrumb page = "Policies" className = "mb-4" />
53+ < h4 className = "mb-4 font-medium" > Policies</ h4 >
54+ < Link variant = "underline" to = "/policies" className = "text-body-subtle" >
55+ ← Back to Policies
56+ </ Link >
57+ < div className = "mt-8 lg:mt-20" >
58+ < div
59+ suppressHydrationWarning
60+ dangerouslySetInnerHTML = { { __html : policy . body } }
61+ className = "prose"
62+ />
63+ </ div >
64+ </ Section >
7365 ) ;
7466}
7567
0 commit comments