tango-app-api-trax 3.5.2-alpha-8 → 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 +16 -5
- package/src/hbs/login-otp.hbs +943 -943
package/package.json
CHANGED
|
@@ -280,14 +280,25 @@ 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
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if ( req.body?.userEmail?.length ) {
|
|
301
|
+
query['userEmail'] = { $in: req.body?.userEmail };
|
|
291
302
|
}
|
|
292
303
|
let checklistDetails = await processedChecklist.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1, client_id: 1, coverage: 1, checkListName: 1 } );
|
|
293
304
|
if ( !checklistDetails.length ) {
|
|
@@ -325,7 +336,7 @@ export async function approveChecklist( req, res ) {
|
|
|
325
336
|
approvalByEmail: req.user.email,
|
|
326
337
|
},
|
|
327
338
|
};
|
|
328
|
-
console.log( params );
|
|
339
|
+
// console.log( params );
|
|
329
340
|
const requestOptions = {
|
|
330
341
|
method: 'POST',
|
|
331
342
|
headers: {
|
|
@@ -335,7 +346,7 @@ export async function approveChecklist( req, res ) {
|
|
|
335
346
|
};
|
|
336
347
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
337
348
|
let searchResponse = await fetch( url.approveChecklist, requestOptions );
|
|
338
|
-
console.log( searchResponse );
|
|
349
|
+
// console.log( searchResponse );
|
|
339
350
|
const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
|
|
340
351
|
let logData= {
|
|
341
352
|
'client_id': checklistDetails[0].client_id,
|
|
@@ -375,7 +386,7 @@ export async function approveChecklist( req, res ) {
|
|
|
375
386
|
return res.sendError( `${redoList.length} stores has not been approved since those stores are not submitted`, 400 );
|
|
376
387
|
}
|
|
377
388
|
} catch ( e ) {
|
|
378
|
-
|
|
389
|
+
console.log( 'e', e );
|
|
379
390
|
logger.error( { function: 'approveChecklist', error: e } );
|
|
380
391
|
return res.sendError( e, 500 );
|
|
381
392
|
}
|