@@ -5,6 +5,7 @@ import quoteRepository from "../repositorys/quoteRepository";
55import processQuotes from "../utils/quote/processQuoteData" ;
66import notificationRepository from "../repositorys/notificationRepository" ;
77import moverRepository from "../repositorys/moverRepository" ;
8+ import { object } from "superstruct" ;
89
910interface queryString {
1011 limit : number ;
@@ -167,7 +168,7 @@ const getMovingRequestListByMover = async (
167168 moverId : number ,
168169 query : queryString
169170) => {
170- const { limit, cursor, orderBy } = query ;
171+ const { limit, cursor, orderBy, isQuoted } = query ;
171172 const whereCondition : WhereCondition = setWhereCondition ( query , moverId ) ;
172173 const orderByQuery = setOrderBy ( orderBy ) ;
173174
@@ -186,18 +187,52 @@ const getMovingRequestListByMover = async (
186187 in : regions ,
187188 } ;
188189
189- const countCondition = {
190- quote : whereCondition . quote ,
191- OR : whereCondition . OR ,
192- AND : whereCondition . AND ,
190+ const countCondition : WhereCondition = {
193191 movingDate : whereCondition . movingDate ,
194192 region : whereCondition . region ,
195193 } ;
196194
195+ if ( isQuoted ) {
196+ countCondition . OR = [
197+ {
198+ quote : {
199+ some : {
200+ moverId,
201+ } ,
202+ } ,
203+ } ,
204+ {
205+ isRejected : {
206+ some : {
207+ id : moverId ,
208+ } ,
209+ } ,
210+ } ,
211+ ] ;
212+ } else {
213+ countCondition . AND = [
214+ {
215+ quote : {
216+ none : {
217+ moverId,
218+ } ,
219+ } ,
220+ } ,
221+ {
222+ isRejected : {
223+ none : {
224+ id : moverId ,
225+ } ,
226+ } ,
227+ } ,
228+ ] ;
229+ }
230+
197231 const serviceCountsPromise =
198232 movingRequestRepository . getMovingRequestCountByServices ( countCondition ) ;
199233
200- const totalCountPromise = movingRequestRepository . getTotalCount ( ) ;
234+ const totalCountPromise =
235+ movingRequestRepository . getTotalCount ( countCondition ) ;
201236 const designatedCountPromise =
202237 movingRequestRepository . getMovingRequestCountByDesignated ( moverId ) ;
203238
0 commit comments