From 89b35927d1bc2d96d5154a618daa9be8291b47ed Mon Sep 17 00:00:00 2001 From: Josepablo C Date: Mon, 22 Jul 2024 20:31:15 -0600 Subject: [PATCH] fix(Calendar): Adding global param --- src/apps/private/loads/services.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/apps/private/loads/services.js b/src/apps/private/loads/services.js index 5732118..1a566e6 100644 --- a/src/apps/private/loads/services.js +++ b/src/apps/private/loads/services.js @@ -18,6 +18,7 @@ function getAndFilterList( query ){ vehicle, driver, status, + posted_by, posted_by_name, load_status, published_date, @@ -33,6 +34,7 @@ function getAndFilterList( query ){ if( vehicle ){ filter_list.push( { vehicle } ); } if( driver ){ filter_list.push( { driver } ); } if( status ){ filter_list.push( { status } ); } + if( posted_by ) { filter_list.push({ posted_by }); } if( posted_by_name ) { filter_list.push({ posted_by_name }); } if( load_status ) { filter_list.push({ load_status }); } if( published_date ) { filter_list.push({ published_date }); } @@ -123,11 +125,6 @@ async function findCalendarLoads( userId, companyId, query ){ {"carrier" : companyId} ] - if( !global ){ - orFilterList.push( {"bidder" : userId} ); - orFilterList.push( {"posted_by" : userId} ); - } - const andFilterList = [ { "est_loading_date" : { @@ -140,10 +137,21 @@ async function findCalendarLoads( userId, companyId, query ){ } ] + if( !(global) || (global == 0) ){ + andFilterList.push( { + $or : [ + {"bidder" : userId}, + {"posted_by" : userId}, + ] + } ); + } + if( load_status ){ andFilterList.push( { load_status } ) } + console.log( andFilterList ); + const filter = { $and : andFilterList, };