tango-app-api-store-builder 1.0.0-beta-90 → 1.0.0-beta-92
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-store-builder",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-92",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"path": "^0.12.7",
|
|
32
32
|
"selenium-webdriver": "^4.31.0",
|
|
33
33
|
"sharp": "^0.34.1",
|
|
34
|
-
"tango-api-schema": "^2.2.
|
|
34
|
+
"tango-api-schema": "^2.2.119",
|
|
35
35
|
"tango-app-api-middleware": "^3.1.48",
|
|
36
36
|
"url": "^0.11.4",
|
|
37
37
|
"winston": "^3.17.0",
|
|
@@ -10,6 +10,7 @@ import * as planoService from '../service/planogram.service.js';
|
|
|
10
10
|
import * as checklistService from '../service/checklist.service.js';
|
|
11
11
|
import timeZone from 'dayjs/plugin/timezone.js';
|
|
12
12
|
import * as planoProductService from '../service/planoProduct.service.js';
|
|
13
|
+
import * as floorService from '../service/storeBuilder.service.js';
|
|
13
14
|
dayjs.extend( timeZone );
|
|
14
15
|
|
|
15
16
|
async function createUser( data ) {
|
|
@@ -201,47 +202,43 @@ export async function createTask( req, res ) {
|
|
|
201
202
|
let storeDetails = await storeService.aggregate( query );
|
|
202
203
|
await Promise.all( storeDetails.map( async ( store ) => {
|
|
203
204
|
let getUserEmail = req.body.stores.find( ( ele ) => ele.store.toLowerCase() == store.storeName.toLowerCase() );
|
|
204
|
-
let planoDetails = await planoService.findOne( {
|
|
205
|
+
let planoDetails = await planoService.findOne( { storeName: store.storeName } );
|
|
205
206
|
if ( planoDetails ) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
let floorDetails = await floorService.find( { planoId: planoDetails._id }, { _id: 1, floorName: 1 } );
|
|
208
|
+
for ( let i=0; i<floorDetails.length; i++ ) {
|
|
209
|
+
if ( getUserEmail ) {
|
|
210
|
+
let query = [
|
|
211
|
+
{
|
|
212
|
+
$addFields: {
|
|
213
|
+
emailLower: { $toLower: '$email' },
|
|
214
|
+
},
|
|
211
215
|
},
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
{
|
|
217
|
+
$match: {
|
|
218
|
+
clientId: req.body.clientId,
|
|
219
|
+
email: getUserEmail.email.toLowerCase(),
|
|
220
|
+
},
|
|
217
221
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
taskData.userEmail = userDetails.email;
|
|
239
|
-
taskData.planoId = planoDetails?._id;
|
|
240
|
-
for ( let i=0; i<req.body.days; i++ ) {
|
|
241
|
-
let currDate = dayjs().add( i, 'day' );
|
|
242
|
-
let insertData = { ...taskData, date_string: currDate.format( 'YYYY-MM-DD' ), date_iso: new Date( currDate.format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( `${currDate.format( 'YYYY-MM-DD' )} 12:00 AM`, 'YYYY-MM-DD hh:mm A' ).format() };
|
|
243
|
-
let response = await processedService.updateOne( { date_string: currDate.format( 'YYYY-MM-DD' ), store_id: insertData.store_id, userEmail: insertData.userEmail, planoId: insertData.planoId, sourceCheckList_id: task._id }, insertData );
|
|
244
|
-
console.log( insertData.store_id, response );
|
|
222
|
+
];
|
|
223
|
+
userDetails = await userService.aggregate( query );
|
|
224
|
+
userDetails = userDetails[0];
|
|
225
|
+
}
|
|
226
|
+
let taskData = { ...data };
|
|
227
|
+
if ( floorDetails.length > 1 ) {
|
|
228
|
+
taskData.checkListName = taskData.checkListName +' - '+ floorDetails[i].floorName;
|
|
229
|
+
taskData.floorId = floorDetails[i]._id;
|
|
230
|
+
}
|
|
231
|
+
taskData.store_id = store.storeId;
|
|
232
|
+
taskData.storeName = store.storeName;
|
|
233
|
+
taskData.userId = userDetails._id;
|
|
234
|
+
taskData.userName = userDetails.userName;
|
|
235
|
+
taskData.userEmail = userDetails.email;
|
|
236
|
+
taskData.planoId = planoDetails?._id;
|
|
237
|
+
for ( let i=0; i<req.body.days; i++ ) {
|
|
238
|
+
let currDate = dayjs().add( i, 'day' );
|
|
239
|
+
let insertData = { ...taskData, date_string: currDate.format( 'YYYY-MM-DD' ), date_iso: new Date( currDate.format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( `${currDate.format( 'YYYY-MM-DD' )} 12:00 AM`, 'YYYY-MM-DD hh:mm A' ).format() };
|
|
240
|
+
await processedService.updateOne( { date_string: currDate.format( 'YYYY-MM-DD' ), store_id: insertData.store_id, userEmail: insertData.userEmail, planoId: insertData.planoId, sourceCheckList_id: task._id, ...( taskData?.floorId ) ? { floorId: taskData.floorId }:{} }, insertData );
|
|
241
|
+
}
|
|
245
242
|
}
|
|
246
243
|
}
|
|
247
244
|
} ) );
|
|
@@ -249,6 +246,7 @@ export async function createTask( req, res ) {
|
|
|
249
246
|
|
|
250
247
|
return res.sendSuccess( 'Task created successfully' );
|
|
251
248
|
} catch ( e ) {
|
|
249
|
+
console.log( e );
|
|
252
250
|
logger.error( { functionName: 'createTask', error: e } );
|
|
253
251
|
return res.sendError( e, 500 );
|
|
254
252
|
}
|
|
@@ -447,7 +445,7 @@ export async function updateStatus( req, res ) {
|
|
|
447
445
|
let submitTimeString = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
448
446
|
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: req.body.status, ...( req.body.status == 'inprogress' ) ? { startTime_string: submitTimeString } : { submitTime_string: submitTimeString } } );
|
|
449
447
|
if ( req.body.status == 'submit' ) {
|
|
450
|
-
await processedService.deleteMany( {
|
|
448
|
+
await processedService.deleteMany( { planoId: taskDetails.planoId, userEmail: taskDetails.userEmail, store_id: taskDetails.store_id, ...( taskDetails?.floorId ) ? { floorId: taskDetails.floorId } : {}, date_iso: { $gt: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } } );
|
|
451
449
|
}
|
|
452
450
|
return res.sendSuccess( 'Task status updated successfully' );
|
|
453
451
|
} catch ( e ) {
|