refactor(order-form/datetime-select): enhance date selection logic to include slot availability check
This commit is contained in:
parent
e925f2925a
commit
e8771ed999
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user