@@ -423,33 +423,29 @@ const designateMover = async (moverId: number, customerId: number) => {
423423 return throwHttpError ( 422 , "일반 견적 요청을 먼저 진행해 주세요." ) ;
424424 }
425425
426- const mover = await moverRepository . getMoverById ( null , moverId ) ;
427-
428- if ( ! mover ) {
429- return throwHttpError ( 404 , "기사를 찾을 수 없습니다." ) ;
430- }
431-
432- //지정 가능 인원 조회
433- const designateCountPromise = movingRequestRepository . getDesignateCount (
434- activeRequest . id
426+ const isQuote = activeRequest . quote . some (
427+ ( quote ) => quote . mover . id === moverId
435428 ) ;
436429
437- const designatedMoversPromise = movingRequestRepository . getDesignatedMovers (
438- activeRequest . id ,
439- moverId
430+ const isDesignated = activeRequest . mover . some (
431+ ( mover ) => mover . id === moverId
440432 ) ;
441433
442- const [ result , designatedMovers ] = await Promise . all ( [
443- designateCountPromise ,
444- designatedMoversPromise ,
445- ] ) ;
446-
447- if ( designatedMovers ) {
434+ if ( isDesignated ) {
448435 return throwHttpError ( 400 , "이미 지정된 기사 입니다." ) ;
449436 }
450437
438+ if ( isQuote ) {
439+ return throwHttpError ( 400 , "받은 일반 견적이 있습니다." ) ;
440+ }
441+
442+ const mover = await moverRepository . getMoverById ( null , moverId ) ;
443+ if ( ! mover ) {
444+ return throwHttpError ( 404 , "기사를 찾을 수 없습니다." ) ;
445+ }
446+
451447 //지정 가능 인원 초과 체크
452- if ( ! result || result . _count . mover >= 3 ) {
448+ if ( activeRequest . designateCount >= 3 ) {
453449 return throwHttpError (
454450 400 ,
455451 "지정 요청 가능한 인원이 초과되었습니다. (최대 3명)"
0 commit comments