tango-app-api-trax 3.7.67 → 3.7.69

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.7.67",
3
+ "version": "3.7.69",
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.63",
32
+ "tango-api-schema": "^2.5.64",
33
33
  "tango-app-api-middleware": "^3.5.2",
34
34
  "url": "^0.11.4",
35
35
  "winston": "^3.13.1",
@@ -1363,6 +1363,43 @@ export async function insertTimeDelayFlags( req, res ) {
1363
1363
 
1364
1364
  let updatedDetails = await processedchecklist.updateMany( { _id: { $in: checklistId } }, { timeFlag: 1 } );
1365
1365
 
1366
+
1367
+ let notifyStores = await processedchecklist.find( { _id: { $in: checklistId }, notify: { $exists: false } } );
1368
+
1369
+ if ( notifyStores.length ) {
1370
+ Promise.all( notifyStores.map( async ( store ) => {
1371
+ let checklistDetails = await checklistService.findOne( { _id: store.sourceCheckList_id }, { notifyFlags: 1, approver: 1 } );
1372
+ if ( checklistDetails?.notifyFlags?.notifyType?.length ) {
1373
+ let emailList = checklistDetails?.notifyFlags?.notifyType.includes( 'approver' ) ? checklistDetails.approver.map( ( ele ) => ele?.value ): [];
1374
+ emailList = [ ...emailList, ...checklistDetails?.notifyFlags?.users?.map( ( ele ) => ele?.value ) ];
1375
+ let data = {
1376
+ storeName: store.storeName,
1377
+ flagCount: 1,
1378
+ checklistName: store.checkListName?.trim(),
1379
+ submittedBy: '--',
1380
+ time: '--',
1381
+ domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,
1382
+ type: 'delay',
1383
+ answerType: [ 'yes/no', 'descriptive', 'multiplechoicesingle', 'multiplechoicemultiple', 'dropdown' ],
1384
+ };
1385
+ const fileContent = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/flag.hbs', 'utf8' );
1386
+ const htmlContent = handlebars.compile( fileContent );
1387
+ const html = htmlContent( { data: data } );
1388
+ emailList.forEach( ( email ) => {
1389
+ let params = {
1390
+ toEmail: email,
1391
+ mailSubject: 'TangoEye | Checklist Flag',
1392
+ htmlBody: html,
1393
+ attachment: '',
1394
+ sourceEmail: JSON.parse( process.env.SES ).adminEmail,
1395
+ };
1396
+ sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
1397
+ } );
1398
+ }
1399
+ await processedchecklist.updateOne( { _id: store._id }, { notify: true } );
1400
+ } ) );
1401
+ }
1402
+
1366
1403
  if ( updatedDetails ) {
1367
1404
  return res.sendSuccess( { message: 'Time Delay Updated Successfully' } );
1368
1405
  }
@@ -2023,7 +2023,7 @@ export async function submitChecklist( req, res ) {
2023
2023
  let data = {
2024
2024
  storeName: getchecklist[0].storeName,
2025
2025
  flagCount: updateData.questionFlag,
2026
- checklistName: getchecklist[0].checkListName,
2026
+ checklistName: getchecklist[0].checkListName?.trim(),
2027
2027
  submittedBy: getchecklist[0].userName,
2028
2028
  time: updateData.submitMobileTime,
2029
2029
  domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,