tango-app-api-trax 3.3.1-beta-55 → 3.3.1-beta-56

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-trax",
3
- "version": "3.3.1-beta-55",
3
+ "version": "3.3.1-beta-56",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2090,9 +2090,24 @@ export const validateUserv1 = async ( req, res ) => {
2090
2090
  } );
2091
2091
  }
2092
2092
 
2093
- if ( newUserList.length || newStoreList.length || existEmail.length ) {
2093
+ if ( ( newUserList.length || newStoreList.length || existEmail.length ) && !req.body?.addUser ) {
2094
2094
  return res.sendError( { validate: false, user: newUserList, store: newStoreList, existEmail, data: assignDetails }, 400 );
2095
2095
  }
2096
+ if ( req.body.coverage == 'user' ) {
2097
+ await Promise.all( newUserList.map( async ( ele ) => {
2098
+ let findUser = assignDetails.findIndex( ( item ) => item?.userEmail?.toLowerCase() == ele?.toLowerCase() );
2099
+ if ( findUser != -1 ) {
2100
+ let data = {
2101
+ userName: findUser.userName,
2102
+ email: ele,
2103
+ mobileNumber: findUser?.mobileNumber,
2104
+ clientId: req.body.clientId,
2105
+ };
2106
+ let response = await createUser( data );
2107
+ findUser._id = response._id;
2108
+ }
2109
+ } ) );
2110
+ }
2096
2111
  return res.sendSuccess( { validate: true, data: assignDetails } );
2097
2112
  } catch ( e ) {
2098
2113
  logger.error( 'validateUser 2=>', e );
@@ -3595,6 +3610,7 @@ async function assignUsers( data ) {
3595
3610
  }
3596
3611
  } else {
3597
3612
  let teamDetails = await teamsServices.findteams( { clientId: data.clientId, _id: new mongoose.Types.ObjectId( data.id ) } );
3613
+ console.log( teamDetails, 'team' );
3598
3614
  if ( teamDetails.length ) {
3599
3615
  let userIdList = teamDetails[0].users.map( ( ele ) => ele.userId );
3600
3616
  let userDetails = await userService.find( { _id: userIdList } );
@@ -3688,7 +3704,7 @@ export async function updateAssign( req, res ) {
3688
3704
  }
3689
3705
  let data = {
3690
3706
  ...assign,
3691
- store_id: assign.storeId,
3707
+ store_id: assign?.storeId,
3692
3708
  client_id: req.body.clientId,
3693
3709
  checkListId: req.body.checkListId,
3694
3710
  coverage: req.body.coverage,