This commit is contained in:
gpt-engineer-app[bot]
2025-12-19 14:43:28 +00:00
parent 04a140b305
commit b63da103cd
8 changed files with 265 additions and 35 deletions

View File

@@ -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);