Skip to content

Commit 3c50c92

Browse files
authored
Merge pull request #27 from skni-kod/fix/past-availability
Fix/past availability
2 parents eade988 + b66b32b commit 3c50c92

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/app/dashboard/calendar/_components/AvailabilityCheckPanel.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default function AvailabilityCheck() {
9393

9494
const { mutate: saveAvailability, isPending } = useMutation({
9595
mutationFn: async () => {
96-
if (!currentWeek || !nextWeek) return;
96+
if (!currentWeek || !nextWeek || !data) return;
9797

9898
const selectedSlots: TimeSlot[] = [];
9999

@@ -102,11 +102,14 @@ export default function AvailabilityCheck() {
102102
week.days.forEach((day) => {
103103
day.timeSlots.forEach((slot) => {
104104
if (slot.selected && !slot.booked) {
105-
selectedSlots.push({
106-
start_time: `${slot.day}T${slot.time}:00Z`,
107-
end_time: `${slot.day}T${parseInt(slot.time) + 1}:00Z`,
108-
status: `available`,
109-
});
105+
const slotDateTime = new Date(`${slot.day}T${slot.time}:00Z`);
106+
if (slotDateTime >= new Date(today)) {
107+
selectedSlots.push({
108+
start_time: `${slot.day}T${slot.time}:00Z`,
109+
end_time: `${slot.day}T${parseInt(slot.time) + 1}:00Z`,
110+
status: `available`,
111+
});
112+
}
110113
}
111114
});
112115
});

src/app/dashboard/calendar/_components/BigCalendar/BigCalendar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const BigCalendar = ({ role }: { role: string }) => {
3030
};
3131

3232
const handleSelectEvent = (event: Event) => {
33-
if (role === 'instructor') {
33+
if (role === 'instructor' && event.status === 'pending') {
3434
setSelectedEvent(event);
3535
setPopoverOpen(true);
3636
}

0 commit comments

Comments
 (0)