tango-app-api-trax 3.7.58 → 3.7.60

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.58",
3
+ "version": "3.7.60",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3241,3 +3241,87 @@ export async function checklistTaskSubmissionDetails( req, res ) {
3241
3241
  return res.sendError( e, 500 );
3242
3242
  }
3243
3243
  }
3244
+
3245
+ export async function getStoreTaskDetails( req, res ) {
3246
+ try {
3247
+ const checklistQuery = [
3248
+ {
3249
+ $match: {
3250
+ storeName: req.body.storeName,
3251
+ checkListName: { $regex: 'Store Tour', $options: 'i' },
3252
+ },
3253
+ },
3254
+ {
3255
+ $group: {
3256
+ _id: '$storeName',
3257
+ checklistStatus: { $last: '$checklistStatus' },
3258
+ checkListName: { $last: '$checkListName' },
3259
+ scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
3260
+ },
3261
+ },
3262
+ ];
3263
+ const checkListDetails = await processedchecklist.aggregate( checklistQuery );
3264
+ const taskQuery = [
3265
+ {
3266
+ $match: {
3267
+ storeName: req.body.storeName,
3268
+ isPlano: true,
3269
+ planoType: { $in: [ 'fixture', 'merchRollout', 'vmRollout' ] },
3270
+ },
3271
+ },
3272
+ {
3273
+ $group: {
3274
+ _id: { store: '$storeName', type: '$planoType' },
3275
+ checklistStatus: { $last: '$checklistStatus' },
3276
+ checkListName: { $last: '$checkListName' },
3277
+ scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
3278
+ },
3279
+ },
3280
+ {
3281
+ $project: {
3282
+ store: '$_id.store',
3283
+ type: '$_id.type',
3284
+ checklistStatus: 1,
3285
+ checkListName: 1,
3286
+ scheduleEndTime_iso: 1,
3287
+ },
3288
+ },
3289
+ ];
3290
+
3291
+
3292
+ const taskDetails = await processedTaskService.aggregate( taskQuery );
3293
+ console.log( taskDetails );
3294
+ let info = [ ...checkListDetails, ...taskDetails ];
3295
+ // const details = {
3296
+ // storeTourVideoChecklist: ( !checkListDetails.length || checkListDetails?.[0]?.checklistStatus == 'submit' ) ? true : false,
3297
+ // FixtureVerification: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'fixture' ) || taskDetails?.some( ( ele ) => ele?.type == 'fixture' && ele?.checklistStatus == 'submit' ) ) ? true : false,
3298
+ // MerchRollout: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'merchRollout' ) || taskDetails?.some( ( ele ) => ele?.type == 'merchRollout' && ele?.checklistStatus == 'submit' ) ) ? true : false,
3299
+ // VmRollout: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'vmRollout' ) || taskDetails?.some( ( ele ) => ele?.type == 'vmRollout' && ele?.checklistStatus == 'submit' ) ) ? true : false,
3300
+ // };
3301
+
3302
+ let result = {
3303
+ storeId: req.body.storeName,
3304
+ tangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus != 'submit' && dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ) < dayjs().format( 'YYYY-MM-DD' ) ).map( ( ele ) => {
3305
+ return {
3306
+ blockName: ele?.checkListName,
3307
+ blockEnabled: true,
3308
+ blockReason: `${ele?.checkListName} is completed`,
3309
+ };
3310
+ } ),
3311
+ upcomingTangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus !== 'submit' ).map( ( ele ) => {
3312
+ return {
3313
+ blockName: ele?.checkListName,
3314
+ blockReason: `Compelete ${ele?.checkListName} before ${dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' )} to avoid ABC block`,
3315
+ dueDate: dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ),
3316
+ };
3317
+ } ),
3318
+ };
3319
+
3320
+
3321
+ return res.sendSuccess( result );
3322
+ } catch ( error ) {
3323
+ const err = error.message || 'Internal Server Error';
3324
+ logger.error( { error: error, message: req.body, function: 'getStoretaskDetails' } );
3325
+ return res.sendError( err, 500 );
3326
+ }
3327
+ }
@@ -29,11 +29,11 @@ import * as cameraService from '../services/camera.service.js';
29
29
  dayjs.extend( isSameOrBefore );
