fix(Calendar): Adding global param

This commit is contained in:
Josepablo C
2024-07-22 20:31:15 -06:00
parent a2d9c48396
commit 89b35927d1

View File

@@ -18,6 +18,7 @@ function getAndFilterList( query ){
vehicle, vehicle,
driver, driver,
status, status,
posted_by,
posted_by_name, posted_by_name,
load_status, load_status,
published_date, published_date,
@@ -33,6 +34,7 @@ function getAndFilterList( query ){
if( vehicle ){ filter_list.push( { vehicle } ); } if( vehicle ){ filter_list.push( { vehicle } ); }
if( driver ){ filter_list.push( { driver } ); } if( driver ){ filter_list.push( { driver } ); }
if( status ){ filter_list.push( { status } ); } 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( posted_by_name ) { filter_list.push({ posted_by_name }); }
if( load_status ) { filter_list.push({ load_status }); } if( load_status ) { filter_list.push({ load_status }); }
if( published_date ) { filter_list.push({ published_date }); } if( published_date ) { filter_list.push({ published_date }); }
@@ -123,11 +125,6 @@ async function findCalendarLoads( userId, companyId, query ){
{"carrier" : companyId} {"carrier" : companyId}
] ]
if( !global ){
orFilterList.push( {"bidder" : userId} );
orFilterList.push( {"posted_by" : userId} );
}
const andFilterList = [ const andFilterList = [
{ {
"est_loading_date" : { "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 ){ if( load_status ){
andFilterList.push( { load_status } ) andFilterList.push( { load_status } )
} }
console.log( andFilterList );
const filter = { const filter = {
$and : andFilterList, $and : andFilterList,
}; };