tango-app-api-store-builder 1.0.0-beta-47 → 1.0.0-beta-49
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
|
@@ -8,6 +8,8 @@ import { logger, fileUpload, signedUrl } from 'tango-app-api-middleware';
|
|
|
8
8
|
import * as planoTaskService from '../service/planoTask.service.js';
|
|
9
9
|
import * as planoService from '../service/planogram.service.js';
|
|
10
10
|
import * as checklistService from '../service/checklist.service.js';
|
|
11
|
+
import timeZone from 'dayjs/plugin/timezone.js';
|
|
12
|
+
dayjs.extend( timeZone );
|
|
11
13
|
|
|
12
14
|
async function createUser( data ) {
|
|
13
15
|
try {
|
|
@@ -404,7 +406,15 @@ export async function updateStatus( req, res ) {
|
|
|
404
406
|
if ( !taskDetails ) {
|
|
405
407
|
return res.sendError( 'No data found', 204 );
|
|
406
408
|
}
|
|
407
|
-
await
|
|
409
|
+
let storeTimeZone = await storeService.findOne( { storeName: { $regex: taskDetails.storeName, $options: 'i' }, clientId: taskDetails.client_id }, { 'storeProfile.timeZone': 1 } );
|
|
410
|
+
let currentDateTime;
|
|
411
|
+
if ( storeTimeZone?.storeProfile?.timeZone ) {
|
|
412
|
+
currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
|
|
413
|
+
} else {
|
|
414
|
+
currentDateTime = requestData?.currentTime ? dayjs( requestData.currentTime, 'HH:mm:ss' ) : dayjs();
|
|
415
|
+
}
|
|
416
|
+
let submitTimeString = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
417
|
+
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: req.body.status, ...( req.body.status == 'inprogress' ) ? { startTime_string: submitTimeString } : { submitTime_string: submitTimeString } } );
|
|
408
418
|
if ( req.body.status == 'submit' ) {
|
|
409
419
|
await processedService.deleteMany( { _id: req.body.taskId, date_iso: { $gt: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } } );
|
|
410
420
|
}
|
|
@@ -417,15 +427,15 @@ export async function updateStatus( req, res ) {
|
|
|
417
427
|
|
|
418
428
|
export async function updateAnswers( req, res ) {
|
|
419
429
|
try {
|
|
420
|
-
// if ( !req.body.fixtureId ) {
|
|
421
|
-
// return res.sendError( 'No data found', 204 );
|
|
422
|
-
// }
|
|
423
|
-
|
|
424
430
|
req.body.answers.forEach( ( ans ) => {
|
|
425
|
-
if ( ans.image
|
|
431
|
+
if ( ans.image ) {
|
|
426
432
|
ans.image = ans.image.split( '.com/' )[1].split( '?' )[0];
|
|
427
433
|
ans.image = decodeURIComponent( ans.image );
|
|
428
434
|
}
|
|
435
|
+
if ( ans.video ) {
|
|
436
|
+
ans.video = ans.video.split( '.com/' )[1].split( '?' )[0];
|
|
437
|
+
ans.video = decodeURIComponent( ans.video );
|
|
438
|
+
}
|
|
429
439
|
} );
|
|
430
440
|
|
|
431
441
|
let data = {
|
|
@@ -474,6 +484,14 @@ export async function getFixtureDetails( req, res ) {
|
|
|
474
484
|
let imageUrl = await signedUrl( params );
|
|
475
485
|
ans.image = imageUrl;
|
|
476
486
|
}
|
|
487
|
+
if ( ans.video ) {
|
|
488
|
+
let params = {
|
|
489
|
+
Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
490
|
+
file_path: ans.video,
|
|
491
|
+
};
|
|
492
|
+
let imageUrl = await signedUrl( params );
|
|
493
|
+
ans.video = imageUrl;
|
|
494
|
+
}
|
|
477
495
|
return ans;
|
|
478
496
|
} ) );
|
|
479
497
|
|
|
@@ -12,6 +12,10 @@ export async function updateOne( query = {}, record = {} ) {
|
|
|
12
12
|
return model.taskProcessedModel.updateOne( query, { $set: record }, { upsert: true } );
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export async function deleteMany( query = {} ) {
|
|
16
|
+
return model.taskProcessedModel.deleteMany( query );
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
export async function find( query = {}, field = {} ) {
|
|
16
20
|
return model.taskProcessedModel.find( query, field );
|
|
17
21
|
}
|