tango-app-api-task 3.2.1-beta-25 → 3.2.1-beta-27

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-task",
3
- "version": "3.2.1-beta-25",
3
+ "version": "3.2.1-beta-27",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1143,6 +1143,7 @@ export async function uploadImage( req, res ) {
1143
1143
 
1144
1144
  async function createUser( data ) {
1145
1145
  try {
1146
+ console.log( 'createUser ====>', data );
1146
1147
  let params = {
1147
1148
  userName: data.userName,
1148
1149
  email: data.email,
@@ -1225,7 +1226,8 @@ async function createUser( data ) {
1225
1226
  ],
1226
1227
  };
1227
1228
  let response = await userService.create( params );
1228
- return response._id;
1229
+ // console.log( 'createUser ====>', response );
1230
+ return response;
1229
1231
  } catch ( e ) {
1230
1232
  logger.error( 'createUser =>', e );
1231
1233
  return false;
@@ -3357,6 +3359,26 @@ export async function taskAssign( req, res ) {
3357
3359
  }
3358
3360
  let assignList = [];
3359
3361
 
3362
+ // for ( let data of req.body.idList ) {
3363
+ // let assignedData = {
3364
+ // ...data,
3365
+ // clientId: req.body.clientId,
3366
+ // checkListName: taskDetails.checkListName,
3367
+ // checklistId: taskDetails._id,
3368
+ // coverage: req.body.coverage,
3369
+ // insert: false,
3370
+ // };
3371
+ // // console.log( assignedData, 'daterthj' );
3372
+ // let uploadData = await assignUsers( assignedData );
3373
+ // if ( uploadData ) {
3374
+ // if ( Array.isArray( uploadData ) ) {
3375
+ // assignList.push( ...uploadData );
3376
+ // } else {
3377
+ // assignList.push( uploadData );
3378
+ // }
3379
+ // }
3380
+ // }
3381
+
3360
3382
  await Promise.all( req.body.idList.map( async ( data ) => {
3361
3383
  let assignedData = {
3362
3384
  ...data,
@@ -3386,6 +3408,7 @@ export async function taskAssign( req, res ) {
3386
3408
  }
3387
3409
 
3388
3410
  async function assignUsers( data ) {
3411
+ console.log( data );
3389
3412
  let assignedData;
3390
3413
  if ( data.coverage == 'store' ) {
3391
3414
  if ( data?.type == 'cluster' ) {
@@ -3469,7 +3492,7 @@ async function assignUsers( data ) {
3469
3492
  ];
3470
3493
  let storeDetails = await storeService.aggregate( query );
3471
3494
  if ( storeDetails.length ) {
3472
- let email = !data?.insert ? data.userEmail : storeDetails?.[0]?.spocDetails?.[0]?.email;
3495
+ let email = data?.userEmail ? data.userEmail : storeDetails?.[0]?.spocDetails?.[0]?.email;
3473
3496
  let userDetails = await userService.findOne( { email: email, clientId: data.clientId } );
3474
3497
  if ( !userDetails ) {
3475
3498
  let userData = {
@@ -3479,6 +3502,7 @@ async function assignUsers( data ) {
3479
3502
  clientId: data.clientId,
3480
3503
  };
3481
3504
  userDetails = await createUser( userData );
3505
+ console.log( 'userDetails =>', userDetails );
3482
3506
  }
3483
3507
  assignedData = {
3484
3508
  store_id: storeDetails?.[0]?.storeId,
@@ -3591,7 +3615,7 @@ async function assignUsers( data ) {
3591
3615
 
3592
3616
  // console.log( assignedData, 'test', data );
3593
3617
  if ( assignedData && !data.upload && data.insert ) {
3594
- await assignedService.updateOne( { checkListId: assignedData.checkListId, assignId: assignedData.assignId }, assignedData );
3618
+ await taskAssignService.updateOne( { checkListId: assignedData.checkListId, assignId: assignedData.assignId }, assignedData );
3595
3619
  } else {
3596
3620
  return assignedData;
3597
3621
  }
@@ -3606,16 +3630,26 @@ export async function assignTaskUser( req, res ) {
3606
3630
  if ( !taskDetails ) {
3607
3631
  return res.sendError( 'No data found', 204 );
3608
3632
  }
3609
- await Promise.all( newUsers.map( async ( user ) => {
3610
- let getUser = inputBody.assignUsers.find( ( ele ) => ele.userEmail.toLowerCase() == user.toLowerCase() );
3633
+ // await Promise.all( newUsers.map( async ( user ) => {
3634
+ // let getUser = inputBody.assignUsers.find( ( ele ) => ele.userEmail.toLowerCase() == user.toLowerCase() );
3635
+ // let userData = {
3636
+ // userName: getUser.userName,
3637
+ // email: user,
3638
+ // mobileNumber: getUser?.phone,
3639
+ // clientId: inputBody.clientId,
3640
+ // };
3641
+ // await createUser( userData );
3642
+ // } ) );
3643
+ for ( let i = 0; i < newUsers.length; i++ ) {
3644
+ let getUser = inputBody.assignUsers.find( ( ele ) => ele.userEmail.toLowerCase() == newUsers[i].toLowerCase() );
3611
3645
  let userData = {
3612
3646
  userName: getUser.userName,
3613
- email: user,
3647
+ email: newUsers[i],
3614
3648
  mobileNumber: getUser?.phone,
3615
3649
  clientId: inputBody.clientId,
3616
3650
  };
3617
3651
  await createUser( userData );
3618
- } ) );
3652
+ }
3619
3653
  let assignData = [];
3620
3654
  await Promise.all( assignDetails.map( async ( assign ) => {
3621
3655
  assign.checklistId = inputBody.taskId;
@@ -20,6 +20,10 @@ export const updateOne = async ( query = {}, record={} ) => {
20
20
  return model.userModel.updateOne( query, { $set: record } );
21
21
  };
22
22
 
23
+ export const upsert = async ( query = {}, record={} ) => {
24
+ return model.userModel.updateOne( query, { $set: record }, { upsert: true } );
25
+ };
26
+
23
27
  export const aggregate = async ( query = {} ) => {
24
28
  return model.userModel.aggregate( query );
25
29
  };