tango-app-api-trax 3.4.0-alpha-0 → 3.4.0-alpha-2

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.4.0-alpha-0",
3
+ "version": "3.4.0-alpha-2",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "mongodb": "^6.8.0",
27
27
  "nodemon": "^3.1.4",
28
28
  "path": "^0.12.7",
29
- "tango-api-schema": "^2.2.70",
30
- "tango-app-api-middleware": "^3.1.55",
29
+ "tango-api-schema": "^2.2.73",
30
+ "tango-app-api-middleware": "^3.1.66",
31
31
  "url": "^0.11.4",
32
32
  "winston": "^3.13.1",
33
33
  "winston-daily-rotate-file": "^5.0.0"
@@ -282,7 +282,7 @@ export async function approveChecklist( req, res ) {
282
282
  if ( req.body?.storeId?.length ) {
283
283
  query['store_id'] = { $in: req.body.storeId };
284
284
  }
285
- let checklistDetails = await processedChecklist.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1 } );
285
+ let checklistDetails = await processedChecklist.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1, client_id: 1, coverage: 1 } );
286
286
  if ( !checklistDetails.length ) {
287
287
  return res.sendError( 'No data found', 204 );
288
288
  }
@@ -317,6 +317,27 @@ export async function approveChecklist( req, res ) {
317
317
  let searchResponse = await fetch( url.approveChecklist, requestOptions );
318
318
 
319
319
  console.log( searchResponse.ok );
320
+
321
+ let logData= {
322
+ 'client_id': checklistDetails[0].client_id,
323
+ 'createAt': new Date(),
324
+ 'sourceCheckList_id': req.body.sourceCheckList_id,
325
+ 'checkListName': checklistDetails[0].checkListName,
326
+ 'fromCheckListName': checklistDetails[0].checkListName,
327
+ 'type': 'checklist',
328
+ 'action': 'approved',
329
+ 'storeName': '',
330
+ 'store_id': '',
331
+ 'createdByEmail': req.user.email,
332
+ 'createdBy': req.user._id,
333
+ 'coverage': checklistDetails[0].coverage,
334
+ 'logDetails': {
335
+ 'approved': [ 'LKST011', 'LKST022', 'LKST3444', 'LKST455', 'LKST566', 'LKST666', 'LKST766', 'LKST866', 'LkST966' ],
336
+ },
337
+ };
338
+ let urlopensearch = JSON.parse( process.env.OPENSEARCH );
339
+ console.log( 'logData', logData );
340
+ await insertOpenSearchData( urlopensearch.traxActivityLog, logData );
320
341
  if ( searchResponse.ok ) {
321
342
  let pendingstores = checklistDetails.filter( ( data ) => data.checklistStatus != 'submit' );
322
343
  if ( pendingstores && pendingstores.length > 0 ) {
@@ -350,7 +371,7 @@ export async function redoChecklist( req, res ) {
350
371
  }
351
372
 
352
373
 
353
- let checklistDetails = await processedChecklist.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1 } );
374
+ let checklistDetails = await processedChecklist.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1, coverage: 1, userEmail: 1 } );
354
375
  if ( !checklistDetails ) {
355
376
  return res.sendError( 'No data found', 204 );
356
377
  }
@@ -440,7 +461,26 @@ export async function redoChecklist( req, res ) {
440
461
  let url = JSON.parse( process.env.LAMBDAURL );
441
462
  let searchResponse = await fetch( url.redoChecklist, requestOptions );
442
463
  console.log( searchResponse.ok );
443
-
464
+ let logData= {
465
+ 'client_id': checklistDetails.client_id,
466
+ 'createAt': new Date(),
467
+ 'sourceCheckList_id': checklistDetails.sourceCheckList_id,
468
+ 'checkListName': checklistDetails.checkListName,
469
+ 'fromCheckListName': checklistDetails.checkListName,
470
+ 'type': 'checklist',
471
+ 'action': 'redo',
472
+ 'storeName': checklistDetails?.storeName?checklistDetails?.storeName:'',
473
+ 'store_id': checklistDetails?.store_id?checklistDetails?.store_id:'',
474
+ 'userName': checklistDetails.userName,
475
+ 'userEmail': checklistDetails.userEmail,
476
+ 'createdByEmail': req.user.email,
477
+ 'createdBy': req.user.userName,
478
+ 'coverage': checklistDetails.coverage,
479
+ 'logDetails': {},
480
+ };
481
+ let urlopensearch = JSON.parse( process.env.OPENSEARCH );
482
+ console.log( 'logData', logData );
483
+ await insertOpenSearchData( urlopensearch.traxActivityLog, logData );
444
484
  if ( searchResponse.ok ) {
445
485
  return res.sendSuccess( 'Question redo successfully' );
446
486
  } else {
@@ -568,6 +608,26 @@ export async function redomultiChecklist( req, res ) {
568
608
  let url = JSON.parse( process.env.LAMBDAURL );
569
609
  let searchResponse = await fetch( url.redoChecklist, requestOptions );
570
610
  console.log( searchResponse.ok );
611
+ let logData= {
612
+ 'client_id': checklistDetails.client_id,
613
+ 'createAt': new Date(),
614
+ 'sourceCheckList_id': checklistDetails.sourceCheckList_id,
615
+ 'checkListName': checklistDetails.checkListName,
616
+ 'fromCheckListName': checklistDetails.checkListName,
617
+ 'type': 'checklist',
618
+ 'action': 'redo',
619
+ 'storeName': checklistDetails?.storeName?checklistDetails?.storeName:'',
620
+ 'store_id': checklistDetails?.store_id?checklistDetails?.store_id:'',
621
+ 'userName': checklistDetails.userName,
622
+ 'userEmail': checklistDetails.userEmail,
623
+ 'createdByEmail': req.user.email,
624
+ 'createdBy': req.user.userName,
625
+ 'coverage': checklistDetails.coverage,
626
+ 'logDetails': {},
627
+ };
628
+ let urlopensearch = JSON.parse( process.env.OPENSEARCH );
629
+ console.log( 'logData', logData );
630
+ await insertOpenSearchData( urlopensearch.traxActivityLog, logData );
571
631
  }
572
632
  }
573
633
  return res.sendSuccess( 'Question redo successfully' );