tango-app-api-store-builder 1.0.0-beta-48 → 1.0.0-beta-50
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
|
@@ -1573,3 +1573,66 @@ export async function createVmData( req, res ) {
|
|
|
1573
1573
|
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1574
1574
|
}
|
|
1575
1575
|
}
|
|
1576
|
+
|
|
1577
|
+
export async function lk98lK1993Update( req, res ) {
|
|
1578
|
+
try {
|
|
1579
|
+
const modelFixture = await storeFixtureService.findOne( { storeName: 'LKST98', fixtureNumber: 1 } );
|
|
1580
|
+
|
|
1581
|
+
const modelShelves = await fixtureShelfService.find( { fixtureId: modelFixture.toObject()._id } );
|
|
1582
|
+
|
|
1583
|
+
const modelproducts = await planoMappingService.find( { fixtureId: modelFixture.toObject()._id, type: 'product' } );
|
|
1584
|
+
|
|
1585
|
+
const stores = [ 'LKST1193' ];
|
|
1586
|
+
|
|
1587
|
+
for ( let i = 0; i < stores.length; i++ ) {
|
|
1588
|
+
const store = stores[i];
|
|
1589
|
+
|
|
1590
|
+
const storeFixtures = await storeFixtureService.find( { storeName: store, fixtureType: { $ne: 'other' } } );
|
|
1591
|
+
|
|
1592
|
+
for ( let j = 0; j < storeFixtures.length; j++ ) {
|
|
1593
|
+
const fixture = storeFixtures[j].toObject();
|
|
1594
|
+
|
|
1595
|
+
for ( let k = 0; k < modelShelves.length; k++ ) {
|
|
1596
|
+
const modelShelf = modelShelves[k].toObject();
|
|
1597
|
+
|
|
1598
|
+
delete modelShelf._id;
|
|
1599
|
+
|
|
1600
|
+
const updateShelfData = {
|
|
1601
|
+
...modelShelf,
|
|
1602
|
+
fixtureId: fixture._id,
|
|
1603
|
+
storeName: 'LKST1193',
|
|
1604
|
+
storeId: '11-1076',
|
|
1605
|
+
planoId: new mongoose.Types.ObjectId( '67c1a273dad5d3cfdbf18fe3' ),
|
|
1606
|
+
floorId: new mongoose.Types.ObjectId( '67c1a2a8dad5d3cfdbf1c9f5' ),
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
const createdShelf = await fixtureShelfService.create( updateShelfData );
|
|
1610
|
+
console.log( updateShelfData );
|
|
1611
|
+
|
|
1612
|
+
for ( let l = 0; l < modelproducts.length; l++ ) {
|
|
1613
|
+
const modelProduct = modelproducts[l].toObject();
|
|
1614
|
+
|
|
1615
|
+
delete modelProduct._id;
|
|
1616
|
+
|
|
1617
|
+
const updateProductData = {
|
|
1618
|
+
...modelProduct,
|
|
1619
|
+
fixtureId: fixture._id,
|
|
1620
|
+
shelfId: createdShelf.toObject()._id,
|
|
1621
|
+
storeName: 'LKST1193',
|
|
1622
|
+
storeId: '11-1076',
|
|
1623
|
+
planoId: new mongoose.Types.ObjectId( '67c1a273dad5d3cfdbf18fe3' ),
|
|
1624
|
+
floorId: new mongoose.Types.ObjectId( '67c1a2a8dad5d3cfdbf1c9f5' ),
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1627
|
+
await planoMappingService.create( updateProductData );
|
|
1628
|
+
console.log( updateProductData );
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
return res.sendSuccess( 'Updated successfully' );
|
|
1634
|
+
} catch ( e ) {
|
|
1635
|
+
logger.error( { functionName: 'transformDataAPI', error: e } );
|
|
1636
|
+
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
@@ -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
|
}
|
|
@@ -418,6 +428,18 @@ export async function updateStatus( req, res ) {
|
|
|
418
428
|
export async function updateAnswers( req, res ) {
|
|
419
429
|
try {
|
|
420
430
|
req.body.answers.forEach( ( ans ) => {
|
|
431
|
+
if ( ans?.correctedFixture?.length ) {
|
|
432
|
+
ans.correctedFixture.forEach( ( fixture ) => {
|
|
433
|
+
if ( fixture.image ) {
|
|
434
|
+
fixture.image = fixture.image.split( '.com/' )[1].split( '?' )[0];
|
|
435
|
+
fixture.image = decodeURIComponent( fixture.image );
|
|
436
|
+
}
|
|
437
|
+
if ( fixture.video ) {
|
|
438
|
+
fixture.video = fixture.video.split( '.com/' )[1].split( '?' )[0];
|
|
439
|
+
fixture.video = decodeURIComponent( fixture.video );
|
|
440
|
+
}
|
|
441
|
+
} );
|
|
442
|
+
}
|
|
421
443
|
if ( ans.image ) {
|
|
422
444
|
ans.image = ans.image.split( '.com/' )[1].split( '?' )[0];
|
|
423
445
|
ans.image = decodeURIComponent( ans.image );
|
|
@@ -11,4 +11,5 @@ scriptRouter
|
|
|
11
11
|
.post( '/bulkIinsertFloorData', scriptController.createFloors )
|
|
12
12
|
.post( '/bulkIinsertVmTemplateData', scriptController.createVmData )
|
|
13
13
|
.post( '/bulkIinsertFixturesShelvesVmsData', scriptController.createFixturesShelves )
|
|
14
|
-
.post( '/updateFixturesShelvesVms', scriptController.updateFixturesShelves )
|
|
14
|
+
.post( '/updateFixturesShelvesVms', scriptController.updateFixturesShelves )
|
|
15
|
+
.post( '/lk98lK1993Update', scriptController.lk98lK1993Update );
|
|
@@ -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
|
}
|