feat(Shipper): Adding privacy as any other flag to the loads query
This commit is contained in:
@@ -325,7 +325,7 @@ const findList = async(req, res) => {
|
|||||||
switch( req.context.user?.company?.company_type ){
|
switch( req.context.user?.company?.company_type ){
|
||||||
case "Shipper":
|
case "Shipper":
|
||||||
console.log("Shipper loads finder");
|
console.log("Shipper loads finder");
|
||||||
retVal = await ShipperServices.findLoads( companyId, query );
|
retVal = await ShipperServices.findLoads( query );
|
||||||
break;
|
break;
|
||||||
case "Carrier":
|
case "Carrier":
|
||||||
if( req.context.user?.job_role === "driver" ){
|
if( req.context.user?.job_role === "driver" ){
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ function getAndFilterList( query ){
|
|||||||
truck_type,
|
truck_type,
|
||||||
state,
|
state,
|
||||||
city,
|
city,
|
||||||
|
privacy,
|
||||||
} = query;
|
} = query;
|
||||||
|
|
||||||
if( company ){ filter_list.push( { company } ); }
|
if( company ){ filter_list.push( { company } ); }
|
||||||
@@ -86,6 +87,7 @@ function getAndFilterList( query ){
|
|||||||
if( destination_warehouse ) { filter_list.push({ destination_warehouse }); }
|
if( destination_warehouse ) { filter_list.push({ destination_warehouse }); }
|
||||||
if( alert_list ) { filter_list.push({ alert_list }); }
|
if( alert_list ) { filter_list.push({ alert_list }); }
|
||||||
if( truck_type ) { filter_list.push({ truck_type }); }
|
if( truck_type ) { filter_list.push({ truck_type }); }
|
||||||
|
if( privacy ) { filter_list.push({ privacy }); }
|
||||||
|
|
||||||
if( state ) {
|
if( state ) {
|
||||||
filter_list.push({
|
filter_list.push({
|
||||||
@@ -141,21 +143,7 @@ function getAndFilterList( query ){
|
|||||||
return filter_list;
|
return filter_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCompanyIdListFromGroups( companyId ){
|
async function findLoads( query ){
|
||||||
const privateGroups = await companyGroupsModel.find({
|
|
||||||
allowedCompanies: { $in: [companyId] }
|
|
||||||
});
|
|
||||||
|
|
||||||
if( !privateGroups ){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const companiesIds = privateGroups.map((group) => group.owner);
|
|
||||||
|
|
||||||
return companiesIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function findLoads( companyId, query ){
|
|
||||||
const { $sort, company_name } = query;
|
const { $sort, company_name } = query;
|
||||||
const { page, elements } = getPagination( query );
|
const { page, elements } = getPagination( query );
|
||||||
const andFilterList = getAndFilterList( query ) || [];
|
const andFilterList = getAndFilterList( query ) || [];
|
||||||
|
|||||||
Reference in New Issue
Block a user