fix getSlots filters
This commit is contained in:
parent
2fd279a055
commit
75246fbfa9
@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
import { addSlot, deleteSlot, getSlot, getSlots, updateSlot } from '@/actions/slots';
|
||||
import { ScheduleSlotsContext } from '@/context/schedule-slots';
|
||||
import { combineDateTime } from '@/utils/date';
|
||||
// eslint-disable-next-line sonarjs/no-internal-api-use
|
||||
import type * as ApolloTypes from '@repo/graphql/node_modules/@apollo/client/core';
|
||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
@ -11,9 +12,19 @@ type FixTypescriptCringe = ApolloTypes.FetchResult;
|
||||
|
||||
export const useSlots = () => {
|
||||
const { selectedDate } = use(ScheduleSlotsContext);
|
||||
const dayStart = combineDateTime(selectedDate, '00:00');
|
||||
const dayEnd = combineDateTime(selectedDate, '23:59');
|
||||
|
||||
return useQuery({
|
||||
queryFn: () => getSlots({ filters: { datestart: { gte: selectedDate } } }),
|
||||
queryFn: () =>
|
||||
getSlots({
|
||||
filters: {
|
||||
datestart: {
|
||||
gte: dayStart,
|
||||
lte: dayEnd,
|
||||
},
|
||||
},
|
||||
}),
|
||||
queryKey: ['schedule', 'slots', 'list', selectedDate],
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user