tango-app-api-trax 3.5.2-alpha-10 → 3.5.2-alpha-11
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
|
@@ -288,14 +288,12 @@ export async function approveChecklist( req, res ) {
|
|
|
288
288
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
289
289
|
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
290
290
|
let query = { sourceCheckList_id: req.body.sourceCheckList_id, date_iso: { $gte: req.body.fromDate, $lte: toDate }, $or: [ { checklistStatus: 'submit' }, { redoStatus: true } ], approvalEnable: true };
|
|
291
|
+
if ( !( req.body.assignedStores && req.body.assignedStores.length >0 ) ) {
|
|
292
|
+
req.body.assignedStores = req.body.storeId;
|
|
293
|
+
}
|
|
291
294
|
if ( req.body?.storeId?.length ) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
query['store_id'] = { $in: filteredStoreIds };
|
|
295
|
-
} else {
|
|
296
|
-
const filteredStoreIds = req.body?.storeId;
|
|
297
|
-
query['store_id'] = { $in: filteredStoreIds };
|
|
298
|
-
}
|
|
295
|
+
const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
|
|
296
|
+
query['store_id'] = { $in: filteredStoreIds };
|
|
299
297
|
}
|
|
300
298
|
if ( req.body?.userEmail?.length ) {
|
|
301
299
|
query['userEmail'] = { $in: req.body?.userEmail };
|
|
@@ -336,7 +334,7 @@ export async function approveChecklist( req, res ) {
|
|
|
336
334
|
approvalByEmail: req.user.email,
|
|
337
335
|
},
|
|
338
336
|
};
|
|
339
|
-
|
|
337
|
+
console.log( params );
|
|
340
338
|
const requestOptions = {
|
|
341
339
|
method: 'POST',
|
|
342
340
|
headers: {
|
|
@@ -386,7 +384,7 @@ export async function approveChecklist( req, res ) {
|
|
|
386
384
|
return res.sendError( `${redoList.length} stores has not been approved since those stores are not submitted`, 400 );
|
|
387
385
|
}
|
|
388
386
|
} catch ( e ) {
|
|
389
|
-
console.log( 'e', e );
|
|
387
|
+
// console.log( 'e', e );
|
|
390
388
|
logger.error( { function: 'approveChecklist', error: e } );
|
|
391
389
|
return res.sendError( e, 500 );
|
|
392
390
|
}
|