tango-app-api-trax 3.7.74 → 3.7.75
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 +2 -4
- package/src/controllers/internalTrax.controller.js +3 -157
- package/src/controllers/mobileTrax.controller.js +41 -383
- package/src/controllers/trax.controller.js +1 -80
- package/src/controllers/traxDashboard.controllers.js +3 -58
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/internalTraxApi.router.js +0 -1
- package/src/routes/mobileTrax.routes.js +1 -3
- package/src/routes/trax.routes.js +1 -2
- package/src/controllers/handlebar-helper.js +0 -16
- package/src/hbs/flag.hbs +0 -249
- package/src/hbs/template.hbs +0 -337
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.75",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,13 +23,11 @@
|
|
|
23
23
|
"firebase-admin": "^13.0.0",
|
|
24
24
|
"fs": "^0.0.1-security",
|
|
25
25
|
"handlebars": "^4.7.8",
|
|
26
|
-
"html-pdf": "^3.0.1",
|
|
27
26
|
"lodash": "^4.17.21",
|
|
28
27
|
"mongodb": "^6.8.0",
|
|
29
28
|
"nodemon": "^3.1.4",
|
|
30
29
|
"path": "^0.12.7",
|
|
31
|
-
"
|
|
32
|
-
"tango-api-schema": "^2.5.64",
|
|
30
|
+
"tango-api-schema": "^2.5.59",
|
|
33
31
|
"tango-app-api-middleware": "^3.5.2",
|
|
34
32
|
"url": "^0.11.4",
|
|
35
33
|
"winston": "^3.13.1",
|
|
@@ -595,7 +595,6 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
595
595
|
element4.remainder = getCLconfig?.remainder || [];
|
|
596
596
|
element4.country = element4?.store?.[0]?.country || '';
|
|
597
597
|
element4.state = element4?.store?.[0]?.state || '';
|
|
598
|
-
element4.complianceCount = getCLconfig?.complianceCount || 0;
|
|
599
598
|
|
|
600
599
|
// if ( getCLconfig?.isPlano ) {
|
|
601
600
|
// let planoDetails = await planoService.findOne( { storeId: element4.store_id, clientId: getCLconfig.client_id }, { _id: 1 } );
|
|
@@ -1363,42 +1362,6 @@ export async function insertTimeDelayFlags( req, res ) {
|
|
|
1363
1362
|
|
|
1364
1363
|
let updatedDetails = await processedchecklist.updateMany( { _id: { $in: checklistId } }, { timeFlag: 1 } );
|
|
1365
1364
|
|
|
1366
|
-
|
|
1367
|
-
let notifyStores = await processedchecklist.find( { _id: { $in: checklistId }, notify: { $exists: false } } );
|
|
1368
|
-
|
|
1369
|
-
if ( notifyStores.length ) {
|
|
1370
|
-
Promise.all( notifyStores.map( async ( store ) => {
|
|
1371
|
-
let checklistDetails = await checklistService.findOne( { _id: store.sourceCheckList_id }, { notifyFlags: 1, approver: 1 } );
|
|
1372
|
-
if ( checklistDetails?.notifyFlags?.notifyType?.length ) {
|
|
1373
|
-
let emailList = checklistDetails?.notifyFlags?.notifyType.includes( 'approver' ) ? checklistDetails.approver.map( ( ele ) => ele?.value ): [];
|
|
1374
|
-
emailList = [ ...emailList, ...checklistDetails?.notifyFlags?.users?.map( ( ele ) => ele?.value ) ];
|
|
1375
|
-
let data = {
|
|
1376
|
-
storeName: store.storeName,
|
|
1377
|
-
flagCount: 1,
|
|
1378
|
-
checklistName: store.checkListName?.trim(),
|
|
1379
|
-
submittedBy: '--',
|
|
1380
|
-
time: '--',
|
|
1381
|
-
domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,
|
|
1382
|
-
type: 'delay',
|
|
1383
|
-
};
|
|
1384
|
-
const fileContent = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/flag.hbs', 'utf8' );
|
|
1385
|
-
const htmlContent = handlebars.compile( fileContent );
|
|
1386
|
-
const html = htmlContent( { data: data } );
|
|
1387
|
-
emailList.forEach( ( email ) => {
|
|
1388
|
-
let params = {
|
|
1389
|
-
toEmail: email,
|
|
1390
|
-
mailSubject: 'TangoEye | Checklist Flag',
|
|
1391
|
-
htmlBody: html,
|
|
1392
|
-
attachment: '',
|
|
1393
|
-
sourceEmail: JSON.parse( process.env.SES ).adminEmail,
|
|
1394
|
-
};
|
|
1395
|
-
sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
1396
|
-
} );
|
|
1397
|
-
}
|
|
1398
|
-
await processedchecklist.updateOne( { _id: store._id }, { notify: true } );
|
|
1399
|
-
} ) );
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
1365
|
if ( updatedDetails ) {
|
|
1403
1366
|
return res.sendSuccess( { message: 'Time Delay Updated Successfully' } );
|
|
1404
1367
|
}
|
|
@@ -2752,13 +2715,8 @@ export async function updateChecklistConfig( req, res ) {
|
|
|
2752
2715
|
|
|
2753
2716
|
export async function submittedList( req, res ) {
|
|
2754
2717
|
try {
|
|
2755
|
-
let fromDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
2756
|
-
let toDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
2757
|
-
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
2758
|
-
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
2759
|
-
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
2760
2718
|
let getSubmitChecklist = await processedchecklist.find( { checklistStatus: 'submit', date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ) }, { _id: 1 } );
|
|
2761
|
-
let getSubmitTask = await processedTaskService.find( { checklistStatus: 'submit',
|
|
2719
|
+
let getSubmitTask = await processedTaskService.find( { checklistStatus: 'submit', date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ), isPlano: { $exists: false } }, { _id: 1 } );
|
|
2762
2720
|
|
|
2763
2721
|
let result = [ ...getSubmitChecklist?.map( ( ele ) => ele?._id ), ...getSubmitTask?.map( ( ele ) => ele?._id ) ];
|
|
2764
2722
|
return res.sendSuccess( result );
|
|
@@ -3245,37 +3203,9 @@ export async function checklistTaskSubmissionDetails( req, res ) {
|
|
|
3245
3203
|
}
|
|
3246
3204
|
let details = [];
|
|
3247
3205
|
if ( req.body.type == 'checklist' ) {
|
|
3248
|
-
details = await processedchecklist.find( { sourceCheckList_id: req.body.checklistId,
|
|
3249
|
-
date_string: 1,
|
|
3250
|
-
checkListName: 1,
|
|
3251
|
-
createdByName: 1,
|
|
3252
|
-
store_id: 1,
|
|
3253
|
-
storeName: 1,
|
|
3254
|
-
submmitedBy: '$userName',
|
|
3255
|
-
submmitedByEmail: '$userEmail',
|
|
3256
|
-
checklistStatus: 1,
|
|
3257
|
-
submitTime: 1,
|
|
3258
|
-
approvalTime: 1,
|
|
3259
|
-
approvalTime_string: 1,
|
|
3260
|
-
approvalByName: 1,
|
|
3261
|
-
approvalByEmail: 1,
|
|
3262
|
-
} );
|
|
3206
|
+
details = await processedchecklist.find( { sourceCheckList_id: req.body.checklistId, date_iso: new Date( dayjs( req.body.date ).format( 'YYYY-MM-DD' ) ) }, { submitTime: '$submitTime_string', status: '$checklistStatus', approvalStatus: '$approvalStatus', approvalTime: '$approvalTime_string', _id: 0 } );
|
|
3263
3207
|
} else {
|
|
3264
|
-
details = await processedTaskService.find( { sourceCheckList_id: req.body.checklistId,
|
|
3265
|
-
date_string: 1,
|
|
3266
|
-
checkListName: 1,
|
|
3267
|
-
createdByName: 1,
|
|
3268
|
-
store_id: 1,
|
|
3269
|
-
storeName: 1,
|
|
3270
|
-
submmitedBy: '$userName',
|
|
3271
|
-
submmitedByEmail: '$userEmail',
|
|
3272
|
-
checklistStatus: 1,
|
|
3273
|
-
submitTime: 1,
|
|
3274
|
-
approvalTime: 1,
|
|
3275
|
-
approvalTime_string: 1,
|
|
3276
|
-
approvalByName: 1,
|
|
3277
|
-
approvalByEmail: 1,
|
|
3278
|
-
} );
|
|
3208
|
+
details = await processedTaskService.find( { sourceCheckList_id: req.body.checklistId, date_iso: new Date( dayjs( req.body.date ).format( 'YYYY-MM-DD' ) ) }, { submitTime: '$submitTime_string', status: '$checklistStatus', approvalStatus: '$approvalStatus', approvalTime: '$approvalTime_string', _id: 0 } );
|
|
3279
3209
|
}
|
|
3280
3210
|
return res.sendSuccess( details );
|
|
3281
3211
|
} catch ( e ) {
|
|
@@ -3283,87 +3213,3 @@ export async function checklistTaskSubmissionDetails( req, res ) {
|
|
|
3283
3213
|
return res.sendError( e, 500 );
|
|
3284
3214
|
}
|
|
3285
3215
|
}
|
|
3286
|
-
|
|
3287
|
-
export async function getStoreTaskDetails( req, res ) {
|
|
3288
|
-
try {
|
|
3289
|
-
const checklistQuery = [
|
|
3290
|
-
{
|
|
3291
|
-
$match: {
|
|
3292
|
-
storeName: req.body.storeName,
|
|
3293
|
-
checkListName: { $regex: 'Store Tour', $options: 'i' },
|
|
3294
|
-
},
|
|
3295
|
-
},
|
|
3296
|
-
{
|
|
3297
|
-
$group: {
|
|
3298
|
-
_id: '$storeName',
|
|
3299
|
-
checklistStatus: { $last: '$checklistStatus' },
|
|
3300
|
-
checkListName: { $last: '$checkListName' },
|
|
3301
|
-
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
3302
|
-
},
|
|
3303
|
-
},
|
|
3304
|
-
];
|
|
3305
|
-
const checkListDetails = await processedchecklist.aggregate( checklistQuery );
|
|
3306
|
-
const taskQuery = [
|
|
3307
|
-
{
|
|
3308
|
-
$match: {
|
|
3309
|
-
storeName: req.body.storeName,
|
|
3310
|
-
isPlano: true,
|
|
3311
|
-
planoType: { $in: [ 'fixture', 'merchRollout', 'vmRollout' ] },
|
|
3312
|
-
},
|
|
3313
|
-
},
|
|
3314
|
-
{
|
|
3315
|
-
$group: {
|
|
3316
|
-
_id: { store: '$storeName', type: '$planoType' },
|
|
3317
|
-
checklistStatus: { $last: '$checklistStatus' },
|
|
3318
|
-
checkListName: { $last: '$checkListName' },
|
|
3319
|
-
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
3320
|
-
},
|
|
3321
|
-
},
|
|
3322
|
-
{
|
|
3323
|
-
$project: {
|
|
3324
|
-
store: '$_id.store',
|
|
3325
|
-
type: '$_id.type',
|
|
3326
|
-
checklistStatus: 1,
|
|
3327
|
-
checkListName: 1,
|
|
3328
|
-
scheduleEndTime_iso: 1,
|
|
3329
|
-
},
|
|
3330
|
-
},
|
|
3331
|
-
];
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
const taskDetails = await processedTaskService.aggregate( taskQuery );
|
|
3335
|
-
console.log( taskDetails );
|
|
3336
|
-
let info = [ ...checkListDetails, ...taskDetails ];
|
|
3337
|
-
// const details = {
|
|
3338
|
-
// storeTourVideoChecklist: ( !checkListDetails.length || checkListDetails?.[0]?.checklistStatus == 'submit' ) ? true : false,
|
|
3339
|
-
// FixtureVerification: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'fixture' ) || taskDetails?.some( ( ele ) => ele?.type == 'fixture' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3340
|
-
// MerchRollout: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'merchRollout' ) || taskDetails?.some( ( ele ) => ele?.type == 'merchRollout' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3341
|
-
// VmRollout: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'vmRollout' ) || taskDetails?.some( ( ele ) => ele?.type == 'vmRollout' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3342
|
-
// };
|
|
3343
|
-
|
|
3344
|
-
let result = {
|
|
3345
|
-
storeId: req.body.storeName,
|
|
3346
|
-
tangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus != 'submit' && dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ) < dayjs().format( 'YYYY-MM-DD' ) ).map( ( ele ) => {
|
|
3347
|
-
return {
|
|
3348
|
-
blockName: ele?.checkListName,
|
|
3349
|
-
blockEnabled: true,
|
|
3350
|
-
blockReason: `${ele?.checkListName} is completed`,
|
|
3351
|
-
};
|
|
3352
|
-
} ),
|
|
3353
|
-
upcomingTangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus !== 'submit' ).map( ( ele ) => {
|
|
3354
|
-
return {
|
|
3355
|
-
blockName: ele?.checkListName,
|
|
3356
|
-
blockReason: `Compelete ${ele?.checkListName} before ${dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' )} to avoid ABC block`,
|
|
3357
|
-
dueDate: dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ),
|
|
3358
|
-
};
|
|
3359
|
-
} ),
|
|
3360
|
-
};
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
return res.sendSuccess( result );
|
|
3364
|
-
} catch ( error ) {
|
|
3365
|
-
const err = error.message || 'Internal Server Error';
|
|
3366
|
-
logger.error( { error: error, message: req.body, function: 'getStoretaskDetails' } );
|
|
3367
|
-
return res.sendError( err, 500 );
|
|
3368
|
-
}
|
|
3369
|
-
}
|