tango-app-api-trax 3.5.2-alpha-9 → 3.5.2-alpha-10
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 +1 -1
- package/src/controllers/gallery.controller.js +13 -5
- package/src/hbs/login-otp.hbs +943 -943
package/package.json
CHANGED
|
@@ -280,14 +280,22 @@ export const checklistDropdown = async ( req, res ) => {
|
|
|
280
280
|
|
|
281
281
|
export async function approveChecklist( req, res ) {
|
|
282
282
|
try {
|
|
283
|
+
if ( !( req.body.storeId.length > 0 || req.body.userEmail.length > 0 ) ) {
|
|
284
|
+
return res.sendError( 'StoreId or user Email required', 400 );
|
|
285
|
+
}
|
|
283
286
|
let toDate = new Date( req.body.toDate );
|
|
284
287
|
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
285
288
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
286
289
|
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
287
290
|
let query = { sourceCheckList_id: req.body.sourceCheckList_id, date_iso: { $gte: req.body.fromDate, $lte: toDate }, $or: [ { checklistStatus: 'submit' }, { redoStatus: true } ], approvalEnable: true };
|
|
288
291
|
if ( req.body?.storeId?.length ) {
|
|
289
|
-
|
|
290
|
-
|
|
292
|
+
if ( req.body.assignedStores && req.body.assignedStores.length > 0 ) {
|
|
293
|
+
const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
|
|
294
|
+
query['store_id'] = { $in: filteredStoreIds };
|
|
295
|
+
} else {
|
|
296
|
+
const filteredStoreIds = req.body?.storeId;
|
|
297
|
+
query['store_id'] = { $in: filteredStoreIds };
|
|
298
|
+
}
|
|
291
299
|
}
|
|
292
300
|
if ( req.body?.userEmail?.length ) {
|
|
293
301
|
query['userEmail'] = { $in: req.body?.userEmail };
|
|
@@ -328,7 +336,7 @@ export async function approveChecklist( req, res ) {
|
|
|
328
336
|
approvalByEmail: req.user.email,
|
|
329
337
|
},
|
|
330
338
|
};
|
|
331
|
-
console.log( params );
|
|
339
|
+
// console.log( params );
|
|
332
340
|
const requestOptions = {
|
|
333
341
|
method: 'POST',
|
|
334
342
|
headers: {
|
|
@@ -338,7 +346,7 @@ export async function approveChecklist( req, res ) {
|
|
|
338
346
|
};
|
|
339
347
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
340
348
|
let searchResponse = await fetch( url.approveChecklist, requestOptions );
|
|
341
|
-
console.log( searchResponse );
|
|
349
|
+
// console.log( searchResponse );
|
|
342
350
|
const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
|
|
343
351
|
let logData= {
|
|
344
352
|
'client_id': checklistDetails[0].client_id,
|
|
@@ -378,7 +386,7 @@ export async function approveChecklist( req, res ) {
|
|
|
378
386
|
return res.sendError( `${redoList.length} stores has not been approved since those stores are not submitted`, 400 );
|
|
379
387
|
}
|
|
380
388
|
} catch ( e ) {
|
|
381
|
-
|
|
389
|
+
console.log( 'e', e );
|
|
382
390
|
logger.error( { function: 'approveChecklist', error: e } );
|
|
383
391
|
return res.sendError( e, 500 );
|
|
384
392
|
}
|