tango-app-api-trax 3.3.1-beta-23 → 3.3.1-beta-24
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
|
@@ -397,7 +397,6 @@ export async function redoChecklist( req, res ) {
|
|
|
397
397
|
};
|
|
398
398
|
|
|
399
399
|
let response = await processedChecklist.updateOne( { _id: req.body.payload._id }, updateData );
|
|
400
|
-
conosole.log( response );
|
|
401
400
|
if ( response.modifiedCount || response.matchedCount ) {
|
|
402
401
|
let storeTimeZone = await storeService.findOne( { storeName: checklistDetails.storeName }, { 'storeProfile.timeZone': 1 } );
|
|
403
402
|
let currentDateTime;
|
|
@@ -414,8 +413,8 @@ export async function redoChecklist( req, res ) {
|
|
|
414
413
|
sectionName: question[sectionIndex].sectionName,
|
|
415
414
|
questionName: question[sectionIndex].questions[findQuestion].qname,
|
|
416
415
|
action: 'redo',
|
|
417
|
-
store_id: checklistDetails
|
|
418
|
-
storeName: checklistDetails
|
|
416
|
+
store_id: checklistDetails.store_id,
|
|
417
|
+
storeName: checklistDetails.storeName,
|
|
419
418
|
client_id: checklistDetails.client_id,
|
|
420
419
|
processedChecklistId: checklistDetails._id,
|
|
421
420
|
type: checklistDetails.checkListType,
|
|
@@ -439,7 +438,7 @@ export async function redoChecklist( req, res ) {
|
|
|
439
438
|
};
|
|
440
439
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
441
440
|
let searchResponse = await fetch( url.redoChecklist, requestOptions );
|
|
442
|
-
|
|
441
|
+
|
|
443
442
|
|
|
444
443
|
if ( searchResponse.ok ) {
|
|
445
444
|
return res.sendSuccess( 'Question redo successfully' );
|
|
@@ -20,6 +20,8 @@ import { logger } from 'tango-app-api-middleware';
|
|
|
20
20
|
import mongoose from 'mongoose';
|
|
21
21
|
import { sendPushNotification } from 'tango-app-api-middleware';
|
|
22
22
|
import * as planoService from '../services/planogram.service.js';
|
|
23
|
+
import * as clusterServices from '../services/cluster.service.js';
|
|
24
|
+
import * as teamsServices from '../services/teams.service.js';
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
const ObjectId = mongoose.Types.ObjectId;
|
|
@@ -341,6 +343,152 @@ async function insertData( requestData ) {
|
|
|
341
343
|
} );
|
|
342
344
|
let allQuestion = await CLassign.aggregate( getquestionQuery );
|
|
343
345
|
if ( allQuestion.length ) {
|
|
346
|
+
let assignList = [];
|
|
347
|
+
if ( getCLconfig.coverage == 'store' ) {
|
|
348
|
+
let clusterList = allQuestion.filter( ( ele ) => ele?.clusterName ).map( ( item ) => item.assignId );
|
|
349
|
+
if ( clusterList.length ) {
|
|
350
|
+
let clusterDetails = await clusterServices.findcluster( { _id: { $in: clusterList } } );
|
|
351
|
+
if ( clusterDetails.length ) {
|
|
352
|
+
let idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
|
|
353
|
+
let getStoreDetails = await storeService.find( { _id: { $in: idList } } );
|
|
354
|
+
if ( getStoreDetails.length ) {
|
|
355
|
+
assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
|
|
356
|
+
let userDetails = await userService.findOne( { email: store?.spocDetails?.[0]?.email, clientId: store.clientId } );
|
|
357
|
+
if ( !userDetails ) {
|
|
358
|
+
let data = {
|
|
359
|
+
clientId: store.clientId,
|
|
360
|
+
userName: store.spocDetails?.[0]?.name,
|
|
361
|
+
mobileNumber: store.spocDetails?.[0]?.phone || '',
|
|
362
|
+
email: store.spocDetails[0].email,
|
|
363
|
+
password: '5dqFKAJj29PsV6P+kL+3Dw==',
|
|
364
|
+
role: 'user',
|
|
365
|
+
userType: 'client',
|
|
366
|
+
rolespermission: [
|
|
367
|
+
{
|
|
368
|
+
featureName: 'Global',
|
|
369
|
+
modules: [
|
|
370
|
+
{
|
|
371
|
+
name: 'Store',
|
|
372
|
+
isAdd: false,
|
|
373
|
+
isEdit: false,
|
|
374
|
+
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
name: 'User',
|
|
378
|
+
isAdd: false,
|
|
379
|
+
isEdit: false,
|
|
380
|
+
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: 'Camera',
|
|
384
|
+
isAdd: false,
|
|
385
|
+
isEdit: false,
|
|
386
|
+
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: 'Configuration',
|
|
390
|
+
isAdd: false,
|
|
391
|
+
isEdit: false,
|
|
392
|
+
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: 'Subscription',
|
|
396
|
+
isAdd: false,
|
|
397
|
+
isEdit: false,
|
|
398
|
+
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: 'Billing',
|
|
402
|
+
isAdd: false,
|
|
403
|
+
isEdit: false,
|
|
404
|
+
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
featurName: 'TangoEye',
|
|
410
|
+
modules: [
|
|
411
|
+
{
|
|
412
|
+
name: 'ZoneTag',
|
|
413
|
+
isAdd: false,
|
|
414
|
+
isEdit: false,
|
|
415
|
+
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
featurName: 'TangoTrax',
|
|
421
|
+
modules: [
|
|
422
|
+
{
|
|
423
|
+
name: 'checklist',
|
|
424
|
+
isAdd: false,
|
|
425
|
+
isEdit: false,
|
|
426
|
+
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: 'Task',
|
|
430
|
+
isAdd: false,
|
|
431
|
+
isEdit: false,
|
|
432
|
+
|
|
433
|
+
},
|
|
434
|
+
],
|
|
435
|
+
},
|
|
436
|
+
],
|
|
437
|
+
};
|
|
438
|
+
userDetails = await userService.create( data );
|
|
439
|
+
}
|
|
440
|
+
let data = {
|
|
441
|
+
store_id: store?.storeId,
|
|
442
|
+
storeName: store?.storeName,
|
|
443
|
+
userId: userDetails._id,
|
|
444
|
+
userName: userDetails.userName,
|
|
445
|
+
userEmail: userDetails.email,
|
|
446
|
+
userPhone: userDetails?.mobileNumber,
|
|
447
|
+
city: store?.storeProfile?.city,
|
|
448
|
+
country: store?.storeProfile?.country,
|
|
449
|
+
checkFlag: true,
|
|
450
|
+
checkListId: getCLconfig._id,
|
|
451
|
+
checkListName: getCLconfig.checkListName,
|
|
452
|
+
client_id: getCLconfig.client_id,
|
|
453
|
+
};
|
|
454
|
+
return data;
|
|
455
|
+
} ) );
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
allQuestion = allQuestion.filter( ( ele ) => !clusterList.includes( ele.assignId ) );
|
|
460
|
+
}
|
|
461
|
+
if ( getCLconfig.coverage == 'user' ) {
|
|
462
|
+
let teamsList = allQuestion.filter( ( ele ) => ele?.teamName ).map( ( item ) => item.assignId );
|
|
463
|
+
if ( teamsList.length ) {
|
|
464
|
+
let teamDetails = await teamsServices.findteams( { _id: { $in: teamsList } } );
|
|
465
|
+
if ( teamDetails.length ) {
|
|
466
|
+
let idList = teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) );
|
|
467
|
+
let getUserDetails = await userService.find( { _id: { $in: idList } } );
|
|
468
|
+
if ( getUserDetails.length ) {
|
|
469
|
+
assignList = getUserDetails.map( ( user ) => {
|
|
470
|
+
let data = {
|
|
471
|
+
store_id: '',
|
|
472
|
+
storeName: '',
|
|
473
|
+
userId: user._id,
|
|
474
|
+
userName: user.userName,
|
|
475
|
+
userEmail: user.email,
|
|
476
|
+
userPhone: user?.mobileNumber,
|
|
477
|
+
city: '',
|
|
478
|
+
country: '',
|
|
479
|
+
checkFlag: true,
|
|
480
|
+
checkListId: getCLconfig._id,
|
|
481
|
+
checkListName: getCLconfig.checkListName,
|
|
482
|
+
client_id: getCLconfig.client_id,
|
|
483
|
+
};
|
|
484
|
+
return data;
|
|
485
|
+
} );
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
allQuestion = allQuestion.filter( ( ele ) => !teamsList.includes( ele.assignId ) );
|
|
490
|
+
}
|
|
491
|
+
allQuestion = [ ...allQuestion, ...assignList ];
|
|
344
492
|
let userIdList = [];
|
|
345
493
|
for ( let element4 of allQuestion ) {
|
|
346
494
|
if ( getCLconfig.allowOnce && ![ 'onetime', 'daily' ].includes( getCLconfig.schedule ) ) {
|
|
@@ -394,9 +394,9 @@ export const getConfigDetails = async ( req, res ) => {
|
|
|
394
394
|
result.checkListDetails.scheduleStartTime = result.openTime;
|
|
395
395
|
result.checkListDetails.scheduleEndTime = result.closeTime;
|
|
396
396
|
}
|
|
397
|
-
let
|
|
398
|
-
|
|
399
|
-
result.checkListDetails = { ...result.checkListDetails, ...{ sections: sectionList }, ...{ assignedUsers:
|
|
397
|
+
let assignedUsers = await assignedService.find( { checkListId: storechecklistdetails._id }, { _id: 1, assignId: 1 } );
|
|
398
|
+
assignedUsers = assignedUsers?.map( ( item ) => item.assignId );
|
|
399
|
+
result.checkListDetails = { ...result.checkListDetails, ...{ sections: sectionList }, ...{ assignedUsers: assignedUsers }, ...{ removedUsers: [] } };
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
return res.sendSuccess( result );
|
|
@@ -863,7 +863,7 @@ export const assignedUserDetails = async ( req, res ) => {
|
|
|
863
863
|
let page = parseInt( req.query.offset ) || 0;
|
|
864
864
|
let skip = limit * page;
|
|
865
865
|
|
|
866
|
-
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), isdeleted: false } } ];
|
|
866
|
+
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), ...( req.query.coverage ) ? { coverage: req.query.coverage } : {}, isdeleted: false } } ];
|
|
867
867
|
if ( req.query.search.trim() && req.query.search.trim() != '' ) {
|
|
868
868
|
let searchValue = req.query.search;
|
|
869
869
|
searchValue = searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
|
|
@@ -972,7 +972,7 @@ export const assignedUserDetailsv1 = async ( req, res ) => {
|
|
|
972
972
|
// let page = parseInt( req.query.offset ) || 0;
|
|
973
973
|
// let skip = limit * page;
|
|
974
974
|
|
|
975
|
-
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), isdeleted: false } } ];
|
|
975
|
+
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), ...( req.query.coverage ) ? { coverage: req.query.coverage } : {}, isdeleted: false } } ];
|
|
976
976
|
if ( req.query.search.trim() && req.query.search.trim() != '' ) {
|
|
977
977
|
let searchValue = req.query.search;
|
|
978
978
|
searchValue = searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
|
|
@@ -1954,7 +1954,7 @@ export const validateUser = async ( req, res ) => {
|
|
|
1954
1954
|
}
|
|
1955
1955
|
};
|
|
1956
1956
|
|
|
1957
|
-
export const validateUserv1 = async ( req, res
|
|
1957
|
+
export const validateUserv1 = async ( req, res ) => {
|
|
1958
1958
|
try {
|
|
1959
1959
|
if ( !req.body.assignedUsers.length ) {
|
|
1960
1960
|
return res.sendError( 'Please Enter user Details', 400 );
|
|
@@ -2049,8 +2049,7 @@ export const validateUserv1 = async ( req, res, next ) => {
|
|
|
2049
2049
|
if ( userDetails.length || storeDetails.length ) {
|
|
2050
2050
|
return res.sendError( { validate: false, user: userDetails, store: storeDetails }, 400 );
|
|
2051
2051
|
}
|
|
2052
|
-
|
|
2053
|
-
next();
|
|
2052
|
+
return res.sendSuccess( { validate: true } );
|
|
2054
2053
|
} catch ( e ) {
|
|
2055
2054
|
logger.error( 'validateUser 2=>', e );
|
|
2056
2055
|
return res.sendError( e, 500 );
|
|
@@ -3638,7 +3637,7 @@ async function assignUsers( data ) {
|
|
|
3638
3637
|
];
|
|
3639
3638
|
let storeDetails = await storeService.aggregate( query );
|
|
3640
3639
|
if ( storeDetails.length ) {
|
|
3641
|
-
let email = data?.upload ? data.userEmail : storeDetails?.[0]?.spocDetails?.email;
|
|
3640
|
+
let email = data?.upload ? data.userEmail : storeDetails?.[0]?.spocDetails?.[0]?.email;
|
|
3642
3641
|
let userDetails = await userService.findOne( { email: email, clientId: data.clientId } );
|
|
3643
3642
|
if ( !userDetails ) {
|
|
3644
3643
|
let userData = {
|
|
@@ -3764,7 +3763,7 @@ export async function checklistAssign( req, res ) {
|
|
|
3764
3763
|
return res.sendError( 'No data found', 204 );
|
|
3765
3764
|
}
|
|
3766
3765
|
assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
|
|
3767
|
-
let userDetails = await userService.findOne( { email: store?.spocDetails?.email, clientId: store.clientId } );
|
|
3766
|
+
let userDetails = await userService.findOne( { email: store?.spocDetails?.[0]?.email, clientId: store.clientId } );
|
|
3768
3767
|
if ( !userDetails ) {
|
|
3769
3768
|
let data = {
|
|
3770
3769
|
clientId: store.clientId,
|
|
@@ -81,13 +81,14 @@ export const checklistPageValidation = {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
export const uploadUserSchema = joi.object( {
|
|
84
|
-
|
|
84
|
+
checklistId: joi.string().required(),
|
|
85
85
|
assignedUsers: joi.array().required(),
|
|
86
|
-
uploadUser: joi.boolean().required(),
|
|
86
|
+
// uploadUser: joi.boolean().required(),
|
|
87
87
|
type: joi.string().optional().allow( '' ),
|
|
88
88
|
addUser: joi.boolean().optional(),
|
|
89
89
|
delete: joi.boolean().optional(),
|
|
90
90
|
clientId: joi.string().optional(),
|
|
91
|
+
coverage: joi.string().optional(),
|
|
91
92
|
} );
|
|
92
93
|
|
|
93
94
|
export const uploadUserValidation = {
|