diff --git a/apps/web/components/schedule/calendar.tsx b/apps/web/components/schedule/calendar.tsx index 76945f3..c58b603 100644 --- a/apps/web/components/schedule/calendar.tsx +++ b/apps/web/components/schedule/calendar.tsx @@ -35,9 +35,9 @@ export function ScheduleCalendar() { return ( { - return dayjs().isAfter(dayjs(date), 'day'); - }} + // disabled={(date) => { + // return dayjs().isAfter(dayjs(date), 'day'); + // }} mode="single" modifiers={{ hasEvent: (date) => { diff --git a/apps/web/components/schedule/day-slots-list/index.tsx b/apps/web/components/schedule/day-slots-list/index.tsx index 3f9b472..ad94952 100644 --- a/apps/web/components/schedule/day-slots-list/index.tsx +++ b/apps/web/components/schedule/day-slots-list/index.tsx @@ -2,16 +2,19 @@ import { DaySlotAddForm } from './day-slot-add-form'; import { SlotCard } from './slot-card'; +import { DataNotFound } from '@/components/shared/alert'; import { useCustomerQuery } from '@/hooks/api/customers'; import { useMasterSlotsQuery } from '@/hooks/api/slots'; import { useDateTimeStore } from '@/stores/datetime'; import { LoadingSpinner } from '@repo/ui/components/ui/spinner'; import { getDateUTCRange } from '@repo/utils/datetime-format'; +import dayjs from 'dayjs'; +import { type PropsWithChildren } from 'react'; export function DaySlotsList() { const { data: { customer } = {} } = useCustomerQuery(); const selectedDate = useDateTimeStore((store) => store.date); - + const now = dayjs(); const { endOfDay, startOfDay } = getDateUTCRange(selectedDate).day(); const { data: { slots } = {}, isLoading } = useMasterSlotsQuery({ @@ -20,12 +23,31 @@ export function DaySlotsList() { master: { documentId: { eq: customer?.documentId } }, }, }); - if (isLoading) return ; + + if (isLoading) { + return ; + } + + const shouldShowAddForm = now.isSame(selectedDate, 'day') || now.isBefore(selectedDate, 'day'); + + if (!slots?.length) { + return ( + + + {shouldShowAddForm && } + + ); + } + return ( -
+

Слоты

- {slots?.map((slot) => slot && )} - -
+ {slots.map((slot) => slot && )} + {shouldShowAddForm && } + ); } + +function Wrapper({ children }: Readonly) { + return
{children}
; +}