tango-app-api-trax 3.8.11-nike → 3.8.12

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.8.11-nike",
3
+ "version": "3.8.12",
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.83",
32
+ "tango-api-schema": "^2.5.72",
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
- // const zipName = `${sanitizeFilenamePart( zipBaseName, 'visit-checklists' )}_${dayjs().format( 'YYYY-MM-DD_HH-mm' )}.zip`;
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
- // 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' );
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
- // const archive = archiver( 'zip', { zlib: { level: 9 } } );
64
+ const archive = archiver( 'zip', { zlib: { level: 9 } } );
65
65
 
66
- // archive.on( 'error', ( err ) => {
67
- // throw err;
68
- // } );
66
+ archive.on( 'error', ( err ) => {
67
+ throw err;
68
+ } );
69
69
 
70
- // archive.pipe( res );
70
+ archive.pipe( res );
71
71
 
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
- // }
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
- // await archive.finalize();
80
- // }
79
+ await archive.finalize();
80
+ }
81
81
 
82
82
  async function createChecklistZipBuffer( checklistList, brandInfo ) {
83
83
  const output = new PassThrough();
@@ -139,7 +139,6 @@ 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 );
143
142
  if ( resultData ) {
144
143
  if ( resultData.status_code == '200' ) {
145
144
  return res.sendSuccess( resultData );
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-invalid-this */
2
1
  import Handlebars from 'handlebars';
3
2
  import fs from 'fs';
4
3
 
@@ -323,7 +323,7 @@ export async function PCLconfigCreation( req, res ) {
323
323
  },
324
324
  } );
325
325
  let getSections = await CLquestions.aggregate( sectionQuery );
