tango-app-api-trax 3.7.58 → 3.7.59
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
|
@@ -3241,3 +3241,88 @@ 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
|
+
scheduleEndTime_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
3271
|
+
},
|
|
3272
|
+
},
|
|
3273
|
+
{
|
|
3274
|
+
$group: {
|
|
3275
|
+
_id: { store: '$storeName', type: '$planoType' },
|
|
3276
|
+
checklistStatus: { $last: '$checklistStatus' },
|
|
3277
|
+
checkListName: { $last: '$checkListName' },
|
|
3278
|
+
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
3279
|
+
},
|
|
3280
|
+
},
|
|
3281
|
+
{
|
|
3282
|
+
$project: {
|
|
3283
|
+
store: '$_id.store',
|
|
3284
|
+
type: '$_id.type',
|
|
3285
|
+
checklistStatus: 1,
|
|
3286
|
+
checkListName: 1,
|
|
3287
|
+
scheduleEndTime_iso: 1,
|
|
3288
|
+
},
|
|
3289
|
+
},
|
|
3290
|
+
];
|
|
3291
|
+
|
|
3292
|
+
|
|
3293
|
+
const taskDetails = await processedTaskService.aggregate( taskQuery );
|
|
3294
|
+
console.log( taskDetails );
|
|
3295
|
+
let info = [ ...checkListDetails, ...taskDetails ];
|
|
3296
|
+
// const details = {
|
|
3297
|
+
// storeTourVideoChecklist: ( !checkListDetails.length || checkListDetails?.[0]?.checklistStatus == 'submit' ) ? true : false,
|
|
3298
|
+
// FixtureVerification: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'fixture' ) || taskDetails?.some( ( ele ) => ele?.type == 'fixture' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3299
|
+
// MerchRollout: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'merchRollout' ) || taskDetails?.some( ( ele ) => ele?.type == 'merchRollout' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3300
|
+
// VmRollout: ( !taskDetails.length || !taskDetails?.some( ( ele ) => ele?.type == 'vmRollout' ) || taskDetails?.some( ( ele ) => ele?.type == 'vmRollout' && ele?.checklistStatus == 'submit' ) ) ? true : false,
|
|
3301
|
+
// };
|
|
3302
|
+
|
|
3303
|
+
let result = {
|
|
3304
|
+
storeId: req.body.storeName,
|
|
3305
|
+
tangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus == 'submit' ).map( ( ele ) => {
|
|
3306
|
+
return {
|
|
3307
|
+
blockName: ele?.checkListName,
|
|
3308
|
+
blockEnabled: true,
|
|
3309
|
+
blockReason: `${ele?.checkListName} is completed`,
|
|
3310
|
+
};
|
|
3311
|
+
} ),
|
|
3312
|
+
upcomingTangoPosBlocks: info.filter( ( ele ) => ele.checklistStatus !== 'submit' ).map( ( ele ) => {
|
|
3313
|
+
return {
|
|
3314
|
+
blockName: ele?.checkListName,
|
|
3315
|
+
blockReason: `Compelete ${ele?.checkListName} before ${dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' )} to avoid ABC block`,
|
|
3316
|
+
dueDate: dayjs( ele?.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ),
|
|
3317
|
+
};
|
|
3318
|
+
} ),
|
|
3319
|
+
};
|
|
3320
|
+
|
|
3321
|
+
|
|
3322
|
+
return res.sendSuccess( result );
|
|
3323
|
+
} catch ( error ) {
|
|
3324
|
+
const err = error.message || 'Internal Server Error';
|
|
3325
|
+
logger.error( { error: error, message: req.body, function: 'getStoretaskDetails' } );
|
|
3326
|
+
return res.sendError( err, 500 );
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
@@ -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
|
}
|
|
@@ -4579,53 +4579,44 @@ 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
|
|
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
|
-
|
|
4590
|
-
|
|
4589
|
+
checklistDetails.questionAnswers.forEach( ( section ) => {
|
|
4590
|
+
section.questions.forEach( ( question ) => {
|
|
4591
4591
|
question.remarks = question.remarks == null || question.remarks == 'null' ? '' : question.remarks;
|
|
4592
|
-
|
|
4592
|
+
question.userAnswer.forEach( ( answer ) => {
|
|
4593
4593
|
if ( answer?.referenceImage?.trim() ) {
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
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
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
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
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
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
|
-
}
|
|
4617
|
+
} );
|
|
4618
|
+
} );
|
|
4619
|
+
} );
|
|
4629
4620
|
const targetFolder = path.join( __dirname, '..', '/hbs/template.hbs' );
|
|
4630
4621
|
const templateHtml = fs.readFileSync( targetFolder, 'utf8' );
|
|
4631
4622
|
const template = handlebars.compile( templateHtml );
|
|
@@ -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
|
|