tango-app-api-trax 3.8.25 → 3.8.26-nike
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 -2
- package/src/controllers/download.controller.js +19 -19
- package/src/controllers/gallery.controller.js +92 -28
- package/src/controllers/handlebar-helper.js +1 -0
- package/src/controllers/internalTrax.controller.js +418 -172
- package/src/controllers/mobileTrax.controller.js +770 -168
- package/src/controllers/teaxFlag.controller.js +5 -5
- package/src/controllers/trax.controller.js +6 -2
- package/src/hbs/flag.hbs +248 -248
- package/src/hbs/login-otp.hbs +943 -943
- package/src/hbs/recurringFlag.hbs +250 -253
- package/src/hbs/template.hbs +6 -2
- package/src/hbs/visit-checklist.hbs +82 -38
- package/src/hbs/weeklyWrap.hbs +218 -218
- package/src/routes/mobileTrax.routes.js +1 -0
- package/src/utils/visitChecklistPdf.utils.js +6 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.26-nike",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"nodemon": "^3.1.4",
|
|
30
30
|
"path": "^0.12.7",
|
|
31
31
|
"puppeteer": "^24.39.1",
|
|
32
|
-
"tango-api-schema": "^2.5.
|
|
32
|
+
"tango-api-schema": "^2.5.98",
|
|
33
33
|
"tango-app-api-middleware": "^3.5.2",
|
|
34
34
|
"url": "^0.11.4",
|
|
35
35
|
"winston": "^3.13.1",
|
|
@@ -53,31 +53,31 @@ async function getBrandInfo( clientId ) {
|
|
|
53
53
|
return brandInfo;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
async function streamChecklistZip( res, checklistList, brandInfo, zipBaseName ) {
|
|
57
|
-
|
|
56
|
+
// async function streamChecklistZip( res, checklistList, brandInfo, zipBaseName ) {
|
|
57
|
+
// const zipName = `${sanitizeFilenamePart( zipBaseName, 'visit-checklists' )}_${dayjs().format( 'YYYY-MM-DD_HH-mm' )}.zip`;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
// res.status( 200 );
|
|
60
|
+
// res.setHeader( 'Content-Type', 'application/zip' );
|
|
61
|
+
// res.setHeader( 'Content-Disposition', `attachment; filename="${zipName.replace( /"/g, '\\"' )}"` );
|
|
62
|
+
// res.setHeader( 'Cache-Control', 'private, no-cache' );
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
// const archive = archiver( 'zip', { zlib: { level: 9 } } );
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
// archive.on( 'error', ( err ) => {
|
|
67
|
+
// throw err;
|
|
68
|
+
// } );
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
// archive.pipe( res );
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
// for ( const checklistDetails of checklistList ) {
|
|
73
|
+
// const templateData = buildVisitChecklistTemplateData( checklistDetails, brandInfo );
|
|
74
|
+
// const pdfBuffer = await generateVisitChecklistPDF( templateData );
|
|
75
|
+
// const pdfName = `${sanitizeFilenamePart( checklistDetails.storeName || checklistDetails.store_id || checklistDetails._id, 'store' )}_${sanitizeFilenamePart( checklistDetails.checkListName || 'Visit Checklist' )}.pdf`;
|
|
76
|
+
// archive.append( Buffer.isBuffer( pdfBuffer ) ? pdfBuffer : Buffer.from( pdfBuffer ), { name: pdfName } );
|
|
77
|
+
// }
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
}
|
|
79
|
+
// await archive.finalize();
|
|
80
|
+
// }
|
|
81
81
|
|
|
82
82
|
async function createChecklistZipBuffer( checklistList, brandInfo ) {
|
|
83
83
|
const output = new PassThrough();
|
|
@@ -139,6 +139,7 @@ export async function getcustomerunattendedlist( req, res ) {
|
|
|
139
139
|
}
|
|
140
140
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
141
141
|
let resultData = await LamdaServiceCall( url.customerUnattended, req.body );
|
|
142
|
+
console.log( '🚀 ~ getcustomerunattendedlist ~ url.customerUnattended:', url.customerUnattended );
|
|
142
143
|
if ( resultData ) {
|
|
143
144
|
if ( resultData.status_code == '200' ) {
|
|
144
145
|
return res.sendSuccess( resultData );
|
|
@@ -436,12 +437,14 @@ export async function redoChecklist( req, res ) {
|
|
|
436
437
|
}
|
|
437
438
|
|
|
438
439
|
|
|
439
|
-
let checklistDetails = await processedChecklist.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1, coverage: 1, userEmail: 1 } );
|
|
440
|
+
let checklistDetails = await processedChecklist.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1, coverage: 1, userEmail: 1, scheduleEndTime_iso: 1, redoEdit: 1 } );
|
|
441
|
+
|
|
440
442
|
if ( !checklistDetails ) {
|
|
441
443
|
return res.sendError( 'No data found', 204 );
|
|
442
444
|
}
|
|
443
445
|
let question = checklistDetails.questionAnswers;
|
|
444
446
|
|
|
447
|
+
let checklistConfigDetails = await checklistService.findOne( { _id: checklistDetails.sourceCheckList_id }, { redoValidity: 1 } );
|
|
445
448
|
|
|
446
449
|
let sectionIndex = question.findIndex( ( sec ) => sec.sectionName == req.body.payload.sectionName );
|
|
447
450
|
if ( sectionIndex == -1 ) {
|
|
@@ -450,38 +453,100 @@ export async function redoChecklist( req, res ) {
|
|
|
450
453
|
|
|
451
454
|
let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.payload.qno );
|
|
452
455
|
|
|
453
|
-
let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
456
|
+
let data = { ...question[sectionIndex].questions[findQuestion], redo: true, ...( !req.body.payload?.answerIndex && { redoComment: req.body.payload?.checklistDescription || '' } ) };
|
|
457
|
+
let answerIndex = req.body.payload?.answerIndex;
|
|
458
|
+
let isSingleAnswerRedo = answerIndex != null;
|
|
459
|
+
|
|
460
|
+
if ( !isSingleAnswerRedo ) {
|
|
461
|
+
// if ( checklistDetails.client_id == '458' ) {
|
|
462
|
+
data.answers.forEach( ( item ) => {
|
|
463
|
+
if ( item.showLinked ) {
|
|
464
|
+
item.nestedQuestion.forEach( ( ele ) => {
|
|
465
|
+
let eleIndex = question[sectionIndex].questions.findIndex( ( qn ) => qn.qno == parseInt( ele ) );
|
|
466
|
+
let element = { ...question[sectionIndex].questions[eleIndex], redo: true, redoComment: '', linkquestionenabled: false };
|
|
467
|
+
question[sectionIndex].questions[eleIndex] = element;
|
|
468
|
+
if ( Array.isArray( question?.[sectionIndex]?.questions?.[eleIndex]?.answers )?.length ) {
|
|
469
|
+
question[sectionIndex].questions[eleIndex].answers.forEach( ( ans ) => {
|
|
470
|
+
ans.validationAnswer = '';
|
|
471
|
+
delete ans.redoComment;
|
|
472
|
+
delete ans.redo;
|
|
473
|
+
} );
|
|
474
|
+
}
|
|
475
|
+
question[sectionIndex].questions[eleIndex].userAnswer = [];
|
|
476
|
+
question[sectionIndex].questions[eleIndex].remarks = '';
|
|
477
|
+
} );
|
|
478
|
+
}
|
|
479
|
+
} );
|
|
480
|
+
// data.answers.forEach( ( item ) => {
|
|
481
|
+
// if ( item.showLinked ) {
|
|
482
|
+
// item.nestedQuestion = [];
|
|
483
|
+
// item.showLinked = false;
|
|
484
|
+
// item.linkedQuestion = 0;
|
|
485
|
+
// }
|
|
486
|
+
// } );
|
|
487
|
+
// }
|
|
488
|
+
}
|
|
489
|
+
let userAnswer = Array.isArray( data.userAnswer ) ? [ ...data.userAnswer ] : [];
|
|
490
|
+
|
|
491
|
+
question[sectionIndex].questions[findQuestion] = data;
|
|
492
|
+
if ( isSingleAnswerRedo ) {
|
|
493
|
+
let targetQuestion = question[sectionIndex].questions[findQuestion];
|
|
494
|
+
let targetUserAnswerIndex = targetQuestion.userAnswer?.findIndex( ( ele ) => ele.answer == req.body.payload.answerName );
|
|
495
|
+
let targetUserAnswer = targetQuestion.userAnswer[targetUserAnswerIndex];
|
|
496
|
+
if ( targetUserAnswer && Array.isArray( targetQuestion.answers ) ) {
|
|
497
|
+
let matchedAnsIdx = targetQuestion.answers.findIndex( ( ans ) => {
|
|
498
|
+
// if ( targetUserAnswer.no !== undefined && ans.index === targetUserAnswer.no ) return true;
|
|
499
|
+
// if ( targetUserAnswer.index !== undefined && ans.index === targetUserAnswer.index ) return true;
|
|
500
|
+
// if ( targetUserAnswer.answeroptionNumber !== undefined && ans.answeroptionNumber === targetUserAnswer.answeroptionNumber ) return true;
|
|
501
|
+
return ans.answer === targetUserAnswer.answer;
|
|
463
502
|
} );
|
|
503
|
+
if ( matchedAnsIdx !== -1 ) {
|
|
504
|
+
targetQuestion.answers[matchedAnsIdx].redo = true;
|
|
505
|
+
targetQuestion.answers[matchedAnsIdx].validationAnswer = '';
|
|
506
|
+
targetQuestion.answers[matchedAnsIdx].redoComment = req.body.payload?.checklistDescription || '';
|
|
507
|
+
targetQuestion.remarks = '';
|
|
508
|
+
}
|
|
509
|
+
targetQuestion.userAnswer.splice( targetUserAnswerIndex, 1 );
|
|
464
510
|
}
|
|
465
|
-
} );
|
|
466
|
-
// data.answers.forEach( ( item ) => {
|
|
467
|
-
// if ( item.showLinked ) {
|
|
468
|
-
// item.nestedQuestion = [];
|
|
469
|
-
// item.showLinked = false;
|
|
470
|
-
// item.linkedQuestion = 0;
|
|
471
|
-
// }
|
|
472
|
-
// } );
|
|
473
|
-
// }
|
|
474
|
-
let userAnswer = data.userAnswer;
|
|
475
511
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
512
|
+
let currentQno = req.body.payload.qno;
|
|
513
|
+
let parentQIndex = -1;
|
|
514
|
+
// let parentAnsIndex = -1;
|
|
515
|
+
for ( let i = 0; i < question[sectionIndex].questions.length; i++ ) {
|
|
516
|
+
let parentAnswers = question[sectionIndex].questions[i].answers || [];
|
|
517
|
+
let foundAnsIdx = parentAnswers.findIndex( ( ans ) => Array.isArray( ans?.nestedQuestion ) && ans.nestedQuestion.some( ( ele ) => parseInt( ele ) == currentQno ) );
|
|
518
|
+
if ( foundAnsIdx !== -1 ) {
|
|
519
|
+
parentQIndex = i;
|
|
520
|
+
// parentAnsIndex = foundAnsIdx;
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if ( parentQIndex !== -1 ) {
|
|
525
|
+
let parentQno = question[sectionIndex].questions[parentQIndex].qno;
|
|
526
|
+
question[sectionIndex].questions[findQuestion].parentQno = parentQno;
|
|
527
|
+
// question[sectionIndex].questions[findQuestion].remarks = '';
|
|
528
|
+
// question[sectionIndex].questions[parentQIndex].answers[parentAnsIndex].redo = true;
|
|
529
|
+
// question[sectionIndex].questions[parentQIndex].answers[parentAnsIndex].validationAnswer = '';
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
question[sectionIndex].questions[findQuestion].userAnswer = [];
|
|
533
|
+
if ( Array.isArray( question[sectionIndex].questions[findQuestion].answers ) ) {
|
|
534
|
+
question[sectionIndex].questions[findQuestion].answers.forEach( ( ans ) => {
|
|
535
|
+
ans.validationAnswer = '';
|
|
536
|
+
delete ans.redoComment;
|
|
537
|
+
delete ans.redo;
|
|
538
|
+
} );
|
|
539
|
+
}
|
|
540
|
+
question[sectionIndex].questions[findQuestion].remarks = '';
|
|
541
|
+
}
|
|
479
542
|
checklistDetails.questionAnswers = question;
|
|
480
543
|
let updateData = {
|
|
481
|
-
checklistStatus: 'open',
|
|
544
|
+
checklistStatus: checklistDetails.checklistStatus != 'submit' ? checklistDetails.checklistStatus : 'open',
|
|
482
545
|
redoStatus: true,
|
|
483
|
-
reinitiateStatus: true,
|
|
546
|
+
...( !checklistConfigDetails?.redoValidity && { reinitiateStatus: true } ),
|
|
484
547
|
questionAnswers: question,
|
|
548
|
+
...( checklistDetails.checklistStatus != 'submit' && checklistDetails.redoStatus ) ? { redoEdit: true } : {},
|
|
549
|
+
...( ( checklistDetails.redoEdit === undefined && checklistConfigDetails.redoValidity ) && { scheduleEndTime_iso: dayjs( checklistDetails.scheduleEndTime_iso ).add( checklistConfigDetails.redoValidity, 'day' ).format() } ),
|
|
485
550
|
};
|
|
486
551
|
|
|
487
552
|
let response = await processedChecklist.updateOne( { _id: req.body.payload._id }, updateData );
|
|
@@ -740,9 +805,8 @@ export async function getLogs( req, res ) {
|
|
|
740
805
|
let initiatedstatus = {
|
|
741
806
|
actionType: 'initation',
|
|
742
807
|
userName: data.initiatedBy,
|
|
743
|
-
Timestamp: data.initiatedTime,
|
|
808
|
+
Timestamp: dayjs.utc( data.initiatedTime ),
|
|
744
809
|
description: data.checklistDescription,
|
|
745
|
-
|
|
746
810
|
};
|
|
747
811
|
response.push( initiatedstatus );
|
|
748
812
|
response.push( userAnswer );
|