File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,7 +121,16 @@ export async function selectAvailabilities(
121121 return result . state ;
122122 }
123123
124- // 4. Update the session
124+ // 4. Only pending sessions can have their availabilities changed
125+ if ( result . session . status !== "pending" ) {
126+ return {
127+ errors : {
128+ _form : [ "Availabilities can only be set for pending sessions" ] ,
129+ } ,
130+ } ;
131+ }
132+
133+ // 5. Update the session
125134 try {
126135 await db
127136 . update ( coachingSessions )
@@ -184,7 +193,16 @@ export async function selectTimeSlot(
184193
185194 const { session } = result ;
186195
187- // 4. Verify the slot exists in the session's available time slots
196+ // 4. Only pending sessions can be confirmed
197+ if ( session . status !== "pending" ) {
198+ return {
199+ errors : {
200+ _form : [ "Only pending sessions can be confirmed" ] ,
201+ } ,
202+ } ;
203+ }
204+
205+ // 5. Verify the slot exists in the session's available time slots
188206 const slots = session . selectedTimeSlots as TimeSlot [ ] | null ;
189207 if ( ! slots || ! Array . isArray ( slots ) ) {
190208 return {
You can’t perform that action at this time.
0 commit comments