30
30
  import * as pdf from 'html-pdf';
31
31
  import handlebars from './handlebar-helper.js';
32
- import fs from 'fs';
33
- import { fileURLToPath } from 'url';
34
- import path from 'path';
35
- const __filename = fileURLToPath( import.meta.url );
36
- const __dirname = path.dirname( __filename );
32
+ // import fs from 'fs';
33
+ // import { fileURLToPath } from 'url';
34
+ // import path from 'path';
35
+ // const __filename = fileURLToPath( import.meta.url );
36
+ // const __dirname = path.dirname( __filename );
37
37
 
38
38
  export async function storeList( req, res ) {
39
39
  try {
@@ -667,10 +667,10 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
667
667
  // question.answers.forEach( ( answer ) => {
668
668
  let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
669
669
  if ( sectionQuestion.length ) {
670
- if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
670
+ if ( question.answerType == 'multiplechoicemultiple' || ( question.answerType =='dropdown' && question.allowMultiple ) && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
671
671
  validationCount++;
672
672
  } else {
673
- if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
673
+ if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( question.answerType =='dropdown' && !question.allowMultiple ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
674
674
  validationCount++;
675
675
  }
676
676
  }
@@ -2026,9 +2026,9 @@ export async function submitChecklist( req, res ) {
2026
2026
  time: updateData.submitMobileTime,
2027
2027
  domain: JSON.parse( process.env.URL ).domain,
2028
2028
  };
2029
- const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialExtentionEmail.hbs', 'utf8' );
2030
- const template = Handlebars.compile( templateHtml );
2031
- const html = template( { data: data } );
2029
+ const fileContent = readFileSync( join() + '/src/hbs/flag.hbs', 'utf8' );
2030
+ const htmlContent = handlebars.compile( fileContent );
2031
+ const html = htmlContent( { data: data } );
2032
2032
  emailList.forEach( ( email ) => {
2033
2033
  let params = {
2034
2034
  toEmail: email,
@@ -4579,55 +4579,45 @@ export async function downloadChecklist( req, res ) {
4579
4579
  Bucket: JSON.parse( process.env.BUCKET )?.assets,
4580
4580
  file_path: `${bucketpath}/${clientDetails?.profileDetails?.logo}`,
4581
4581
  };
4582
- let url = await signedUrl( params );
4583
- let brandImage = await convertUrltoBase64( url );
4582
+ let brandImage = await signedUrl( params );
4583
+ // let brandImage = await convertUrltoBase64( url );
4584
4584
  if ( brandImage ) {
4585
4585
  checklistDetails['brandLogo'] = brandImage;
4586
4586
  }
4587
4587
  }
4588
4588
  checklistDetails['brandName'] = clientDetails?.clientName;
4589
- for ( let section of checklistDetails.questionAnswers ) {
4590
- for ( let question of section.questions ) {
4589
+ checklistDetails.questionAnswers.forEach( ( section ) => {
4590
+ section.questions.forEach( ( question ) => {
4591
4591
  question.remarks = question.remarks == null || question.remarks == 'null' ? '' : question.remarks;
4592
- for ( let answer of question.userAnswer ) {
4592
+ question.userAnswer.forEach( ( answer ) => {
4593
4593
  if ( answer?.referenceImage?.trim() ) {
4594
- let inputData = {
4595
- Bucket: JSON.parse( process.env.BUCKET )?.sop,
4596
- file_path: answer.referenceImage,
4597
- };
4598
- let url = await signedUrl( inputData );
4599
- const base64Image = await convertUrltoBase64( url );
4600
- if ( base64Image ) {
4601
- answer.referenceImage = base64Image;
4602
- }
4594
+ answer.referenceImage = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.referenceImage;
4595
+ // const base64Image = await convertUrltoBase64( url );
4596
+ // if ( base64Image ) {
4597
+ // answer.referenceImage = base64Image;
4598
+ // }
4603
4599
  }
4604
4600
  if ( answer.validationType == 'Capture Image' && answer?.validationAnswer?.trim() ) {
4605
- let inputData = {
4606
- Bucket: JSON.parse( process.env.BUCKET )?.sop,
4607
- file_path: answer.validationAnswer,
4608
- };
4609
- let url = await signedUrl( inputData );
4610
- const base64Image = await convertUrltoBase64( url );
4611
- if ( base64Image ) {
4612
- answer.validationAnswer = base64Image;
4613
- }
4601
+ answer.validationAnswer = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.validationAnswer;
4602
+ // const base64Image = await convertUrltoBase64( url );
4603
+ // if ( base64Image ) {
4604
+ // answer.validationAnswer = base64Image;
4605
+ // }
4614
4606
  }
4615
4607
  if ( answer?.answer?.trim() && [ 'image', 'descriptiveImage', 'multipleImage', 'image/video' ].includes( question.answerType ) ) {
4616
- let inputData = {
4617
- Bucket: JSON.parse( process.env.BUCKET )?.sop,
4618
- file_path: answer.answer,
4619
- };
4620
- let url = await signedUrl( inputData );
4621
- const base64Image = await convertUrltoBase64( url );
4622
- if ( base64Image ) {
4623
- answer.answer = base64Image;
4608
+ answer.answer = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.answer;
4609
+ if ( question.answerType == 'multipleImage' ) {
4610
+ console.log( answer.answer );
4624
4611
  }
4612
+ // const base64Image = await convertUrltoBase64( url );
4613
+ // if ( base64Image ) {
4614
+ // answer.answer = base64Image;
4615
+ // }
4625
4616
  }
4626
- }
4627
- }
4628
- }
4629
- const targetFolder = path.join( __dirname, '..', '/hbs/template.hbs' );
4630
- const templateHtml = fs.readFileSync( targetFolder, 'utf8' );
4617
+ } );
4618
+ } );
4619
+ } );
4620
+ const templateHtml = readFileSync( join() + '/src/hbs/template.hbs', 'utf8' );
4631
4621
  const template = handlebars.compile( templateHtml );
4632
4622
  const html = template( { data: checklistDetails } );
4633
4623
  pdf.create( html ).toBuffer( ( err, buffer ) => {
@@ -4645,24 +4635,24 @@ export async function downloadChecklist( req, res ) {
4645
4635
  }
4646
4636
  }
4647
4637
 
4648
- async function convertUrltoBase64( url ) {
4649
- try {
4650
- const response = await fetch( url );
4638
+ // async function convertUrltoBase64( url ) {
4639
+ // try {
4640
+ // const response = await fetch( url );
4651
4641
 
4652
- if ( !response.ok ) {
4653
- throw new Error( 'Failed to fetch image' );
4654
- }
4642
+ // if ( !response.ok ) {
4643
+ // throw new Error( 'Failed to fetch image' );
4644
+ // }
4655
4645
 
4656
- const contentType = response.headers.get( 'content-type' );
4657
- const arrayBuffer = await response.arrayBuffer();
4646
+ // const contentType = response.headers.get( 'content-type' );
4647
+ // const arrayBuffer = await response.arrayBuffer();
4658
4648
 
4659
- const base64Image =
4660
- `data:${contentType};base64,` +
4661
- Buffer.from( arrayBuffer ).toString( 'base64' );
4649
+ // const base64Image =
4650
+ // `data:${contentType};base64,` +
4651
+ // Buffer.from( arrayBuffer ).toString( 'base64' );
4662
4652
 
4663
- return base64Image;
4664
- } catch ( error ) {
4665
- // console.error( 'Error fetching image:', error.message );
4666
- return false;
4667
- }
4668
- }
4653
+ // return base64Image;
4654
+ // } catch ( error ) {
4655
+ // // console.error( 'Error fetching image:', error.message );
4656
+ // return false;
4657
+ // }
4658
+ // }
@@ -35,6 +35,7 @@ internalTraxRouter
35
35
  .get( '/getSubmittedDetails', isAllowedInternalAPIHandler, internalController.submittedInfo )
36
36
  .post( '/checklistCreation', isAllowedInternalAPIHandler, internalController.checklistCreation )
37
37
  .post( '/getSubmissionDetails', isAllowedInternalAPIHandler, internalController.checklistTaskSubmissionDetails )
38
+ .post( '/posblock', isAllowedInternalAPIHandler, internalController.getStoreTaskDetails )
38
39
  ;
39
40
 
40
41