tango-app-api-trax 3.3.1-hotfix-8 → 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
CHANGED
|
@@ -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 ) {
|
|
@@ -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
|
|