From cfc51a9e0cfb9375671455dcca4d6e99738f5ccc Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 5 Feb 2025 13:08:57 +0300 Subject: [PATCH] filter by selected day --- apps/web/actions/slots.ts | 2 +- apps/web/context/schedule-slots.tsx | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/web/actions/slots.ts b/apps/web/actions/slots.ts index 572c1e7..047c5da 100644 --- a/apps/web/actions/slots.ts +++ b/apps/web/actions/slots.ts @@ -23,13 +23,13 @@ export async function getSlots(input: GQL.GetSlotsQueryVariables) { return api.getSlots({ filters: { + ...input.filters, master: { documentId: { eq: customer.documentId, }, }, }, - ...input.filters, }); } diff --git a/apps/web/context/schedule-slots.tsx b/apps/web/context/schedule-slots.tsx index 098e060..bfefdae 100644 --- a/apps/web/context/schedule-slots.tsx +++ b/apps/web/context/schedule-slots.tsx @@ -14,8 +14,15 @@ export const ScheduleSlotsContext = createContext({} as ContextType export function ScheduleSlotsProvider({ children }: { readonly children: React.ReactNode }) { const [selectedDate, setSelectedDate] = useState(new Date()); const { data: slots = [] } = useQuery({ - queryFn: () => getSlots({}), - queryKey: ['schedule', 'slots'], + queryFn: () => + getSlots({ + filters: { + datestart: { + gte: selectedDate, + }, + }, + }), + queryKey: ['schedule', 'slots', selectedDate], }); const value = useMemo(() => ({ selectedDate, setSelectedDate, slots }), [selectedDate, slots]);