@@ -149,6 +149,15 @@ async function createWithCard(req: Request, res: Response, next: NextFunction) {
149149 const phone = await withPhone ( user , payload . phone ) ;
150150 if ( phone instanceof Error ) return next ( bad ( phone . message ) ) ;
151151
152+ if ( payload . slotId < 0 ) {
153+ const pseudoSlot = await createPseudoLessonSlot ( {
154+ tutorId : payload . tutorId ,
155+ duration : payload . duration ,
156+ start : payload . start ,
157+ } ) ;
158+ payload . slotId = pseudoSlot . id ;
159+ }
160+
152161 const valid = await validateCreateLessonPayload ( payload ) ;
153162 if ( valid instanceof TutorNotFound ) return next ( notfound . tutor ( ) ) ;
154163 if ( valid instanceof SlotNotFound ) return next ( notfound . slot ( ) ) ;
@@ -200,6 +209,15 @@ async function createWithFawryRefNum(
200209 const phone = await withPhone ( user , payload . phone ) ;
201210 if ( phone instanceof Error ) return next ( bad ( phone . message ) ) ;
202211
212+ if ( payload . slotId < 0 ) {
213+ const pseudoSlot = await createPseudoLessonSlot ( {
214+ tutorId : payload . tutorId ,
215+ duration : payload . duration ,
216+ start : payload . start ,
217+ } ) ;
218+ payload . slotId = pseudoSlot . id ;
219+ }
220+
203221 const valid = await validateCreateLessonPayload ( payload ) ;
204222 if ( valid instanceof TutorNotFound ) return next ( notfound . tutor ( ) ) ;
205223 if ( valid instanceof SlotNotFound ) return next ( notfound . slot ( ) ) ;
@@ -249,6 +267,15 @@ async function createWithEWallet(
249267 const phone = await withPhone ( user , payload . phone ) ;
250268 if ( phone instanceof Error ) return next ( bad ( phone . message ) ) ;
251269
270+ if ( payload . slotId < 0 ) {
271+ const pseudoSlot = await createPseudoLessonSlot ( {
272+ tutorId : payload . tutorId ,
273+ duration : payload . duration ,
274+ start : payload . start ,
275+ } ) ;
276+ payload . slotId = pseudoSlot . id ;
277+ }
278+
252279 const valid = await validateCreateLessonPayload ( payload ) ;
253280 if ( valid instanceof TutorNotFound ) return next ( notfound . tutor ( ) ) ;
254281 if ( valid instanceof SlotNotFound ) return next ( notfound . slot ( ) ) ;
0 commit comments