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

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-8",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -286,7 +286,8 @@ 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 };
290
291
  }
291
292
  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
293
  if ( !checklistDetails.length ) {
@@ -324,7 +325,7 @@ export async function approveChecklist( req, res ) {
324
325
  approvalByEmail: req.user.email,
325
326
  },
326
327
  };
327
-
328
+ console.log( params );
328
329
  const requestOptions = {
329
330
  method: 'POST',
330
331
  headers: {
@@ -334,6 +335,8 @@ export async function approveChecklist( req, res ) {
334
335
  };
335
336
  let url = JSON.parse( process.env.LAMBDAURL );
336
337
  let searchResponse = await fetch( url.approveChecklist, requestOptions );
338
+ console.log( searchResponse );
339
+ const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
337
340
  let logData= {
338
341
  'client_id': checklistDetails[0].client_id,
339
342
  'createAt': new Date(),
@@ -351,7 +354,7 @@ export async function approveChecklist( req, res ) {
351
354
  'approved': storeNames,
352
355
  },
353
356
  'userType': req.user.userType,
354
- 'requestedStores': req.body.storeId,
357
+ 'requestedStores': filteredStoreIds,
355
358
  };
356
359
  console.log( 'logData', logData );
357
360
  let urlopensearch = JSON.parse( process.env.OPENSEARCH );