tango-app-api-trax 3.4.1-alpha-6 → 3.4.1-alpha-8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-trax",
3
- "version": "3.4.1-alpha-6",
3
+ "version": "3.4.1-alpha-8",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -284,8 +284,6 @@ export async function startChecklist( req, res ) {
284
284
  nesedQuestion.forEach( ( ele ) => {
285
285
  let nestedLinkqn = [];
286
286
  ele.answers.forEach( ( ans ) => {
287
- console.log( ans );
288
- console.log( ans.nestedQuestion );
289
287
  if ( ans.linkedQuestion ) {
290
288
  ans.nestedQuestion.forEach( ( nested, idx ) => {
291
289
  let findRandom = nesedQuestion.find( ( qn ) => qn.qno == nested && !nestedLinkqn.includes( qn.uniqueNo ) && !qn.updated );
@@ -311,6 +309,7 @@ export async function startChecklist( req, res ) {
311
309
  getchecklist[index].questionAnswers[secIndex].questions = questions;
312
310
  }
313
311
  }
312
+ await processedchecklist.updateOne( updateQuery, { questionAnswers: getchecklist[0].questionAnswers } );
314
313
  return res.sendSuccess( getchecklist );
315
314
  } else {
316
315
  return res.sendError( 'something went wrong please try again', 500 );
@@ -1111,17 +1110,16 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1111
1110
  let requestSection = reqAnswers.filter( ( item ) => item.section_id == section.id );
1112
1111
  for ( let i = 0; i < requestSection.length; i++ ) {
1113
1112
  for ( let j = 0; j < qaAnswers.length; j++ ) {
1114
- if ( ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) && ( !qaAnswers[j].uniqueqno || ( qaAnswers[j].uniqueqno && requestSection[i].uniqueqno == qaAnswers[j].uniqueqno ) ) ) {
1113
+ if ( ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) && ( !qaAnswers[j].uniqueNo || ( qaAnswers[j].uniqueNo && requestSection[i].uniqueNo == qaAnswers[j].uniqueNo ) ) ) {
1115
1114
  if ( qaAnswers[j].answerType == 'yes/no' ) {
1116
1115
  let qaans = qaAnswers[j].answers;
1117
1116
  let yn = [];
1118
1117
  for ( let k = 0; k < qaans.length; k++ ) {
1119
- console.log( typeof requestSection[i].questionAnswers == 'string' );
1120
- let requestAnswer = typeof requestSection[i].questionAnswers == 'string' ? JSON.parse( requestSection[i].questionAnswers ) : requestSection[i].questionAnswers;
1121
- let findAnswer= requestAnswer.find( ( ele ) => ele.answer == qaans[k].answer );
1122
- if ( findAnswer ) {
1123
- qaans[k].nestedQuestion = typeof findAnswer.nestedQuestion == 'string' ? JSON.parse( findAnswer.nestedQuestion ) : findAnswer.nestedQuestion;
1124
- }
1118
+ // let requestAnswer = typeof requestSection[i].questionAnswers == 'string' ? JSON.parse( requestSection[i].questionAnswers ) : requestSection[i].questionAnswers;
1119
+ // let findAnswer = requestAnswer.find( ( ele ) => ele.answer == qaans[k].answer && ele.);
1120
+ // if ( findAnswer ) {
1121
+ // qaans[k].nestedQuestion = typeof findAnswer.nestedQuestion == 'string' ? JSON.parse( findAnswer.nestedQuestion ) : findAnswer.nestedQuestion;
1122
+ // }
1125
1123
  if ( requestSection[i].answer == qaans[k].answer ) {
1126
1124
  if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
1127
1125
  if ( requestSection[i].validationAnswer ) {
@@ -1156,8 +1154,8 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1156
1154
  structure.parentanswer = requestSection[i].parentanswer;
1157
1155
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1158
1156
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1159
- structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1160
- qaAnswers[j].nestedQuestion = requestSection[i]?.nestedlinkedQuestion;
1157
+ structure.uniqueNo = qaAnswers[j].uniqueNo;
1158
+ // qaAnswers[j].nestedQuestion = requestSection[i]?.nestedlinkedQuestion;
1161
1159
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1162
1160
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1163
1161
  if ( qaAnswers[j]?.taskId ) {
@@ -1177,11 +1175,11 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1177
1175
  let qaans = qaAnswers[j].answers;
1178
1176
  let ms = [];
1179
1177
  for ( let k = 0; k < qaans.length; k++ ) {
1180
- let requestAnswer = typeof requestSection[i].questionAnswers == 'string' ? JSON.parse( requestSection[i].questionAnswers ) : requestSection[i].questionAnswers;
1181
- let findAnswer= requestAnswer.find( ( ele ) => ele.answer == qaans[k].answer );
1182
- if ( findAnswer ) {
1183
- qaans[k].nestedQuestion = typeof findAnswer.nestedQuestion == 'string' ? JSON.parse( findAnswer.nestedQuestion ) : findAnswer.nestedQuestion;
1184
- }
1178
+ // let requestAnswer = typeof requestSection[i].questionAnswers == 'string' ? JSON.parse( requestSection[i].questionAnswers ) : requestSection[i].questionAnswers;
1179
+ // let findAnswer= requestAnswer.find( ( ele ) => ele.answer == qaans[k].answer );
1180
+ // if ( findAnswer ) {
1181
+ // qaans[k].nestedQuestion = typeof findAnswer.nestedQuestion == 'string' ? JSON.parse( findAnswer.nestedQuestion ) : findAnswer.nestedQuestion;
1182
+ // }
1185
1183
  if ( requestSection[i].answer == qaans[k].answer ) {
1186
1184
  if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
1187
1185
  if ( requestSection[i].validationAnswer ) {
@@ -1216,8 +1214,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1216
1214
  structure.parentanswer = requestSection[i].parentanswer;
1217
1215
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1218
1216
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1219
- structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1220
- structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1217
+ structure.uniqueNo = qaAnswers[j].uniqueNo;
1218
+ // structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1219
+ // structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1221
1220
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1222
1221
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1223
1222
  if ( qaAnswers[j]?.taskId ) {
@@ -1275,10 +1274,11 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1275
1274
  structure.parentanswer = requestSection[i].parentanswer;
1276
1275
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1277
1276
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1277
+ structure.uniqueNo = qaAnswers[j].uniqueNo;
1278
1278
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1279
1279
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1280
- structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1281
- structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1280
+ // structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1281
+ // structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1282
1282
  if ( qaAnswers[j]?.taskId ) {
1283
1283
  structure.taskId = qaAnswers[j]?.taskId;
1284
1284
  structure.task = true;
@@ -1339,8 +1339,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1339
1339
  structure.parentanswer = requestSection[i].parentanswer;
1340
1340
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1341
1341
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1342
- structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1343
- structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1342
+ structure.uniqueNo = qaAnswers[j].uniqueNo;
1343
+ // structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1344
+ // structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1344
1345
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1345
1346
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1346
1347
  if ( qaAnswers[j]?.taskId ) {
@@ -1401,8 +1402,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1401
1402
  structure.parentanswer = requestSection[i].parentanswer;
1402
1403
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1403
1404
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1404
- structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1405
- structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1405
+ structure.uniqueNo = qaAnswers[j].uniqueNo;
1406
+ // structure.uniqueqno = parseInt( requestSection[i]?.uniqueqno );
1407
+ // structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1406
1408
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1407
1409
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1408
1410
  if ( qaAnswers[j]?.taskId ) {
@@ -2755,18 +2757,18 @@ export async function questionList( req, res ) {
2755
2757
  for ( let question of section.questions ) {
2756
2758
  let linkedQuestions;
2757
2759
  if ( !question.linkType ) {
2758
- if ( !question?.uniqueqno ) {
2760
+ if ( !question?.uniqueNo ) {
2759
2761
  question.uniqueNo = parseInt( getOtp() );
2760
2762
  }
2761
2763
  questions.push( question );
2762
2764
  linkedQuestions = [];
2763
2765
  let questionList;
2764
- if ( !question?.uniqueqno ) {
2766
+ if ( !question?.uniqueNo ) {
2765
2767
  questionList = new Map( section.questions.map( ( ele ) => [ ele.qno, ele ] ) );
2766
2768
  } else {
2767
2769
  let uniqueList = question.answers.flatMap( ( ele ) => ele.nestedQuestion );
2768
- let filteredQuestion = section.questions.filter( ( ele ) => uniqueList.includes( ele?.uniqueqno ) );
2769
- questionList = new Map( filteredQuestion.map( ( ele ) => [ ele.uniqueqno, ele ] ) );
2770
+ let filteredQuestion = section.questions.filter( ( ele ) => uniqueList.includes( ele?.uniqueNo ) );
2771
+ questionList = new Map( filteredQuestion.map( ( ele ) => [ ele.uniqueNo, ele ] ) );
2770
2772
  }
2771
2773
  question.answers.forEach( ( answer ) => {
2772
2774
  if ( answer.linkedQuestion ) {
@@ -2775,10 +2777,10 @@ export async function questionList( req, res ) {
2775
2777
  let getQn = questionList.get( qn );
2776
2778
  if ( getQn ) {
2777
2779
  let randomNo;
2778
- if ( !getQn?.uniqueqno ) {
2780
+ if ( !getQn?.uniqueNo ) {
2779
2781
  randomNo = parseInt( getOtp() );
2780
2782
  } else {
2781
- randomNo = getQn?.uniqueqno;
2783
+ randomNo = getQn?.uniqueNo;
2782
2784
  }
2783
2785
  getQn = JSON.parse( JSON.stringify( getQn ) );
2784
2786
  getQn = { ...getQn, uniqueNo: randomNo };
@@ -2794,7 +2796,7 @@ export async function questionList( req, res ) {
2794
2796
  ele.answers.forEach( ( ans ) => {
2795
2797
  if ( ans.linkedQuestion ) {
2796
2798
  ans.nestedQuestion.forEach( ( nested, idx ) => {
2797
- let findRandom = nesedQuestion.find( ( qn ) => ( !question?.uniqueqno ? qn.qno == nested : qn.uniqueNo == nested ) && !nestedLinkqn.includes( qn.uniqueNo ) && !qn.updated );
2799
+ let findRandom = nesedQuestion.find( ( qn ) => ( !question?.uniqueNo ? qn.qno == nested : qn.uniqueNo == nested ) && !nestedLinkqn.includes( qn.uniqueNo ) && !qn.updated );
2798
2800
  if ( findRandom ) {
2799
2801
  if ( ans.linkedQuestion == findRandom.qno ) {
2800
2802
  ans.linkedQuestion = findRandom.uniqueNo;
@@ -3566,11 +3568,19 @@ export async function updatePlanoStatus( req, res ) {
3566
3568
  if ( !processCheckDetails ) {
3567
3569
  return res.sendError( 'No data found', 204 );
3568
3570
  }
3569
- processCheckDetails.checklistStatus = req.body.status;
3570
- processCheckDetails.save();
3571
+ let storeTimeZone = await storeService.findOne( { storeName: { $regex: processCheckDetails.storeName, $options: 'i' }, clientId: processCheckDetails.client_id }, { 'storeProfile.timeZone': 1 } );
3572
+ let currentDateTime;
3573
+ if ( storeTimeZone?.storeProfile?.timeZone ) {
3574
+ currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
3575
+ } else {
3576
+ currentDateTime = requestData?.currentTime ? dayjs( requestData.currentTime, 'HH:mm:ss' ) : dayjs();
3577
+ }
3578
+ let submitTimeString = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
3579
+ await processedchecklist.updateOne( { _id: req.body.id }, { checklistStatus: req.body.status, ...( req.body.status == 'inprogress' ) ? { startTime_string: submitTimeString } : { submitTime_string: submitTimeString } } );
3571
3580
  return res.sendSuccess( 'Status updated Successfully' );
3572
3581
  } catch ( e ) {
3573
3582
  logger.error( { error: e, function: 'updatePlanoStatus' } );
3574
3583
  return res.sendError( e, 500 );
3575
3584
  }
3576
3585
  }
3586
+