File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
src/app/dashboard/calendar/_components Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ export default function AvailabilityCheck() {
93
93
94
94
const { mutate : saveAvailability , isPending } = useMutation ( {
95
95
mutationFn : async ( ) => {
96
- if ( ! currentWeek || ! nextWeek ) return ;
96
+ if ( ! currentWeek || ! nextWeek || ! data ) return ;
97
97
98
98
const selectedSlots : TimeSlot [ ] = [ ] ;
99
99
@@ -102,11 +102,14 @@ export default function AvailabilityCheck() {
102
102
week . days . forEach ( ( day ) => {
103
103
day . timeSlots . forEach ( ( slot ) => {
104
104
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
+ }
110
113
}
111
114
} ) ;
112
115
} ) ;
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ const BigCalendar = ({ role }: { role: string }) => {
30
30
} ;
31
31
32
32
const handleSelectEvent = ( event : Event ) => {
33
- if ( role === 'instructor' ) {
33
+ if ( role === 'instructor' && event . status === 'pending' ) {
34
34
setSelectedEvent ( event ) ;
35
35
setPopoverOpen ( true ) ;
36
36
}
You can’t perform that action at this time.
0 commit comments