Changes
This commit is contained in:
@@ -13,7 +13,7 @@ import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { formatIDR } from '@/lib/format';
|
||||
import { Video, Clock, Calendar as CalendarIcon, MessageSquare } from 'lucide-react';
|
||||
import { format, addMinutes, parse, isAfter, isBefore, startOfDay, addDays } from 'date-fns';
|
||||
import { format, addMinutes, parse, isAfter, isBefore, startOfDay, addDays, isSameDay } from 'date-fns';
|
||||
import { id } from 'date-fns/locale';
|
||||
|
||||
interface ConsultingSettings {
|
||||
@@ -106,6 +106,8 @@ export default function ConsultingBooking() {
|
||||
|
||||
const slots: TimeSlot[] = [];
|
||||
const duration = settings.consulting_block_duration_minutes;
|
||||
const now = new Date();
|
||||
const isToday = isSameDay(selectedDate, now);
|
||||
|
||||
for (const wh of dayWorkhours) {
|
||||
let current = parse(wh.start_time, 'HH:mm:ss', selectedDate);
|
||||
@@ -122,10 +124,13 @@ export default function ConsultingBooking() {
|
||||
return !(slotEnd <= csStart || slotStart >= csEnd);
|
||||
});
|
||||
|
||||
// Check if slot is in the past for today
|
||||
const isPassed = isToday && isBefore(current, now);
|
||||
|
||||
slots.push({
|
||||
start: slotStart,
|
||||
end: slotEnd,
|
||||
available: !isConflict,
|
||||
available: !isConflict && !isPassed,
|
||||
});
|
||||
|
||||
current = addMinutes(current, duration);
|
||||
|
||||
Reference in New Issue
Block a user