refactor(order-form/datetime-select): enhance date selection logic to include slot availability check

This commit is contained in:
vchikalkin 2025-07-16 13:58:02 +03:00
parent e925f2925a
commit e8771ed999

View File

@ -45,17 +45,12 @@ export function DateSelect() {
<Calendar
className="bg-background"
disabled={(date) => {
return dayjs().isAfter(dayjs(date), 'day');
return (
dayjs().isAfter(dayjs(date), 'day') ||
!slots?.some((slot) => dayjs(slot?.date).isSame(date, 'day'))
);
}}
mode="single"
modifiers={{
hasEvent: (date) => {
return slots?.some((slot) => dayjs(slot?.date).isSame(date, 'day')) || false;
},
}}
modifiersClassNames={{
hasEvent: 'border-primary border-2 rounded-xl',
}}
onMonthChange={(date) => setCurrentMonthDate(date)}
onSelect={(date) => {
if (date) setDate(date);