tango-app-api-store-builder 1.0.0-beta-90 → 1.0.0-beta-91
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-91",
|
|
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,51 @@ 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 } );
|
|
208
|
+
for ( let i=0; i<floorDetails.length; i++ ) {
|
|
209
|
+
let numbers =[
|
|
210
|
+
'Ground',
|
|
211
|
+
'First',
|
|
212
|
+
'Second',
|
|
213
|
+
'Third',
|
|
214
|
+
'Fourth',
|
|
215
|
+
'Fifth',
|
|
216
|
+
];
|
|
217
|
+
if ( getUserEmail ) {
|
|
218
|
+
let query = [
|
|
219
|
+
{
|
|
220
|
+
$addFields: {
|
|
221
|
+
emailLower: { $toLower: '$email' },
|
|
222
|
+
},
|
|
211
223
|
},
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
224
|
+
{
|
|
225
|
+
$match: {
|
|
226
|
+
clientId: req.body.clientId,
|
|
227
|
+
email: getUserEmail.email.toLowerCase(),
|
|
228
|
+
},
|
|
217
229
|
},
|
|
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 );
|
|
230
|
+
];
|
|
231
|
+
userDetails = await userService.aggregate( query );
|
|
232
|
+
userDetails = userDetails[0];
|
|
233
|
+
}
|
|
234
|
+
let taskData = { ...data };
|
|
235
|
+
if ( floorDetails.length > 1 ) {
|
|
236
|
+
taskData.checkListName = taskData.checkListName + `- ${numbers[i]} floor`;
|
|
237
|
+
taskData.floorId = floorDetails[i]._id;
|
|
238
|
+
}
|
|
239
|
+
taskData.store_id = store.storeId;
|
|
240
|
+
taskData.storeName = store.storeName;
|
|
241
|
+
taskData.userId = userDetails._id;
|
|
242
|
+
taskData.userName = userDetails.userName;
|
|
243
|
+
taskData.userEmail = userDetails.email;
|
|
244
|
+
taskData.planoId = planoDetails?._id;
|
|
245
|
+
for ( let i=0; i<req.body.days; i++ ) {
|
|
246
|
+
let currDate = dayjs().add( i, 'day' );
|
|
247
|
+
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() };
|
|
248
|
+
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 );
|
|
249
|
+
}
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
} ) );
|
|
@@ -249,6 +254,7 @@ export async function createTask( req, res ) {
|
|
|
249
254
|
|
|
250
255
|
return res.sendSuccess( 'Task created successfully' );
|
|
251
256
|
} catch ( e ) {
|
|
257
|
+
console.log( e );
|
|
252
258
|
logger.error( { functionName: 'createTask', error: e } );
|
|
253
259
|
return res.sendError( e, 500 );
|
|
254
260
|
}
|
|
@@ -447,7 +453,7 @@ export async function updateStatus( req, res ) {
|
|
|
447
453
|
let submitTimeString = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
448
454
|
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: req.body.status, ...( req.body.status == 'inprogress' ) ? { startTime_string: submitTimeString } : { submitTime_string: submitTimeString } } );
|
|
449
455
|
if ( req.body.status == 'submit' ) {
|
|
450
|
-
await processedService.deleteMany( {
|
|
456
|
+
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
457
|
}
|
|
452
458
|
return res.sendSuccess( 'Task status updated successfully' );
|
|
453
459
|
} catch ( e ) {
|