tango-app-api-trax 3.5.2-alpha-11 → 3.5.2-alpha-12
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
|
|
|
3
|
-
import { logger, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
3
|
+
import { logger, insertOpenSearchData, sendTeamsNotification } from 'tango-app-api-middleware';
|
|
4
4
|
import * as storeService from '../services/store.service.js';
|
|
5
5
|
import * as groupService from '../services/group.service.js';
|
|
6
6
|
import * as clusterService from '../services/cluster.service.js';
|
|
@@ -298,7 +298,8 @@ export async function approveChecklist( req, res ) {
|
|
|
298
298
|
if ( req.body?.userEmail?.length ) {
|
|
299
299
|
query['userEmail'] = { $in: req.body?.userEmail };
|
|
300
300
|
}
|
|
301
|
-
let checklistDetails = await processedChecklist.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1, client_id: 1, coverage: 1, checkListName: 1 } );
|
|
301
|
+
let checklistDetails = await processedChecklist.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1, client_id: 1, coverage: 1, checkListName: 1, sourceCheckList_id: 1 } );
|
|
302
|
+
// console.log( 'checklistDetails =>', checklistDetails );
|
|
302
303
|
if ( !checklistDetails.length ) {
|
|
303
304
|
return res.sendError( 'No data found', 204 );
|
|
304
305
|
}
|
|
@@ -313,7 +314,19 @@ export async function approveChecklist( req, res ) {
|
|
|
313
314
|
approvalByEmail: req.user.email,
|
|
314
315
|
};
|
|
315
316
|
let updateResponse = await processedChecklist.updateMany( { _id: { $in: idList }, approvalStatus: false }, approvalUpdateData );
|
|
317
|
+
|
|
318
|
+
let teamsMsg;
|
|
319
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
320
|
+
teamsMsg = 'ClientId: '+ checklistDetails[0].client_id + ', Type: Checklist, Process: started, Action: Approval, ChecklistId: '+ checklistDetails[0].sourceCheckList_id + ', Checklist Name: '+ checklistDetails[0].checkListName +', UpDatedBy: '+ req.user.email;
|
|
321
|
+
if ( teamsAlertUrls && teamsAlertUrls.approvalAlert ) {
|
|
322
|
+
sendTeamsNotification( teamsAlertUrls.approvalAlert, teamsMsg );
|
|
323
|
+
}
|
|
324
|
+
|
|
316
325
|
if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
|
|
326
|
+
teamsMsg = 'ClientId: '+ checklistDetails[0].client_id + ', Type: Checklist, Process: Completed, Updated Count: '+updateResponse.modifiedCount+' Action: Approval, ChecklistId: '+ checklistDetails[0].sourceCheckList_id + ', Checklist Name: '+ checklistDetails[0].checkListName +', UpDatedBy: '+ req.user.email;
|
|
327
|
+
if ( teamsAlertUrls && teamsAlertUrls.approvalAlert ) {
|
|
328
|
+
sendTeamsNotification( teamsAlertUrls.approvalAlert, teamsMsg );
|
|
329
|
+
}
|
|
317
330
|
let inputstores = checklistDetails.filter( ( data ) => data.checklistStatus == 'submit' );
|
|
318
331
|
let storeNames = inputstores.map( ( data ) => data.storeName );
|
|
319
332
|
|
|
@@ -364,6 +377,7 @@ export async function approveChecklist( req, res ) {
|
|
|
364
377
|
},
|
|
365
378
|
'userType': req.user.userType,
|
|
366
379
|
'requestedStores': filteredStoreIds,
|
|
380
|
+
'requestedUsers': req.body.userEmail,
|
|
367
381
|
};
|
|
368
382
|
console.log( 'logData', logData );
|
|
369
383
|
let urlopensearch = JSON.parse( process.env.OPENSEARCH );
|