tango-app-api-trax 3.5.2-alpha-7 → 3.5.2-alpha-9

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.5.2-alpha-7",
3
+ "version": "3.5.2-alpha-9",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -286,7 +286,11 @@ export async function approveChecklist( req, res ) {
286
286
  toDate.setUTCHours( 23, 59, 59, 59 );
287
287
  let query = { sourceCheckList_id: req.body.sourceCheckList_id, date_iso: { $gte: req.body.fromDate, $lte: toDate }, $or: [ { checklistStatus: 'submit' }, { redoStatus: true } ], approvalEnable: true };
288
288
  if ( req.body?.storeId?.length ) {
289
- query['store_id'] = { $in: req.body.storeId };
289
+ const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
290
+ query['store_id'] = { $in: filteredStoreIds };
291
+ }
292
+ if ( req.body?.userEmail?.length ) {
293
+ query['userEmail'] = { $in: req.body?.userEmail };
290
294
  }
291
295
  let checklistDetails = await processedChecklist.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1, client_id: 1, coverage: 1, checkListName: 1 } );
292
296
  if ( !checklistDetails.length ) {
@@ -324,7 +328,7 @@ export async function approveChecklist( req, res ) {
324
328
  approvalByEmail: req.user.email,
325
329
  },
326
330
  };
327
-
331
+ console.log( params );
328
332
  const requestOptions = {
329
333
  method: 'POST',
330
334
  headers: {
@@ -334,6 +338,8 @@ export async function approveChecklist( req, res ) {
334
338
  };
335
339
  let url = JSON.parse( process.env.LAMBDAURL );
336
340
  let searchResponse = await fetch( url.approveChecklist, requestOptions );
341
+ console.log( searchResponse );
342
+ const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
337
343
  let logData= {
338
344
  'client_id': checklistDetails[0].client_id,
339
345
  'createAt': new Date(),
@@ -351,7 +357,7 @@ export async function approveChecklist( req, res ) {
351
357
  'approved': storeNames,
352
358
  },
353
359
  'userType': req.user.userType,
354
- 'requestedStores': req.body.storeId,
360
+ 'requestedStores': filteredStoreIds,
355
361
  };
356
362
  console.log( 'logData', logData );
357
363
  let urlopensearch = JSON.parse( process.env.OPENSEARCH );