tango-app-api-trax 3.7.59 → 3.7.61

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.59",
3
+ "version": "3.7.61",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,6 +28,7 @@
28
28
  "mongodb": "^6.8.0",
29
29
  "nodemon": "^3.1.4",
30
30
  "path": "^0.12.7",
31
+ "puppeteer": "^24.39.0",
31
32
  "tango-api-schema": "^2.5.61",
32
33
  "tango-app-api-middleware": "^3.5.2",
33
34
  "url": "^0.11.4",
@@ -3267,7 +3267,6 @@ export async function getStoreTaskDetails( req, res ) {
3267
3267
  storeName: req.body.storeName,
3268
3268
  isPlano: true,
3269
3269
  planoType: { $in: [ 'fixture', 'merchRollout', 'vmRollout' ] },
3270
- scheduleEndTime_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
3271
3270
  },
3272
3271
  },
3273
3272
  {
@@ -3302,7 +3301,7 @@ export async function getStoreTaskDetails( req, res ) {
3302
3301
 
3303
3302
  let result = {
3304
3303
  storeId: req.body.storeName,
3305
- tangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus == 'submit' ).map( ( ele ) => {
3304
+ tangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus != 'submit' && dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ) < dayjs().format( 'YYYY-MM-DD' ) ).map( ( ele ) => {
3306
3305
  return {
3307
3306
  blockName: ele?.checkListName,
3308
3307
  blockEnabled: true,
@@ -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 {
@@ -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,
@@ -4592,68 +4592,58 @@ export async function downloadChecklist( req, res ) {
4592
4592
  question.userAnswer.forEach( ( answer ) => {
4593
4593
  if ( answer?.referenceImage?.trim() ) {
4594
4594
  answer.referenceImage = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.referenceImage;
4595
- // const base64Image = await convertUrltoBase64( url );
4596
- // if ( base64Image ) {
4597
- // answer.referenceImage = base64Image;
4598
- // }
4599
4595
  }
4600
4596
  if ( answer.validationType == 'Capture Image' && answer?.validationAnswer?.trim() ) {
4601
4597
  answer.validationAnswer = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.validationAnswer;
4602
- // const base64Image = await convertUrltoBase64( url );
4603
- // if ( base64Image ) {
4604
- // answer.validationAnswer = base64Image;
4605
- // }
4606
4598
  }
4607
4599
  if ( answer?.answer?.trim() && [ 'image', 'descriptiveImage', 'multipleImage', 'image/video' ].includes( question.answerType ) ) {
4608
4600
  answer.answer = 'https://d1r0hc2sskgmri.cloudfront.net/'+answer.answer;
4609
4601
  if ( question.answerType == 'multipleImage' ) {
4610
4602
  console.log( answer.answer );
4611
4603
  }
4612
- // const base64Image = await convertUrltoBase64( url );
4613
- // if ( base64Image ) {
4614
- // answer.answer = base64Image;
4615
- // }
4616
4604
  }
4617
4605
  } );
4618
4606
  } );
4619
4607
  } );
4620
- const targetFolder = path.join( __dirname, '..', '/hbs/template.hbs' );
4621
- const templateHtml = fs.readFileSync( targetFolder, 'utf8' );
4608
+ const templateHtml = readFileSync( join() + '/src/hbs/template.hbs', 'utf8' );
4622
4609
  const template = handlebars.compile( templateHtml );
4623
4610
  const html = template( { data: checklistDetails } );
4624
- pdf.create( html ).toBuffer( ( err, buffer ) => {
4611
+ conosle.log( html );
4612
+ pdf.create( html ).toStream( ( err, stream ) => {
4625
4613
  if ( err ) {
4626
- res.status( 500 ).send( 'Error Generating PDF' );
4627
- } else {
4628
- res.setHeader( 'Content-Disposition', 'attachment; filename=checkListDetails.pdf' );
4629
- res.contentType( 'application/pdf' );
4630
- res.send( buffer );
4614
+ return res.status( 500 ).send( 'Error generating PDF' );
4631
4615
  }
4616
+
4617
+ res.setHeader( 'Content-Type', 'application/pdf' );
4618
+ res.setHeader( 'Content-Disposition', 'attachment; filename=checkListDetails.pdf' );
4619
+
4620
+ stream.pipe( res );
4632
4621
  } );
4633
4622
  } catch ( e ) {
4623
+ console.log( e );
4634
4624
  console.log( 'getChecklistQuestionAnswers =>', e );
4635
4625
  return false;
4636
4626
  }
4637
4627
  }
4638
4628
 
4639
- async function convertUrltoBase64( url ) {
4640
- try {
4641
- const response = await fetch( url );
4629
+ // async function convertUrltoBase64( url ) {
4630
+ // try {
4631
+ // const response = await fetch( url );
4642
4632
 
4643
- if ( !response.ok ) {
4644
- throw new Error( 'Failed to fetch image' );
4645
- }
4633
+ // if ( !response.ok ) {
4634
+ // throw new Error( 'Failed to fetch image' );
4635
+ // }
4646
4636
 
4647
- const contentType = response.headers.get( 'content-type' );
4648
- const arrayBuffer = await response.arrayBuffer();
4637
+ // const contentType = response.headers.get( 'content-type' );
4638
+ // const arrayBuffer = await response.arrayBuffer();
4649
4639
 
4650
- const base64Image =
4651
- `data:${contentType};base64,` +
4652
- Buffer.from( arrayBuffer ).toString( 'base64' );
4640
+ // const base64Image =
4641
+ // `data:${contentType};base64,` +
4642
+ // Buffer.from( arrayBuffer ).toString( 'base64' );
4653
4643
 
4654
- return base64Image;
4655
- } catch ( error ) {
4656
- // console.error( 'Error fetching image:', error.message );
4657
- return false;
4658
- }
4659
- }
4644
+ // return base64Image;
4645
+ // } catch ( error ) {
4646
+ // // console.error( 'Error fetching image:', error.message );
4647
+ // return false;
4648
+ // }
4649
+ // }