326
- if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'storehygienemonitoring', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) {
326
+ if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'storehygienemonitoring' ].includes( getCLconfig.checkListType ) ) {
327
327
  if ( getSections.length ) {
328
328
  for ( let element3 of getSections ) {
329
329
  let collectQuestions = {};
@@ -648,11 +648,11 @@ export async function PCLconfigCreation( req, res ) {
648
648
  // }
649
649
  }
650
650
  } else {
651
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) {
651
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
652
652
  let storeNameList = allQuestion.map( ( item ) => item.store_id );
653
- let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
653
+ let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
654
654
  let storeList = storeDetails.map( ( store ) => store.storeId );
655
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) {
655
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
656
656
  allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
657
657
  } else {
658
658
  allQuestion = storeDetails.map( ( item ) => {
@@ -686,7 +686,7 @@ export async function PCLconfigCreation( req, res ) {
686
686
  client_id: getCLconfig.client_id,
687
687
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
688
688
  };
689
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) {
689
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
690
690
  let processData = {
691
691
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
692
692
  return { storeName: store.storeName, storeId: store.store_id, events: store.events };
@@ -927,7 +927,7 @@ async function insertData( requestData ) {
927
927
  },
928
928
  } );
929
929
  let getSections = await CLquestions.aggregate( sectionQuery );
930
- if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) {
930
+ if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
931
931
  if ( getSections.length ) {
932
932
  for ( let element3 of getSections ) {
933
933
  let collectQuestions = {};
@@ -1222,11 +1222,11 @@ async function insertData( requestData ) {
1222
1222
  // }
1223
1223
  }
1224
1224
  } else {
1225
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) {
1225
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
1226
1226
  let storeNameList = allQuestion.map( ( item ) => item.store_id );
1227
- let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
1227
+ let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
1228
1228
  let storeList = storeDetails.map( ( store ) => store.storeId );
1229
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) {
1229
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
1230
1230
  allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
1231
1231
  } else {
1232
1232
  allQuestion = storeDetails.map( ( item ) => {
@@ -1260,7 +1260,7 @@ async function insertData( requestData ) {
1260
1260
  client_id: getCLconfig.client_id,
1261
1261
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
1262
1262
  };
1263
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( getCLconfig.checkListType ) ) {
1263
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
1264
1264
  let processData = {
1265
1265
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
1266
1266
  return { storeName: store.storeName, storeId: store.store_id, events: store.events };
@@ -1250,6 +1250,21 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1250
1250
  }
1251
1251
  }
1252
1252
  } else {
1253
+ if ( qaans[k].validationType == 'Capture Multiple Image with description' ) {
1254
+ qaans[k]['validationImage']=[];
1255
+ if ( requestSection[i].validationImage.length ) {
1256
+ for ( let image of requestSection[i].validationImage ) {
1257
+ let validationAnswer = decodeURIComponent( image.split( '?' )[0] );
1258
+ if ( validationAnswer.length ) {
1259
+ let splitImgUrl = validationAnswer.split( '/' );
1260
+ if ( splitImgUrl.length > 1 ) {
1261
+ splitImgUrl.splice( 0, 3 );
1262
+ qaans[k].validationImage.push( splitImgUrl.join( '/' ) || '' );
1263
+ }
1264
+ };
1265
+ }
1266
+ }
1267
+ }
1253
1268
  // qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
1254
1269
  qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
1255
1270
  }
@@ -2325,6 +2340,9 @@ export async function submitTask( req, res ) {
2325
2340
  insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
2326
2341
  if ( submittype === 'submit' ) {
2327
2342
  const excludedChecklists = [ 'Store Hygiene Check' ];
2343
+ if ( checklist.checkListName.includes( 'Store Hygiene' ) ) {
2344
+
2345
+ }
2328
2346
  if ( !excludedChecklists.includes( checklist.checkListName ) ) {
2329
2347
  const query1 = [
2330
2348
  {
@@ -3523,6 +3541,13 @@ export async function questionList( req, res ) {
3523
3541
  if ( ( userAns.validationType == 'Capture Image' || userAns.validationType == 'Capture Video' ) && userAns.validationAnswer && userAns.validationAnswer != '' ) {
3524
3542
  getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer = await signedUrl( { file_path: decodeURIComponent( userAns.validationAnswer ), Bucket: bucket.sop } );
3525
3543
  }
3544
+ if ( userAns.validationType == 'Capture Multiple Image with description' ) {
3545
+ let imageAnswers = userAns.validationImage;
3546
+ userAns.validationImage = [];
3547
+ for ( let image of imageAnswers ) {
3548
+ getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationImage.push( await signedUrl( { file_path: decodeURIComponent( image ), Bucket: bucket.sop } ) );
3549
+ }
3550
+ }
3526
3551
  if ( [ 'image', 'descriptiveImage', 'video' ].includes( question.answerType ) && userAns.answer != '' ) {
3527
3552
  getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
3528
3553
  }
@@ -4771,6 +4796,9 @@ export async function downloadChecklist( req, res ) {
4771
4796
  if ( [ 'Capture Image', 'Capture Video' ].includes( answer.validationType ) && answer?.validationAnswer?.trim() ) {
4772
4797
  answer.validationAnswer = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN+answer.validationAnswer;
4773
4798
  }
4799
+ if ( [ 'Capture Multiple Image with description' ].includes( answer.validationType ) && answer?.validationImage?.length() ) {
4800
+ answer.validationImage = answer?.validationImage?.map( ( ele ) => JSON.parse( process.env.CDNURL )?.TraxAnswerCDN+answer.ele );
4801
+ }
4774
4802
  if ( answer?.answer?.trim() && [ 'image', 'descriptiveImage', 'multipleImage', 'image/video', 'video' ].includes( question.answerType ) ) {
4775
4803
  answer.answer = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN+answer.answer;
4776
4804
  }
@@ -608,7 +608,7 @@ export const flagCardsV1 = async ( req, res ) => {
608
608
  {
609
609
  client_id: clientId,
610
610
  publish: true,
611
- checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ] },
611
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] },
612
612
  },
613
613
  { checkListType: 1 },
614
614
  );
@@ -2743,7 +2743,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
2743
2743
  $or: [
2744
2744
  { questionFlag: { $gte: 1 } },
2745
2745
  { timeFlag: { $gte: 1 } },
2746
- { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ] } },
2746
+ { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } },
2747
2747
  {
2748
2748
  runAIQuestionCount: { $gte: 1 },
2749
2749
  },
@@ -2945,7 +2945,7 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2945
2945
  {
2946
2946
  client_id: requestData.clientId,
2947
2947
  publish: true,
2948
- checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ] },
2948
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] },
2949
2949
  },
2950
2950
  { checkListType: 1 },
2951
2951
  );
@@ -3047,7 +3047,7 @@ export const flagTablesV2 = async ( req, res ) => {
3047
3047
  }
3048
3048
 
3049
3049
  if ( requestData?.filter === 'all' ) {
3050
- findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ] } } ] } );
3050
+ findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } } ] } );
3051
3051
  } else if ( requestData?.filter === 'question' ) {
3052
3052
  findAndQuery.push( { checkListType: 'custom' } );
3053
3053
  findAndQuery.push( { questionFlag: { $gte: 1 } } );
@@ -3055,7 +3055,7 @@ export const flagTablesV2 = async ( req, res ) => {
3055
3055
  findAndQuery.push( { checkListType: 'custom' } );
3056
3056
  findAndQuery.push( { timeFlag: { $gte: 1 } } );
3057
3057
  } else if ( requestData?.filter === 'detection' ) {
3058
- findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ] } } );
3058
+ findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } } );
3059
3059
  } else if ( requestData?.filter === 'runAI' ) {
3060
3060
  if ( req.body.runAIChecklistName ) {
3061
3061
  findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
@@ -1668,6 +1668,10 @@ export const updateConfigure = async ( req, res ) => {
1668
1668
  return res.sendError( 'no data found', 204 );
1669
1669
  }
1670
1670
 
1671
+ if ( inputBody.submitType == 'publish' && checklistDetails.checkListType == 'custom' && !checklistDetails.questionCount ) {
1672
+ return res.sendError( 'Question is required', 400 );
1673
+ }
1674
+
1671
1675
  let currentDate = dayjs.utc().format();
1672
1676
  let updatedscheduleEndTimeISO = dayjs.utc( inputBody?.checkListDetails?.scheduleEndTime, 'hh:mm A' ).format( 'HH:mm:ss' );
1673
1677
  let newUpdatedDate = dayjs.utc( updatedscheduleEndTimeISO, 'HH:mm:ss' ).format();
@@ -1958,6 +1962,9 @@ export const updateConfigurev1 = async ( req, res ) => {
1958
1962
  if ( !checklistDetails ) {
1959
1963
  return res.sendError( 'no data found', 204 );
1960
1964
  }
1965
+ if ( inputBody.submitType == 'publish' && checklistDetails.checkListType == 'custom' && !checklistDetails.questionCount ) {
1966
+ return res.sendError( 'Question is required', 400 );
1967
+ }
1961
1968
  let currentDate;
1962
1969
  if ( inputBody.timeZone ) {
1963
1970
  currentDate = dayjs().tz( inputBody.timeZone ).format();
@@ -2318,6 +2325,10 @@ export const updatePublish = async ( req, res ) => {
2318
2325
  return res.sendError( 'no data found', 204 );
2319
2326
  }
2320
2327
 
2328
+ if ( req?.body?.publish && getCheckDetails.checkListType == 'custom' && !getCheckDetails.questionCount ) {
2329
+ return res.sendError( 'Question is required', 400 );
2330
+ }
2331
+
2321
2332
  if ( getCheckDetails?.publishDate && getCheckDetails.checkListType == 'custom' ) {
2322
2333
  let date = dayjs();
2323
2334
  let diff = date.diff( dayjs.utc( getCheckDetails?.publishDate ), 'minutes' );
@@ -4116,7 +4127,7 @@ async function updateOpenSearch( user, data ) {
4116
4127
  export const aiChecklist = async ( req, res ) => {
4117
4128
  try {
4118
4129
  let storeDetails = await storeService.count( { clientId: req.query.clientId, status: 'active' } );
4119
- let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ];
4130
+ let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ];
4120
4131
  let checklistDetails = [];
4121
4132
  let publishList = [];
4122
4133
  let unpublishList = [];
@@ -4129,7 +4140,7 @@ export const aiChecklist = async ( req, res ) => {
4129
4140
  checklistDetails = [ ...publishList, ...unpublishList ];
4130
4141
 
4131
4142
  checklistDetails.forEach( ( item ) => {
4132
- if ( ![ 'mobileusagedetection', 'storeopenandclose', 'cleaning', 'scrum', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping' ].includes( item.checkListType ) ) {
4143
+ if ( ![ 'mobileusagedetection', 'storeopenandclose', 'cleaning', 'scrum', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( item.checkListType ) ) {
4133
4144
  item.storeCount = storeDetails;
4134
4145
  }
4135
4146
  } );