tango-app-api-trax 3.3.1-hotfix-9 → 3.4.0-alpha-0
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/gallery.controller.js +123 -1
- package/src/controllers/internalTrax.controller.js +0 -48
- package/src/controllers/trax.controller.js +3 -6
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/gallery.routes.js +2 -1
- package/src/routes/internalTraxApi.router.js +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-alpha-0",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
29
|
"tango-api-schema": "^2.2.70",
|
|
30
|
-
"tango-app-api-middleware": "^3.1.
|
|
30
|
+
"tango-app-api-middleware": "^3.1.55",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
33
33
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -429,7 +429,7 @@ export async function redoChecklist( req, res ) {
|
|
|
429
429
|
submitTime: checklistDetails.submitTime,
|
|
430
430
|
};
|
|
431
431
|
await checklistLogs.create( data );
|
|
432
|
-
|
|
432
|
+
console.log( req.body );
|
|
433
433
|
const requestOptions = {
|
|
434
434
|
method: 'POST',
|
|
435
435
|
headers: {
|
|
@@ -454,6 +454,128 @@ export async function redoChecklist( req, res ) {
|
|
|
454
454
|
return res.sendError( e, 500 );
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
|
+
export async function redomultiChecklist( req, res ) {
|
|
458
|
+
try {
|
|
459
|
+
let inputData = req.body.payload.coverage==='user'?req.body.payload.userEmail:req.body.payload.storeName;
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
for ( let originalData of inputData ) {
|
|
463
|
+
if ( !originalData.checklistId ) {
|
|
464
|
+
return res.sendError( 'Id is Required', 400 );
|
|
465
|
+
}
|
|
466
|
+
if ( !originalData.section_id ) {
|
|
467
|
+
return res.sendError( 'Section id is Required', 400 );
|
|
468
|
+
}
|
|
469
|
+
if ( !req.body.payload.qno ) {
|
|
470
|
+
return res.sendError( 'Question number is Required', 400 );
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
let checklistDetails = await processedChecklist.findOne( { _id: originalData.checklistId }, { 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 } );
|
|
475
|
+
if ( !checklistDetails ) {
|
|
476
|
+
return res.sendError( 'No data found', 204 );
|
|
477
|
+
}
|
|
478
|
+
let question = checklistDetails.questionAnswers;
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
let sectionIndex = question.findIndex( ( sec ) => sec.sectionName == req.body.payload.sectionName );
|
|
482
|
+
if ( sectionIndex == -1 ) {
|
|
483
|
+
return res.sendError( 'section is not found', 400 );
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.payload.qno );
|
|
487
|
+
|
|
488
|
+
let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
|
|
489
|
+
// if ( checklistDetails.client_id == '458' ) {
|
|
490
|
+
data.answers.forEach( ( item ) => {
|
|
491
|
+
if ( item.showLinked ) {
|
|
492
|
+
item.nestedQuestion.forEach( ( ele ) => {
|
|
493
|
+
let eleIndex = question[sectionIndex].questions.findIndex( ( qn ) => qn.qno == parseInt( ele ) );
|
|
494
|
+
let element = { ...question[sectionIndex].questions[eleIndex], redo: true, redoComment: '', linkquestionenabled: false };
|
|
495
|
+
question[sectionIndex].questions[eleIndex] = element;
|
|
496
|
+
question[sectionIndex].questions[eleIndex].userAnswer = [];
|
|
497
|
+
question[sectionIndex].questions[eleIndex].remarks = '';
|
|
498
|
+
} );
|
|
499
|
+
}
|
|
500
|
+
} );
|
|
501
|
+
// data.answers.forEach( ( item ) => {
|
|
502
|
+
// if ( item.showLinked ) {
|
|
503
|
+
// item.nestedQuestion = [];
|
|
504
|
+
// item.showLinked = false;
|
|
505
|
+
// item.linkedQuestion = 0;
|
|
506
|
+
// }
|
|
507
|
+
// } );
|
|
508
|
+
// }
|
|
509
|
+
let userAnswer = data.userAnswer;
|
|
510
|
+
|
|
511
|
+
question[sectionIndex].questions[findQuestion] = data;
|
|
512
|
+
question[sectionIndex].questions[findQuestion].userAnswer = [];
|
|
513
|
+
question[sectionIndex].questions[findQuestion].remarks = '';
|
|
514
|
+
checklistDetails.questionAnswers = question;
|
|
515
|
+
let updateData = {
|
|
516
|
+
checklistStatus: 'open',
|
|
517
|
+
redoStatus: true,
|
|
518
|
+
reinitiateStatus: true,
|
|
519
|
+
questionAnswers: question,
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
let response = await processedChecklist.updateOne( { _id: originalData.checklistId }, updateData );
|
|
523
|
+
console.log( response );
|
|
524
|
+
if ( response.modifiedCount || response.matchedCount ) {
|
|
525
|
+
let storeTimeZone = await storeService.findOne( { storeName: checklistDetails.storeName }, { 'storeProfile.timeZone': 1 } );
|
|
526
|
+
let currentDateTime;
|
|
527
|
+
if ( storeTimeZone?.storeProfile?.timeZone ) {
|
|
528
|
+
currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
|
|
529
|
+
} else {
|
|
530
|
+
currentDateTime = dayjs();
|
|
531
|
+
}
|
|
532
|
+
data = {
|
|
533
|
+
checklistId: checklistDetails.sourceCheckList_id,
|
|
534
|
+
checkListName: checklistDetails.checkListName,
|
|
535
|
+
checklistDescription: req.body.payload.checklistDescription,
|
|
536
|
+
sectionId: originalData.section_id,
|
|
537
|
+
sectionName: question[sectionIndex].sectionName,
|
|
538
|
+
questionName: question[sectionIndex].questions[findQuestion].qname,
|
|
539
|
+
action: 'redo',
|
|
540
|
+
store_id: checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
541
|
+
storeName: checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
542
|
+
client_id: checklistDetails.client_id,
|
|
543
|
+
processedChecklistId: checklistDetails._id,
|
|
544
|
+
type: checklistDetails.checkListType,
|
|
545
|
+
userAnswer: userAnswer,
|
|
546
|
+
initiatedBy: req.user.userName,
|
|
547
|
+
initiatedTime: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
|
|
548
|
+
answerType: question[sectionIndex].questions[findQuestion].answerType,
|
|
549
|
+
submitedBy: checklistDetails.userName,
|
|
550
|
+
submitTime: checklistDetails.submitTime,
|
|
551
|
+
};
|
|
552
|
+
await checklistLogs.create( data );
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
req.body.payload._id=originalData.checklistId;
|
|
556
|
+
req.body.payload.section_id=originalData.section_id;
|
|
557
|
+
req.body.payload.uniqueNo=originalData.uniqueNo;
|
|
558
|
+
console.log( req.body );
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
const requestOptions = {
|
|
562
|
+
method: 'POST',
|
|
563
|
+
headers: {
|
|
564
|
+
'Content-Type': 'application/json',
|
|
565
|
+
},
|
|
566
|
+
body: JSON.stringify( req.body ),
|
|
567
|
+
};
|
|
568
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
569
|
+
let searchResponse = await fetch( url.redoChecklist, requestOptions );
|
|
570
|
+
console.log( searchResponse.ok );
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return res.sendSuccess( 'Question redo successfully' );
|
|
574
|
+
} catch ( e ) {
|
|
575
|
+
logger.error( { function: 'redomultiChecklist', error: e } );
|
|
576
|
+
return res.sendError( e, 500 );
|
|
577
|
+
}
|
|
578
|
+
}
|
|
457
579
|
|
|
458
580
|
|
|
459
581
|
export async function getLogs( req, res ) {
|
|
@@ -1644,51 +1644,3 @@ async function getUserToken( clientId, userEmail ) {
|
|
|
1644
1644
|
return false;
|
|
1645
1645
|
}
|
|
1646
1646
|
}
|
|
1647
|
-
|
|
1648
|
-
export async function internalAISendPushNotification( req, res ) {
|
|
1649
|
-
try {
|
|
1650
|
-
let requestData = req.body;
|
|
1651
|
-
if ( !requestData.clientId ) {
|
|
1652
|
-
return res.sendError( 'clientId is Required', 400 );
|
|
1653
|
-
}
|
|
1654
|
-
if ( !( requestData?.email || requestData?.storeId ) ) {
|
|
1655
|
-
return res.sendError( 'Email or StoreId is Required', 400 );
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
if ( !requestData.title ) {
|
|
1659
|
-
return res.sendError( 'Title is Required', 400 );
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
if ( !requestData.description ) {
|
|
1663
|
-
return res.sendError( 'Description is Required', 400 );
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
let fcmToken;
|
|
1667
|
-
if ( requestData.email && requestData.email !='' ) {
|
|
1668
|
-
fcmToken = await getUserToken( requestData.clientId, requestData.email );
|
|
1669
|
-
} else {
|
|
1670
|
-
let storeData = await storeService.findOne( { clientId: requestData.clientId, storeId: requestData.storeId }, { spocDetails: 1 } );
|
|
1671
|
-
if ( storeData && storeData.spocDetails.length > 0 && storeData.spocDetails[0].email ) {
|
|
1672
|
-
fcmToken = await getUserToken( storeData.spocDetails[0].email );
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
if ( !fcmToken ) {
|
|
1676
|
-
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1677
|
-
}
|
|
1678
|
-
let custom = {
|
|
1679
|
-
type: req.body?.type,
|
|
1680
|
-
storeId: req.body?.storeId,
|
|
1681
|
-
date: req.body?.date,
|
|
1682
|
-
};
|
|
1683
|
-
let responseData = await sendPushNotification( requestData.title, requestData.description, fcmToken, custom );
|
|
1684
|
-
if ( responseData ) {
|
|
1685
|
-
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1686
|
-
} else {
|
|
1687
|
-
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1688
|
-
}
|
|
1689
|
-
} catch ( e ) {
|
|
1690
|
-
logger.error( { error: e, function: 'internalAISendPushNotification' } );
|
|
1691
|
-
if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
|
|
1692
|
-
else res.sendError( e, 500 );
|
|
1693
|
-
}
|
|
1694
|
-
};
|
|
@@ -1465,12 +1465,9 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1465
1465
|
if ( !checklistDetails ) {
|
|
1466
1466
|
return res.sendError( 'no data found', 204 );
|
|
1467
1467
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
} else {
|
|
1472
|
-
currentDate = dayjs().format();
|
|
1473
|
-
}
|
|
1468
|
+
|
|
1469
|
+
let currentDate = dayjs().format( 'HH:mm:ss' );
|
|
1470
|
+
currentDate = dayjs.utc( currentDate, 'HH:mm:ss' ).format();
|
|
1474
1471
|
let updatedscheduleEndTimeISO = dayjs.utc( inputBody?.checkListDetails?.scheduleEndTime, 'hh:mm A' ).format( 'HH:mm:ss' );
|
|
1475
1472
|
let newUpdatedDate = dayjs.utc( updatedscheduleEndTimeISO, 'HH:mm:ss' ).format();
|
|
1476
1473
|
|