tango-app-api-task 3.2.1-beta-21 → 3.2.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-task",
3
- "version": "3.2.1-beta-21",
3
+ "version": "3.2.1-beta-24",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -264,8 +264,8 @@ export async function taskDetails( req, res ) {
264
264
  }
265
265
  if ( storechecklistdetails ) {
266
266
  result.checkListDetails = { ...storechecklistdetails._doc };
267
- let assignedusers = await taskAssignService.find( { checkListId: storechecklistdetails._id }, { _id: 1 } );
268
- assignedusers = assignedusers?.map( ( item ) => item._id );
267
+ let assignedusers = await taskAssignService.find( { checkListId: storechecklistdetails._id }, { assignId: 1 } );
268
+ assignedusers = assignedusers?.map( ( item ) => item.assignId );
269
269
  result.checkListDetails = { ...result.checkListDetails, ...{ sections: sectionList }, ...{ assignedusers: assignedusers } };
270
270
  }
271
271
  return res.sendSuccess( result );
@@ -597,7 +597,7 @@ export async function userDetails( req, res ) {
597
597
  if ( ele?.clusterName ) {
598
598
  let clusterDetails = await clusterServices.findOneCluster( { _id: ele.assignId }, { stores: 1 } );
599
599
  if ( clusterDetails ) {
600
- let storeDetails = await storeService.find( { _id: { $in: clusterDetails.stores.map( ( item ) => item.store ) } } );
600
+ let storeDetails = await storeService.find( { _id: { $in: clusterDetails.stores.map( ( item ) => item.store ) }, status: 'active' } );
601
601
  storeDetails.forEach( ( item ) => {
602
602
  userDetails.push( {
603
603
  id: ele._id,
@@ -664,12 +664,16 @@ export async function taskConfig( req, res ) {
664
664
  return res.sendError( { message: 'Task Id is Required' }, 400 );
665
665
  }
666
666
 
667
- if ( inputBody.submitType == 'publish' ) {
668
- let checkUserAssigned = await taskAssignService.findOne( { checkListId: inputBody._id, checkFlag: true } );
669
- if ( !checkUserAssigned ) {
670
- return res.sendError( { message: 'Please assign a user' }, 400 );
671
- }
667
+ if ( !inputBody.assignedUsers.length && inputBody.submitType == 'publish' ) {
668
+ return res.sendError( 'Please Assigned a user', 400 );
672
669
  }
670
+
671
+ // if ( inputBody.submitType == 'publish' ) {
672
+ // let checkUserAssigned = await taskAssignService.findOne( { checkListId: inputBody._id, checkFlag: true } );
673
+ // if ( !checkUserAssigned ) {
674
+ // return res.sendError( { message: 'Please assign a user' }, 400 );
675
+ // }
676
+ // }
673
677
  if ( !inputBody?.approver.length && inputBody.submitType == 'publish' ) {
674
678
  return res.sendError( { message: 'Please assign approver' }, 400 );
675
679
  }
@@ -931,7 +935,7 @@ async function insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, date,
931
935
  let clusterDetails = await clusterServices.findcluster( { _id: { $in: clusterList } } );
932
936
  if ( clusterDetails.length ) {
933
937
  let idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
934
- let getStoreDetails = await storeService.find( { _id: { $in: idList } } );
938
+ let getStoreDetails = await storeService.find( { _id: { $in: idList }, status: 'active' } );
935
939
  if ( getStoreDetails.length ) {
936
940
  assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
937
941
  let userDetails = await userService.findOne( { email: store?.spocDetails?.[0]?.email, clientId: store.clientId } );
@@ -1524,6 +1528,7 @@ export async function approveTask( req, res ) {
1524
1528
  sourceCheckList_id: req.body.sourceCheckList_id,
1525
1529
  fromDate: req.body.fromDate,
1526
1530
  toDate: req.body.toDate,
1531
+ filtertype: req.body.filtertype,
1527
1532
  store_id: inputstores,
1528
1533
  },
1529
1534
  'upsert': {
@@ -2644,6 +2649,7 @@ export async function StoreHygienetask( req, res ) {
2644
2649
  export async function eyeTesttask( req, res ) {
2645
2650
  try {
2646
2651
  let inputBody = req.body;
2652
+ console.log( inputBody );
2647
2653
  inputBody.clientId = 11;
2648
2654
  inputBody.taskDescription = '';
2649
2655
  let userId;
@@ -2654,7 +2660,9 @@ export async function eyeTesttask( req, res ) {
2654
2660
 
2655
2661
  let url = JSON.parse( process.env.LAMBDAURL );
2656
2662
  let checklistId = url.dailystoreChecklistId;
2663
+ console.log( checklistId );
2657
2664
  let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
2665
+ console.log( finduser );
2658
2666
 
2659
2667
  if ( !finduser ) {
2660
2668
  return res.sendError( 'No user Found For this store', 500 );
@@ -2813,8 +2821,10 @@ export async function eyeTesttask( req, res ) {
2813
2821
  }
2814
2822
  question[0].questionReferenceImage = images;
2815
2823
  } else {
2824
+ console.log( req.file );
2816
2825
  let images = [];
2817
2826
  let uplaodedImage = await uploadmultiImage( req.files.referenceImage );
2827
+ console.log( uplaodedImage );
2818
2828
  let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
2819
2829
  let url = imgUrl.split( '/' );
2820
2830
  if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
@@ -3357,7 +3367,7 @@ export async function taskAssign( req, res ) {
3357
3367
  } else {
3358
3368
  idList = req.body.idList;
3359
3369
  }
3360
- let getStoreDetails = await storeService.find( { _id: { $in: idList } } );
3370
+ let getStoreDetails = await storeService.find( { _id: { $in: idList }, status: 'active' } );
3361
3371
  if ( !getStoreDetails.length ) {
3362
3372
  return res.sendError( 'No data found', 204 );
3363
3373
  }
@@ -3440,7 +3450,6 @@ async function assignUsers( data ) {
3440
3450
  },
3441
3451
  ];
3442
3452
  let clusterDetails = await clusterServices.aggregateCluster( query );
3443
- console.log( clusterDetails );
3444
3453
  if ( clusterDetails.length ) {
3445
3454
  if ( !data.upload ) {
3446
3455
  assignedData = {
@@ -3454,7 +3463,7 @@ async function assignUsers( data ) {
3454
3463
  };
3455
3464
  } else {
3456
3465
  let clusterList = clusterDetails[0].stores.map( ( ele ) => ele.store );
3457
- let storeDetails = await storeService.find( { _id: clusterList } );
3466
+ let storeDetails = await storeService.find( { _id: { $in: clusterList }, status: 'active' } );
3458
3467
  assignedData = await Promise.all( storeDetails.map( async ( store ) => {
3459
3468
  let userDetails = await userService.findOne( { email: store.spocDetails?.[0]?.email, clientId: data.clientId } );
3460
3469
  if ( !userDetails ) {
@@ -3650,13 +3659,15 @@ export async function assignTaskUser( req, res ) {
3650
3659
  assign.clientId = inputBody.clientId;
3651
3660
  assign.upload = inputBody.type;
3652
3661
  let uploadData = await assignUsers( assign );
3653
- if ( Array.isArray( uploadData ) ) {
3654
- assignData.push( ...uploadData );
3655
- } else {
3656
- assignData.push( uploadData );
3662
+ if ( uploadData ) {
3663
+ if ( Array.isArray( uploadData ) ) {
3664
+ assignData.push( ...uploadData );
3665
+ } else {
3666
+ assignData.push( uploadData );
3667
+ }
3657
3668
  }
3658
3669
  } ) );
3659
- return res.sendSuccess( { idList: [ ...new Set( assignData.map( ( item ) => item.assignId ) ) ], assignData } );
3670
+ return res.sendSuccess( { idList: [ ...new Set( assignData.map( ( item ) => item?.assignId?.toString() ) ) ], assignData } );
3660
3671
  } catch ( e ) {
3661
3672
  logger.error( { functionName: 'assignTaskUser', error: e } );
3662
3673
  return res.sendError( e, 500 );