tango-app-api-analysis-traffic 3.0.0-alpha.3 → 3.0.0-alpha.4

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-analysis-traffic",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.4",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -407,8 +407,9 @@ export const headerLocationsV1 = async ( req, res ) => {
407
407
  try {
408
408
  let reqestData = req.body;
409
409
  let getUserEmail = req.user.email;
410
+ let getUserType = req.user.userType;
410
411
  let getClientId = reqestData.clientId;
411
- let totalStores = await getAllStores( getUserEmail, getClientId );
412
+ let totalStores = await getAllStores( getUserEmail, getClientId, getUserType );
412
413
  if ( totalStores && totalStores.length>0 ) {
413
414
  let storeQuery = [
414
415
  {
@@ -455,6 +456,7 @@ export const headerGroupsV1 = async ( req, res ) => {
455
456
  try {
456
457
  let requestData = req.body;
457
458
  let getUserEmail = req.user.email;
459
+ let getUserType = req.user.userType;
458
460
  const assignedQuery = {
459
461
  clientId: requestData.clientId,
460
462
  userEmail: getUserEmail,
@@ -474,7 +476,11 @@ export const headerGroupsV1 = async ( req, res ) => {
474
476
  groupIds = [];
475
477
  }
476
478
  } else {
477
- return res.sendError( 'No User Assign', 400 );
479
+ if ( getUserType == 'tango' ) {
480
+ groupIds = await getGroupIds( requestData.clientId );
481
+ } else {
482
+ return res.sendError( 'No User Assign', 400 );
483
+ }
478
484
  }
479
485
 
480
486
  if ( groupIds && groupIds.length > 0 ) {
@@ -514,8 +520,9 @@ export const headerStoresV1 = async ( req, res ) => {
514
520
  try {
515
521
  let reqestData = req.body;
516
522
  let getUserEmail = req.user.email;
523
+ let getUserType = req.user.userType;
517
524
  let getClientId = reqestData.clientId;
518
- let totalStores = await getAllStores( getUserEmail, getClientId );
525
+ let totalStores = await getAllStores( getUserEmail, getClientId, getUserType );
519
526
  if ( totalStores && totalStores.length>0 ) {
520
527
  let storeQuery = [];
521
528
  if ( reqestData.city.length>0 && reqestData.group.length>0 ) {
@@ -578,7 +585,7 @@ export const headerStoresV1 = async ( req, res ) => {
578
585
  },
579
586
  ];
580
587
  } else {
581
- let totalStores = await getAllStores( getUserEmail, getClientId );
588
+ let totalStores = await getAllStores( getUserEmail, getClientId, getUserType );
582
589
  storeQuery = [
583
590
  {
584
591
  $match: {
@@ -613,7 +620,7 @@ export const headerStoresV1 = async ( req, res ) => {
613
620
  }
614
621
  };
615
622
 
616
- async function getAllStores( getUserEmail, getClientId ) {
623
+ async function getAllStores( getUserEmail, getClientId, getUserType ) {
617
624
  try {
618
625
  if ( getUserEmail && getUserEmail !='' ) {
619
626
  const assignedQuery = {
@@ -662,7 +669,16 @@ async function getAllStores( getUserEmail, getClientId ) {
662
669
  return false;
663
670
  }
664
671
  } else {
665
- return false;
672
+ if ( getUserType && getUserType == 'tango' ) {
673
+ let overAllStores = [];
674
+ let getAllS = await getAssignedAllStores( getClientId );
675
+ if ( getAllS && getAllS.length >0 ) {
676
+ overAllStores = getAllS;
677
+ }
678
+ return overAllStores;
679
+ } else {
680
+ return false;
681
+ }
666
682
  }
667
683
  } else {
668
684
  return false;