tango-app-api-trax 3.3.1-beta-46 → 3.3.1-beta-48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2633,7 +2633,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
|
|
|
2633
2633
|
let findQuery = [
|
|
2634
2634
|
{ $match: { $and: [
|
|
2635
2635
|
{ client_id: requestData.clientId },
|
|
2636
|
-
{ $or: [ { store_id: { $in: requestData.storeId } }, { aiStoreList: { $in: requestData.storeId } } ] },
|
|
2636
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } }, { aiStoreList: { $in: requestData.storeId } } ] },
|
|
2637
2637
|
{ date_iso: { $gte: fromDate } },
|
|
2638
2638
|
{ date_iso: { $lte: toDate } },
|
|
2639
2639
|
{
|
|
@@ -2643,7 +2643,6 @@ export const checklistDropdownV1 = async ( req, res ) => {
|
|
|
2643
2643
|
{ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection' ] } },
|
|
2644
2644
|
],
|
|
2645
2645
|
},
|
|
2646
|
-
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
2647
2646
|
] } },
|
|
2648
2647
|
{
|
|
2649
2648
|
$project: {
|
|
@@ -394,9 +394,21 @@ export const getConfigDetails = async ( req, res ) => {
|
|
|
394
394
|
result.checkListDetails.scheduleStartTime = result.openTime;
|
|
395
395
|
result.checkListDetails.scheduleEndTime = result.closeTime;
|
|
396
396
|
}
|
|
397
|
-
let
|
|
398
|
-
|
|
399
|
-
|
|
397
|
+
let query = {
|
|
398
|
+
checkListId: storechecklistdetails._id,
|
|
399
|
+
...( storechecklistdetails.coverage == 'store' ) ? { $or: [ { store_id: { $exists: true } }, { clusterName: { $exists: true } } ] } : { $or: [ { userEmail: { $exists: true } }, { teamsName: { $exists: true } } ] },
|
|
400
|
+
};
|
|
401
|
+
let assignList = await assignedService.find( query, { _id: 1, store_id: 1, clusterName: 1, userEmail: 1, teamName: 1, assignId: 1 } );
|
|
402
|
+
let singleAssign;
|
|
403
|
+
let groupAssign;
|
|
404
|
+
if ( storechecklistdetails.coverage == 'store' ) {
|
|
405
|
+
singleAssign = assignList.filter( ( item ) => typeof item?.store_id != 'undefined' && item?.store_id != '' ).map( ( item ) => item.assignId );
|
|
406
|
+
groupAssign = assignList.filter( ( item ) => typeof item?.clusterName != 'undefined' && item?.clusterName != '' ).map( ( item ) => item.assignId );
|
|
407
|
+
} else {
|
|
408
|
+
singleAssign = assignList.filter( ( item ) => typeof item?.userEmail != 'undefined' && item?.userEmail !='' ).map( ( item ) => item.assignId );
|
|
409
|
+
groupAssign = assignList.filter( ( item ) => typeof item?.teamName != 'undefined' && item?.teamName != '' ).map( ( item ) => item.assignId );
|
|
410
|
+
}
|
|
411
|
+
result.checkListDetails = { ...result.checkListDetails, ...{ sections: sectionList }, singleAssign, groupAssign };
|
|
400
412
|
}
|
|
401
413
|
|
|
402
414
|
return res.sendSuccess( result );
|
|
@@ -809,6 +821,7 @@ export const update = async ( req, res ) => {
|
|
|
809
821
|
}
|
|
810
822
|
}
|
|
811
823
|
} ).catch( ( e ) => {
|
|
824
|
+
logger.error( 'update =>', e );
|
|
812
825
|
return res.sendError( e, 500 );
|
|
813
826
|
} );
|
|
814
827
|
} catch ( e ) {
|
|
@@ -3465,43 +3478,41 @@ export const selectAssign = async ( req, res ) => {
|
|
|
3465
3478
|
let resuldData;
|
|
3466
3479
|
if ( requestData.coverage == 'store' ) {
|
|
3467
3480
|
// //Select Store and cluster
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
clusterServices.aggregateCluster( clusterQuery )
|
|
3480
|
-
|
|
3481
|
+
if ( requestData.assignType == 'store' ) {
|
|
3482
|
+
let storeQuery = [
|
|
3483
|
+
{ $match: { clientId: requestData.clientId, status: 'active' } },
|
|
3484
|
+
{ $project: { 'storeName': 1, 'storeId': 1, 'type': 'store' } },
|
|
3485
|
+
];
|
|
3486
|
+
resuldData = await storeService.aggregate( storeQuery );
|
|
3487
|
+
} else {
|
|
3488
|
+
let clusterQuery = [
|
|
3489
|
+
{ $match: { clientId: requestData.clientId } },
|
|
3490
|
+
{ $project: { 'clusterName': 1, 'type': 'cluster' } },
|
|
3491
|
+
];
|
|
3492
|
+
resuldData = await clusterServices.aggregateCluster( clusterQuery );
|
|
3493
|
+
}
|
|
3481
3494
|
// console.log( 'getStores =>', getStores );
|
|
3482
3495
|
// console.log( 'getClusters =>', getClusters );
|
|
3483
|
-
resuldData = [ ...getStores, ...getClusters ];
|
|
3484
|
-
console.log( 'resuldData =>', resuldData );
|
|
3485
3496
|
} else if ( requestData.coverage == 'user' ) {
|
|
3486
3497
|
// //Select User and Teams
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3498
|
+
if ( requestData.assignType == 'user' ) {
|
|
3499
|
+
let userQuery = [
|
|
3500
|
+
{ $match: { clientId: requestData.clientId } },
|
|
3501
|
+
{ $project: { 'userEmail': 1, 'userName': 1, 'type': 'user' } },
|
|
3502
|
+
];
|
|
3503
|
+
resuldData = await userService.aggregate( userQuery );
|
|
3504
|
+
} else {
|
|
3505
|
+
let teamQuery = [
|
|
3506
|
+
{ $match: { clientId: requestData.clientId } },
|
|
3507
|
+
{ $project: { 'teamName': 1, 'type': 'teams' } },
|
|
3508
|
+
];
|
|
3509
|
+
resuldData = await teamsServices.aggregateTeams( teamQuery );
|
|
3510
|
+
}
|
|
3491
3511
|
// let getUsers = await userService.aggregate( userQuery );
|
|
3492
3512
|
// console.log( 'getUsers =>', getUsers );
|
|
3493
|
-
|
|
3494
|
-
{ $match: { clientId: requestData.clientId } },
|
|
3495
|
-
{ $project: { 'teamName': 1, 'type': 'teams' } },
|
|
3496
|
-
];
|
|
3513
|
+
|
|
3497
3514
|
// let getTeams = await teamsServices.aggregateTeams( teamQuery );
|
|
3498
3515
|
// console.log( 'getTeams =>', getTeams );
|
|
3499
|
-
const [ getUsers, getTeams ] = await Promise.all( [
|
|
3500
|
-
userService.aggregate( userQuery ),
|
|
3501
|
-
teamsServices.aggregateTeams( teamQuery ),
|
|
3502
|
-
] );
|
|
3503
|
-
resuldData = [ ...getUsers, ...getTeams ];
|
|
3504
|
-
console.log( 'resuldData =>', resuldData );
|
|
3505
3516
|
}
|
|
3506
3517
|
return res.sendSuccess( { 'totalCount': resuldData.length, 'data': resuldData } );
|
|
3507
3518
|
} catch ( e ) {
|
|
@@ -3600,7 +3611,7 @@ async function assignUsers( data ) {
|
|
|
3600
3611
|
if ( !userDetails ) {
|
|
3601
3612
|
let userData = {
|
|
3602
3613
|
userName: storeDetails?.[0]?.spocDetails?.[0]?.name,
|
|
3603
|
-
email: storeDetails?.[0]?.spocDetails[0].email,
|
|
3614
|
+
email: data?.userEmail || storeDetails?.[0]?.spocDetails[0].email,
|
|
3604
3615
|
mobileNumber: storeDetails?.[0]?.spocDetails?.[0]?.phone,
|
|
3605
3616
|
clientId: data.clientId,
|
|
3606
3617
|
};
|
|
@@ -3715,7 +3726,6 @@ async function assignUsers( data ) {
|
|
|
3715
3726
|
}
|
|
3716
3727
|
}
|
|
3717
3728
|
|
|
3718
|
-
// console.log( assignedData, 'test', data );
|
|
3719
3729
|
if ( assignedData && data?.insert ) {
|
|
3720
3730
|
await assignedService.updateOne( { checkListId: assignedData.checkListId, assignId: assignedData.assignId }, assignedData );
|
|
3721
3731
|
} else {
|
|
@@ -3740,7 +3750,7 @@ export async function checklistAssign( req, res ) {
|
|
|
3740
3750
|
return res.sendError( 'No data found', 204 );
|
|
3741
3751
|
}
|
|
3742
3752
|
|
|
3743
|
-
let
|
|
3753
|
+
let uniqueArr = [];
|
|
3744
3754
|
|
|
3745
3755
|
await Promise.all( req.body.idList.map( async ( data ) => {
|
|
3746
3756
|
let assignedData = {
|
|
@@ -3755,16 +3765,13 @@ export async function checklistAssign( req, res ) {
|
|
|
3755
3765
|
let uploadData = await assignUsers( assignedData );
|
|
3756
3766
|
if ( uploadData ) {
|
|
3757
3767
|
if ( Array.isArray( uploadData ) ) {
|
|
3758
|
-
|
|
3768
|
+
uniqueArr.push( ...uploadData );
|
|
3759
3769
|
} else {
|
|
3760
|
-
|
|
3770
|
+
uniqueArr.push( uploadData );
|
|
3761
3771
|
}
|
|
3762
3772
|
}
|
|
3763
3773
|
} ) );
|
|
3764
3774
|
|
|
3765
|
-
let uniqueArr = userData.filter( ( obj, index, self ) =>
|
|
3766
|
-
index === self.findIndex( ( o ) => o.storeId === obj.storeId && o.userEmail === obj.userEmail ),
|
|
3767
|
-
);
|
|
3768
3775
|
return res.sendSuccess( { count: uniqueArr.length, uniqueArr } );
|
|
3769
3776
|
} catch ( e ) {
|
|
3770
3777
|
logger.error( { functionName: 'checklistAssign', error: e } );
|