tango-app-api-trax 3.3.1-beta-60 → 3.3.1-beta-62
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
|
@@ -1010,7 +1010,7 @@ export const assignedUserDetailsv1 = async ( req, res ) => {
|
|
|
1010
1010
|
let storeDetails = await storeService.find( { _id: { $in: clusterDetails.stores.map( ( item ) => item.store ) }, status: 'active' } );
|
|
1011
1011
|
storeDetails.forEach( ( item ) => {
|
|
1012
1012
|
userDetails.push( {
|
|
1013
|
-
|
|
1013
|
+
id: ele.assignId,
|
|
1014
1014
|
userName: item.spocDetails?.[0]?.name,
|
|
1015
1015
|
userEmail: item.spocDetails?.[0]?.email,
|
|
1016
1016
|
storeId: item?.storeId,
|
|
@@ -1029,7 +1029,7 @@ export const assignedUserDetailsv1 = async ( req, res ) => {
|
|
|
1029
1029
|
let teamUserDetails = await userService.find( { _id: { $in: teamDetails.users.map( ( item ) => item.userId ) } } );
|
|
1030
1030
|
teamUserDetails.forEach( ( item ) => {
|
|
1031
1031
|
userDetails.push( {
|
|
1032
|
-
|
|
1032
|
+
id: ele.assignId,
|
|
1033
1033
|
userName: item.userName,
|
|
1034
1034
|
userEmail: item.email,
|
|
1035
1035
|
storeId: ele?.storeId,
|
|
@@ -1496,7 +1496,6 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1496
1496
|
approver: inputBody?.checkListDetails?.approver.length ? inputBody?.checkListDetails?.approver.map( ( item ) => {
|
|
1497
1497
|
return { name: item.name, value: item.value };
|
|
1498
1498
|
} ) : [],
|
|
1499
|
-
storeCount: inputBody.checkListDetails?.assignedUsers?.length || 0,
|
|
1500
1499
|
};
|
|
1501
1500
|
|
|
1502
1501
|
if ( inputBody?.checkListDetails?.approver.length ) {
|
|
@@ -2006,8 +2005,8 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2006
2005
|
}
|
|
2007
2006
|
}
|
|
2008
2007
|
|
|
2009
|
-
let userEmailList = assignDetails.map( ( item ) => item
|
|
2010
|
-
let storeList = assignDetails.map( ( item ) => item?.storeName?.toLowerCase() );
|
|
2008
|
+
let userEmailList = assignDetails.map( ( item ) => item?.userEmail?.trim()?.toLowerCase() );
|
|
2009
|
+
let storeList = assignDetails.map( ( item ) => item?.storeName?.trim()?.toLowerCase() );
|
|
2011
2010
|
|
|
2012
2011
|
let userQuery = [
|
|
2013
2012
|
{
|
|
@@ -2016,6 +2015,7 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2016
2015
|
isActive: 1,
|
|
2017
2016
|
clientId: 1,
|
|
2018
2017
|
userName: 1,
|
|
2018
|
+
email: 1,
|
|
2019
2019
|
},
|
|
2020
2020
|
},
|
|
2021
2021
|
{
|
|
@@ -2033,6 +2033,7 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2033
2033
|
newEmail: { $toLower: '$email' },
|
|
2034
2034
|
isActive: 1,
|
|
2035
2035
|
clientId: 1,
|
|
2036
|
+
email: 1,
|
|
2036
2037
|
},
|
|
2037
2038
|
},
|
|
2038
2039
|
{
|
|
@@ -2047,17 +2048,19 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2047
2048
|
let storeQuery = [
|
|
2048
2049
|
{
|
|
2049
2050
|
$project: {
|
|
2050
|
-
'
|
|
2051
|
+
'store': { $toLower: '$storeName' },
|
|
2051
2052
|
'clientId': 1,
|
|
2052
2053
|
'storeProfile.city': 1,
|
|
2053
2054
|
'status': 1,
|
|
2054
2055
|
'storeId': 1,
|
|
2056
|
+
'spocDetails': 1,
|
|
2057
|
+
'storeName': 1,
|
|
2055
2058
|
},
|
|
2056
2059
|
},
|
|
2057
2060
|
{
|
|
2058
2061
|
$match: {
|
|
2059
2062
|
clientId: req.body.clientId,
|
|
2060
|
-
|
|
2063
|
+
store: { $in: storeList },
|
|
2061
2064
|
},
|
|
2062
2065
|
},
|
|
2063
2066
|
];
|
|
@@ -2074,14 +2077,18 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2074
2077
|
let newUserList = userEmailList.filter( ( ele ) => !existUserEmail.includes( ele ) && !existEmail.includes( ele ) );
|
|
2075
2078
|
let inActiveStores = storeDetails.filter( ( ele ) => ele.status == 'deactive' ).map( ( ele ) => ele.storeName );
|
|
2076
2079
|
|
|
2077
|
-
let existsStore = storeDetails.map( ( ele ) => ele
|
|
2080
|
+
let existsStore = storeDetails.map( ( ele ) => ele.storeName.toLowerCase() );
|
|
2078
2081
|
let newStoreList = storeList.filter( ( ele ) => ele != null && !existsStore.includes( ele.toLowerCase() ) );
|
|
2079
2082
|
if ( req.body.coverage == 'store' ) {
|
|
2080
2083
|
assignDetails.forEach( ( item ) => {
|
|
2081
|
-
let
|
|
2082
|
-
if (
|
|
2083
|
-
|
|
2084
|
-
item.
|
|
2084
|
+
let getStoreDetails = storeDetails.find( ( store ) => store.storeName.toLowerCase() == item.storeName.toLowerCase() );
|
|
2085
|
+
if ( getStoreDetails ) {
|
|
2086
|
+
let storeUserDetails = userDetails.find( ( ele ) => ele.newEmail.toLowerCase() == item.userEmail.toLowerCase() );
|
|
2087
|
+
item._id = getStoreDetails._id;
|
|
2088
|
+
item.storeId = getStoreDetails.storeId;
|
|
2089
|
+
item.userName = storeUserDetails ? storeUserDetails?.userName : item.userName;
|
|
2090
|
+
item.storeName = getStoreDetails.storeName;
|
|
2091
|
+
item.userEmail = storeUserDetails ? storeUserDetails?.email : item.userEmail;
|
|
2085
2092
|
}
|
|
2086
2093
|
} );
|
|
2087
2094
|
} else {
|
|
@@ -2090,6 +2097,7 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2090
2097
|
if ( getUserDetails ) {
|
|
2091
2098
|
item._id = getUserDetails._id;
|
|
2092
2099
|
item.userName = getUserDetails.userName;
|
|
2100
|
+
item.userEmail = getUserDetails.email;
|
|
2093
2101
|
}
|
|
2094
2102
|
} );
|
|
2095
2103
|
}
|
|
@@ -2097,21 +2105,21 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2097
2105
|
if ( ( newUserList.length || newStoreList.length || existEmail.length || inActiveStores.length ) && !req.body?.addUser ) {
|
|
2098
2106
|
return res.sendError( { validate: false, user: newUserList, store: newStoreList, existEmail, inActiveStores, data: assignDetails }, 400 );
|
|
2099
2107
|
}
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2108
|
+
await Promise.all( newUserList.map( async ( ele ) => {
|
|
2109
|
+
let findUserIndex = assignDetails.findIndex( ( item ) => item?.userEmail?.toLowerCase() == ele?.toLowerCase() );
|
|
2110
|
+
if ( findUserIndex != -1 ) {
|
|
2111
|
+
let data = {
|
|
2112
|
+
userName: assignDetails[findUserIndex]?.userName,
|
|
2113
|
+
email: ele,
|
|
2114
|
+
mobileNumber: assignDetails[findUserIndex]?.mobileNumber,
|
|
2115
|
+
clientId: req.body.clientId,
|
|
2116
|
+
};
|
|
2117
|
+
let response = await createUser( data );
|
|
2118
|
+
if ( req.body.coverage == 'user' ) {
|
|
2111
2119
|
assignDetails[findUserIndex]._id = response._id;
|
|
2112
2120
|
}
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2121
|
+
}
|
|
2122
|
+
} ) );
|
|
2115
2123
|
return res.sendSuccess( { validate: true, data: assignDetails } );
|
|
2116
2124
|
} catch ( e ) {
|
|
2117
2125
|
logger.error( 'validateUser 2=>', e );
|
|
@@ -2933,7 +2941,6 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2933
2941
|
getquestionQuery.push( {
|
|
2934
2942
|
$match: {
|
|
2935
2943
|
checkListId: new ObjectId( checklistId ),
|
|
2936
|
-
checkFlag: true,
|
|
2937
2944
|
isdeleted: false,
|
|
2938
2945
|
},
|
|
2939
2946
|
} );
|
|
@@ -2949,9 +2956,35 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2949
2956
|
let idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
|
|
2950
2957
|
let getStoreDetails = await storeService.find( { _id: { $in: idList }, status: 'active' } );
|
|
2951
2958
|
if ( getStoreDetails.length ) {
|
|
2959
|
+
getStoreDetails = getStoreDetails.filter( ( store ) => {
|
|
2960
|
+
let findStore = allQuestion.find( ( storeList ) => storeList.assignId.toString() == store._id.toString() );
|
|
2961
|
+
if ( findStore ) {
|
|
2962
|
+
return store?.spocDetails?.[0]?.email.toLowerCase() != findStore.userEmail.toLowerCase();
|
|
2963
|
+
} else {
|
|
2964
|
+
return true;
|
|
2965
|
+
}
|
|
2966
|
+
} );
|
|
2952
2967
|
assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
|
|
2953
|
-
let
|
|
2954
|
-
|
|
2968
|
+
let userQuery = [
|
|
2969
|
+
{
|
|
2970
|
+
$project: {
|
|
2971
|
+
newEmail: { $toLower: '$email' },
|
|
2972
|
+
isActive: 1,
|
|
2973
|
+
clientId: 1,
|
|
2974
|
+
userName: 1,
|
|
2975
|
+
email: 1,
|
|
2976
|
+
},
|
|
2977
|
+
},
|
|
2978
|
+
{
|
|
2979
|
+
$match: {
|
|
2980
|
+
newEmail: store?.spocDetails?.[0]?.email.toLowerCase(),
|
|
2981
|
+
isActive: true,
|
|
2982
|
+
clientId: store.clientId,
|
|
2983
|
+
},
|
|
2984
|
+
},
|
|
2985
|
+
];
|
|
2986
|
+
let userDetails = await userService.aggregate( userQuery );
|
|
2987
|
+
if ( !userDetails.length ) {
|
|
2955
2988
|
let data = {
|
|
2956
2989
|
clientId: store.clientId,
|
|
2957
2990
|
userName: store.spocDetails?.[0]?.name,
|
|
@@ -2959,14 +2992,15 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2959
2992
|
email: store.spocDetails[0].email,
|
|
2960
2993
|
};
|
|
2961
2994
|
userDetails = await createUser( data );
|
|
2995
|
+
userDetails = [ userDetails ];
|
|
2962
2996
|
}
|
|
2963
2997
|
let data = {
|
|
2964
2998
|
store_id: store?.storeId,
|
|
2965
2999
|
storeName: store?.storeName,
|
|
2966
|
-
userId: userDetails
|
|
2967
|
-
userName: userDetails
|
|
2968
|
-
userEmail: userDetails
|
|
2969
|
-
userPhone: userDetails?.mobileNumber,
|
|
3000
|
+
userId: userDetails?.[0]?._id,
|
|
3001
|
+
userName: userDetails?.[0]?.userName,
|
|
3002
|
+
userEmail: userDetails?.[0]?.email,
|
|
3003
|
+
userPhone: userDetails?.[0]?.mobileNumber,
|
|
2970
3004
|
city: store?.storeProfile?.city,
|
|
2971
3005
|
country: store?.storeProfile?.country,
|
|
2972
3006
|
checkFlag: true,
|
|
@@ -2987,6 +3021,8 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2987
3021
|
let teamDetails = await teamsServices.findteams( { _id: { $in: teamsList } } );
|
|
2988
3022
|
if ( teamDetails.length ) {
|
|
2989
3023
|
let idList = teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) );
|
|
3024
|
+
let userIdList = allQuestion.filter( ( qn ) => !qn?.teamName ).map( ( qn ) => qn.assignId.toString() );
|
|
3025
|
+
idList = idList.filter( ( id ) => !userIdList.includes( id.toString() ) );
|
|
2990
3026
|
let getUserDetails = await userService.find( { _id: { $in: idList } } );
|
|
2991
3027
|
if ( getUserDetails.length ) {
|
|
2992
3028
|
assignList = getUserDetails.map( ( user ) => {
|
|
@@ -3163,7 +3199,6 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3163
3199
|
let data = { ...getsubmitDetails[0]._doc };
|
|
3164
3200
|
await processedchecklist.updateOne( { _id: getsubmitDetails[0]._id }, data );
|
|
3165
3201
|
if ( editSubmit && getsubmitDetails[0].checklistStatus == 'submit' ) {
|
|
3166
|
-
console.log( editSubmit );
|
|
3167
3202
|
let user = {
|
|
3168
3203
|
_id: getsubmitDetails[0].userId,
|
|
3169
3204
|
clientId: getsubmitDetails[0].client_id,
|
|
@@ -3246,25 +3281,25 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3246
3281
|
}
|
|
3247
3282
|
}
|
|
3248
3283
|
} else {
|
|
3249
|
-
let unAssignedList = assignUserList.reduce( ( acc, item ) => {
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
}, {} );
|
|
3257
|
-
|
|
3258
|
-
let userList = Object.keys( unAssignedList );
|
|
3259
|
-
|
|
3260
|
-
await processedchecklist.deleteMany( { userEmail: { $nin: userList }, date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, checklistStatus: { $nin: [ 'submit' ] } } );
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
}
|
|
3267
|
-
|
|
3284
|
+
// let unAssignedList = assignUserList.reduce( ( acc, item ) => {
|
|
3285
|
+
// if ( !acc[item.userEmail] ) {
|
|
3286
|
+
// acc[item.userEmail]=[ item.store_id ];
|
|
3287
|
+
// } else {
|
|
3288
|
+
// acc[item.userEmail].push( item.store_id );
|
|
3289
|
+
// }
|
|
3290
|
+
// return acc;
|
|
3291
|
+
// }, {} );
|
|
3292
|
+
|
|
3293
|
+
// let userList = Object.keys( unAssignedList );
|
|
3294
|
+
|
|
3295
|
+
// await processedchecklist.deleteMany( { userEmail: { $nin: userList }, date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, checklistStatus: { $nin: [ 'submit' ] } } );
|
|
3296
|
+
await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, checklistStatus: { $nin: [ 'submit' ] } } );
|
|
3297
|
+
|
|
3298
|
+
// for ( let key in assignUserList ) {
|
|
3299
|
+
// if ( assignUserList.hasOwnProperty( key ) ) {
|
|
3300
|
+
// await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, $and: [ { userEmail: key }, { store_id: { $nin: unAssignedList[key] } } ], checklistStatus: { $nin: [ 'submit' ] } } );
|
|
3301
|
+
// }
|
|
3302
|
+
// }
|
|
3268
3303
|
|
|
3269
3304
|
Promise.all( assignUserList.map( async ( ele ) => {
|
|
3270
3305
|
await processedchecklist.updateOne( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, userEmail: ele.userEmail, store_id: ele.store_id }, ele );
|
|
@@ -3614,7 +3649,6 @@ async function assignUsers( data ) {
|
|
|
3614
3649
|
}
|
|
3615
3650
|
} else {
|
|
3616
3651
|
let teamDetails = await teamsServices.findteams( { clientId: data.clientId, _id: new mongoose.Types.ObjectId( data.id ) } );
|
|
3617
|
-
console.log( teamDetails, 'team' );
|
|
3618
3652
|
if ( teamDetails.length ) {
|
|
3619
3653
|
let userIdList = teamDetails[0].users.map( ( ele ) => ele.userId );
|
|
3620
3654
|
let userDetails = await userService.find( { _id: userIdList } );
|
|
@@ -3696,9 +3730,9 @@ export async function checklistAssign( req, res ) {
|
|
|
3696
3730
|
|
|
3697
3731
|
export async function updateAssign( req, res ) {
|
|
3698
3732
|
try {
|
|
3699
|
-
if ( !req.body.assignedList.length && !req.body.assignedGroup.length ) {
|
|
3700
|
-
|
|
3701
|
-
}
|
|
3733
|
+
// if ( !req.body.assignedList.length && !req.body.assignedGroup.length ) {
|
|
3734
|
+
// return res.sendError( 'No data found', 204 );
|
|
3735
|
+
// }
|
|
3702
3736
|
let checklistDetails = await checklistService.findOne( { _id: req.body.checkListId, client_id: req.body.clientId } );
|
|
3703
3737
|
if ( !checklistDetails ) {
|
|
3704
3738
|
return res.sendError( 'No data found', 204 );
|
|
@@ -16,7 +16,7 @@ traxRouter
|
|
|
16
16
|
.post( '/validateUser', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), validate( uploadUserValidation ), traxController.validateUser )
|
|
17
17
|
.post( '/validateUserv1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), validate( uploadUserValidation ), traxController.validateUserv1 )
|
|
18
18
|
.get( '/userDetails/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( duplicateValidation ), traxController.assignedUserDetails )
|
|
19
|
-
.get( '/userDetailsv1/:checklistId', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( duplicateValidation ), traxController.assignedUserDetailsv1 )
|
|
19
|
+
.get( '/userDetailsv1/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( duplicateValidation ), traxController.assignedUserDetailsv1 )
|
|
20
20
|
.post( '/checklistConfigure', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), traxController.updateConfigure )
|
|
21
21
|
.post( '/checklistConfigurev1', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), traxController.updateConfigurev1 )
|
|
22
22
|
.delete( '/deleteChecklist/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ 'isEdit' ] } ] } ), validate( duplicateValidation ), traxController.deleteChecklist )
|