tango-app-api-trax 3.3.1-beta-28 → 3.3.1-beta-29

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-28",
3
+ "version": "3.3.1-beta-29",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1492,6 +1492,7 @@ export const updateConfigurev1 =async ( req, res ) => {
1492
1492
  approver: inputBody?.checkListDetails?.approver.length ? inputBody?.checkListDetails?.approver.map( ( item ) => {
1493
1493
  return { name: item.name, value: item.value };
1494
1494
  } ) : [],
1495
+ storeCount: inputBody.checkListDetails?.assignedUsers?.length || 0,
1495
1496
  };
1496
1497
 
1497
1498
  if ( inputBody?.checkListDetails?.approver.length ) {
@@ -1578,14 +1579,11 @@ export const updateConfigurev1 =async ( req, res ) => {
1578
1579
  clientId: req.body.clientId,
1579
1580
  checkListName: checklistDetails.checkListName,
1580
1581
  checklistId: checklistDetails._id,
1581
- coverage: checklistDetails.coverage,
1582
+ coverage: inputBody?.checkListDetails.coverage,
1582
1583
  };
1583
1584
  await assignUsers( data );
1584
1585
  } ) );
1585
1586
  }
1586
- if ( inputBody.coverage ) {
1587
- await assignedService.deleteMany( { coverage: { $ne: inputBody.coverage } } );
1588
- }
1589
1587
  if ( inputBody.submitType == 'publish' ) {
1590
1588
  if ( inputBody.checkListDetails.checkListType == 'custom' ) {
1591
1589
  let currentDate = dayjs.utc().format();
@@ -2065,9 +2063,6 @@ export async function assignChecklistUser( req, res ) {
2065
2063
  if ( !checklistDetails ) {
2066
2064
  return res.sendError( 'No data found', 204 );
2067
2065
  }
2068
- if ( inputBody.type == 'upload' ) {
2069
- await assignedService.deleteMany( { checkListId: inputBody.checklistId } );
2070
- }
2071
2066
  await Promise.all( newUsers.map( async ( user ) => {
2072
2067
  let getUser = inputBody.assignUsers.find( ( ele ) => ele.userEmail.toLowerCase() == user.toLowerCase() );
2073
2068
  let userData = {
@@ -3609,7 +3604,7 @@ async function assignUsers( data ) {
3609
3604
  },
3610
3605
  },
3611
3606
  ];
3612
- let clusterDetails = await clusterServices.aggregate( query );
3607
+ let clusterDetails = await clusterServices.aggregateCluster( query );
3613
3608
  if ( clusterDetails.length ) {
3614
3609
  assignedData = {
3615
3610
  checkFlag: true,
@@ -3761,9 +3756,10 @@ export async function checklistAssign( req, res ) {
3761
3756
  if ( req.body.coverage == 'store' ) {
3762
3757
  let clusterDetails = await clusterServices.findcluster( { _id: { $in: req.body.idList } }, { stores: 1, clusterName: 1 } );
3763
3758
  if ( clusterDetails.length ) {
3764
- idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
3765
- let storeList = clusterDetails.filter( ( ele ) => !req.body.idList.includes( ele._id.toString() ) ).map( ( ele ) => ele._id );
3766
- idList = [ ...idList, ...storeList ];
3759
+ idList = [
3760
+ ...clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) ),
3761
+ ...clusterDetails.filter( ( ele ) => !req.body.idList.includes( ele._id.toString() ) ).map( ( ele ) => ele._id ),
3762
+ ];
3767
3763
  } else {
3768
3764
  idList = req.body.idList;
3769
3765
  }
@@ -3796,9 +3792,10 @@ export async function checklistAssign( req, res ) {
3796
3792
  } else {
3797
3793
  let teamDetails = await teamsServices.findteams( { _id: { $in: req.body.idList } }, { users: 1, teamName: 1 } );
3798
3794
  if ( teamDetails.length ) {
3799
- idList = teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) );
3800
- let userList = teamDetails.filter( ( ele ) => !req.body.idList.includes( ele._id.toString() ) );
3801
- idList = [ ...idList, ...userList ];
3795
+ idList = [
3796
+ ...teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) ),
3797
+ ...teamDetails.filter( ( ele ) => !req.body.idList.includes( ele._id.toString() ) ).map( ( ele ) => ele._id ),
3798
+ ];
3802
3799
  } else {
3803
3800
  idList = req.body.idList;
3804
3801
  }
@@ -3824,39 +3821,3 @@ export async function checklistAssign( req, res ) {
3824
3821
  }
3825
3822
  }
3826
3823
 
3827
- // export async function removeAssign( req, res ) {
3828
- // try {
3829
- // if ( !req.body.id ) {
3830
- // return res.sendError( 'Id is required', 400 );
3831
- // }
3832
- // if ( !req.body.checkListId ) {
3833
- // return res.sendError( 'Checklist id is required', 400 );
3834
- // }
3835
- // let checklistDetails = await checklistService.findOne( { _id: req.body.checkListId } );
3836
- // if ( !checklistDetails ) {
3837
- // return res.sendError( 'No data found', 204 );
3838
- // }
3839
- // await assignedService.deleteMany( { assignId: { $in: req.body.id } } );
3840
- // return res.sendSuccess( 'Details removed successfully' );
3841
- // } catch ( e ) {
3842
- // logger.error( { functionName: 'removeAssign', error: e } );
3843
- // return res.sendError( e, 500 );
3844
- // }
3845
- // }
3846
-
3847
- // export async function deleteAssignList( req, res ) {
3848
- // try {
3849
- // if ( !req.body.checkListId ) {
3850
- // return res.sendError( 'Checklist id is required', 400 );
3851
- // }
3852
- // let checklistDetails = await checklistService.findOne( { _id: req.body.checkListId, isdeleted: false } );
3853
- // if ( !checklistDetails ) {
3854
- // return res.sendError( 'No data found', 204 );
3855
- // }
3856
- // await assignedService.updateMany( { checkListId: req.body.checkListId }, { isdeleted: true } );
3857
- // return res.sendSuccess( 'Assign details removed successfully' );
3858
- // } catch ( e ) {
3859
- // logger.error( { functionName: 'deleteAssignList', error: e } );
3860
- // return res.sendError( e, 500 );
3861
- // }
3862
- // }