diff --git a/client/sanity/schema.ts b/client/sanity/schema.ts index 3773d5d3e..0f37f894a 100644 --- a/client/sanity/schema.ts +++ b/client/sanity/schema.ts @@ -5,6 +5,7 @@ import { LodgeInfoSchema } from "@/models/sanity/LodgeInfo/Schema" import { type SchemaTypeDefinition } from "sanity" import { CommitteeMemberSchema } from "@/models/sanity/CommitteeMembers/Schema" import { LifeMemberSchema } from "@/models/sanity/LifeMembers/Schema" +import { PoliciesSchema } from "@/models/sanity/Policies/Schema" export const schema: { types: SchemaTypeDefinition[] } = { types: [ @@ -12,6 +13,7 @@ export const schema: { types: SchemaTypeDefinition[] } = { HomePageSchema, ContactDetailSchema, LodgeInfoSchema, + PoliciesSchema, CommitteeMemberSchema, LifeMemberSchema ] diff --git a/client/src/app/bookings/BookingPolicyStorage.tsx b/client/src/app/bookings/BookingPolicyStorage.tsx new file mode 100644 index 000000000..2d671317c --- /dev/null +++ b/client/src/app/bookings/BookingPolicyStorage.tsx @@ -0,0 +1,22 @@ +"use client" + +import { + BookingContext, + PolicyWithTextBlocks +} from "@/components/composite/Booking/BookingContext" +import { useContext, useEffect } from "react" + +const BookingPolicyStorage = ({ + policies +}: { + policies: PolicyWithTextBlocks[] +}) => { + const { setPolicies } = useContext(BookingContext) + useEffect(() => { + setPolicies?.(policies) + }, [policies, setPolicies]) + + return null +} + +export default BookingPolicyStorage diff --git a/client/src/app/bookings/layout.tsx b/client/src/app/bookings/layout.tsx index 3e5f95bf1..1b0cc2dce 100644 --- a/client/src/app/bookings/layout.tsx +++ b/client/src/app/bookings/layout.tsx @@ -11,10 +11,13 @@ import { Footer } from "@/components/generic/Footer/Footer" import { QueryClientProvider } from "@tanstack/react-query" import queryClient from "@/services/QueryClient" -type IBookingLayout = Readonly<{ children: ReactNode }> +type IBookingLayout = Readonly<{ + children: ReactNode + // policyInfoProps: ReactNode +}> const InnerBookingLayout = ({ children }: IBookingLayout) => { - const { getExistingSession } = useContext(BookingContext) + const { getExistingSession, policies } = useContext(BookingContext) const getExistingSessionCallback = useCallback(() => { getExistingSession?.() @@ -22,6 +25,14 @@ const InnerBookingLayout = ({ children }: IBookingLayout) => { useUserLoggedInCallback(getExistingSessionCallback) + const PoliciesContent = policies + ? policies.slice(0, 3).map((policy) => ({ + order: policy.order || 0, // Ensure order is a number + title: policy.title || "Untitled", // Ensure title is a string + information: policy.information || [] // Make sure information is an array of PortableTextBlocks + })) + : [] + return ( <>
{
- +