tango-app-ui-analyse-zone 3.7.1-beta.13 → 3.7.1-beta.15

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.
@@ -2863,10 +2863,10 @@ class StoreHeatmapComponent {
2863
2863
  changeTab(tabName) {
2864
2864
  this.selectedTab = tabName;
2865
2865
  this.zoneName = tabName;
2866
+ this.type = 'daily';
2866
2867
  this.getOverallStoreHeatmapDates();
2867
2868
  this.getTrajectoryAnalysis();
2868
2869
  this.getTrajectoryRateAnalysis();
2869
- this.getAnalaysisSummary();
2870
2870
  this.changeDetector.detectChanges();
2871
2871
  }
2872
2872
  getAvailableZoneNames() {
@@ -2937,6 +2937,7 @@ class StoreHeatmapComponent {
2937
2937
  this.Zonev2Service.getOverallStoreConcentrationData(requestData).pipe(takeUntil(this.destroy$)).subscribe((response) => {
2938
2938
  this.heatmapLoading = false;
2939
2939
  if (response?.code === 200 && response?.status === "success") {
2940
+ this.formatDateInput(this.selectedDate);
2940
2941
  // this.overallStoreData = response.data.overallStoreConcentrationDatas;
2941
2942
  this.overallStoreconcentrationData = response.data.overallStoreConcentrationDatas;
2942
2943
  this.heatmapNoData = false;
@@ -2954,7 +2955,6 @@ class StoreHeatmapComponent {
2954
2955
  this.cardDataLoading = false;
2955
2956
  this.cardNoData = true;
2956
2957
  }
2957
- // this.getAnalaysisSummary()
2958
2958
  }, error => {
2959
2959
  this.overallStoreconcentrationData = [];
2960
2960
  // this.zoneConcentrationData = []
@@ -2967,70 +2967,54 @@ class StoreHeatmapComponent {
2967
2967
  this.customArrow = false;
2968
2968
  this.heatmapLoading = true;
2969
2969
  this.heatmapNoData = true;
2970
- // this.cardDataLoading = true;
2971
2970
  const requestData = {
2972
2971
  fromDate: this.headerData.date.startDate,
2973
2972
  toDate: this.headerData.date.endDate,
2974
- storeId: this.headerData.stores.filter((store) => store.checked).map((store) => store.storeId),
2973
+ storeId: this.headerData.stores.filter((s) => s.checked).map((s) => s.storeId),
2975
2974
  clientId: this.headerData.client,
2976
2975
  zoneName: this.zoneName,
2977
- dateType: this.type
2976
+ dateType: this.type,
2978
2977
  };
2979
- this.Zonev2Service.getOverallStoreHeatmapDates(requestData).pipe(takeUntil(this.destroy$)).subscribe((response) => {
2980
- if (response && response.data) {
2981
- this.overallStoreConcentrationDates = response.data.overallStoreConcentrationDates;
2982
- this.selectedDate = this.overallStoreConcentrationDates[0].zoneDate;
2983
- // if(['weekly','monthly'].includes(this.type)) {
2984
- // let lastDigit = this.overallStoreConcentrationDates[this.overallStoreConcentrationDates.length -1].zoneDate;
2985
- // let lastSplit = lastDigit.split('-')[1];
2986
- // lastSplit = lastSplit +' '+ this.dayjs().format('YYYY');
2987
- // if(this.dayjs(lastSplit,'MMM DD YYYY').format('YYYY-MM-DD') > this.dayjs(this.headerData.date.endDate).format('YYYY-MM-DD'))
2988
- // this.overallStoreConcentrationDates.splice(this.overallStoreConcentrationDates.length-1,1);
2989
- // }
2990
- if (response?.code === 200 && response?.status === "success" && response.data.overallStoreConcentrationDates.length) {
2991
- if (this.type === 'daily') {
2992
- if (response.data.overallStoreConcentrationDates.length > 7) {
2993
- this.customArrow = true;
2994
- }
2995
- }
2996
- else if (this.type === 'weekly') {
2997
- if (response.data.overallStoreConcentrationDates.length > 5) {
2998
- this.customArrow = true;
2999
- }
3000
- }
3001
- else {
3002
- }
2978
+ this.Zonev2Service.getOverallStoreHeatmapDates(requestData)
2979
+ .pipe(takeUntil(this.destroy$))
2980
+ .subscribe({
2981
+ next: (response) => {
2982
+ const data = response?.data?.overallStoreConcentrationDates || [];
2983
+ this.overallStoreConcentrationDates = data;
2984
+ this.heatmapLoading = false;
2985
+ if (response?.code === 200 && response?.status === 'success' && data.length) {
2986
+ this.selectedDate = data[0].zoneDate;
2987
+ // Show arrows based on count
2988
+ this.customArrow =
2989
+ (this.type === 'daily' && data.length > 7) ||
2990
+ (this.type === 'weekly' && data.length > 5);
2991
+ // Load dependent data
3003
2992
  this.getOverallStoreConcentrationData();
3004
- // this.heatmapLoading = false;
3005
- // this.heatmapNoData = false;
2993
+ this.getAnalaysisSummary();
3006
2994
  }
3007
2995
  else {
3008
- this.heatmapLoading = false;
3009
2996
  this.heatmapNoData = true;
3010
- // this.cardNoData = true;
3011
- // this.cardDataLoading = false;
2997
+ this.cardNoData = true;
2998
+ this.overallStoreConcentrationDates = [];
2999
+ this.overallStoreData = [];
3012
3000
  }
3013
- }
3014
- else {
3001
+ },
3002
+ error: () => {
3015
3003
  this.heatmapLoading = false;
3016
3004
  this.heatmapNoData = true;
3017
- }
3018
- }, error => {
3019
- this.heatmapLoading = false;
3020
- this.heatmapNoData = true;
3021
- // console.error('API call failed', error);
3005
+ },
3022
3006
  });
3023
3007
  }
3024
3008
  onDateChange(date) {
3025
3009
  if (this.selectedDate !== date) {
3026
3010
  this.selectedDate = date;
3027
3011
  this.getOverallStoreConcentrationData();
3012
+ this.getAnalaysisSummary();
3028
3013
  }
3029
3014
  }
3030
3015
  selectPlan(selectedType) {
3031
3016
  this.type = selectedType;
3032
- this.getOverallStoreHeatmapDates();
3033
- // this.getOverallStoreConcentrationData();
3017
+ this.getOverallStoreHeatmapDates(); // auto handles everything
3034
3018
  }
3035
3019
  onZoneClick(zoneName) {
3036
3020
  this.zoneName = zoneName;
@@ -3100,38 +3084,57 @@ class StoreHeatmapComponent {
3100
3084
  series.appear(1000, 100);
3101
3085
  }, 100);
3102
3086
  }
3087
+ // --- Utility: format date string (single or range)
3088
+ formatDateInput(dateStr) {
3089
+ if (!dateStr) {
3090
+ return { fromDate: this.headerData.date.startDate, toDate: this.headerData.date.endDate };
3091
+ }
3092
+ const formatLocalDate = (d) => {
3093
+ const date = new Date(d);
3094
+ const y = date.getFullYear();
3095
+ const m = String(date.getMonth() + 1).padStart(2, '0');
3096
+ const day = String(date.getDate()).padStart(2, '0');
3097
+ return `${y}-${m}-${day}`;
3098
+ };
3099
+ const parts = dateStr.split(' - ').map(p => p.trim());
3100
+ const from = formatLocalDate(parts[0]);
3101
+ const to = formatLocalDate(parts[1] || parts[0]);
3102
+ return { fromDate: from, toDate: to };
3103
+ }
3103
3104
  getAnalaysisSummary() {
3104
- this.cardDataLoading = true;
3105
- this.cardNoData = false;
3105
+ const { fromDate, toDate } = this.formatDateInput(this.selectedDate);
3106
3106
  const requestData = {
3107
- fromDate: this.headerData.date.startDate,
3108
- toDate: this.headerData.date.endDate,
3109
- storeId: this.headerData.stores.filter((store) => store.checked).map((store) => store.storeId),
3110
- // storeId: ["204"],
3107
+ fromDate,
3108
+ toDate,
3109
+ storeId: this.headerData.stores.filter((s) => s.checked).map((s) => s.storeId),
3111
3110
  clientId: this.headerData.client,
3112
3111
  zoneName: this.zoneName,
3113
3112
  };
3114
- this.Zonev2Service.getAnalaysisSummary(requestData).pipe(takeUntil(this.destroy$)).subscribe((response) => {
3115
- if (response && response.data && response.data.zoneConcentrationData && response.data.zoneConcentrationData.length > 0) {
3116
- this.overallStoreData = response.data.zoneConcentrationData[0]; // Get the first zone data
3117
- this.ageAnalysis = this.overallStoreData.ageAnalysis || [];
3118
- this.genderAnalysis = this.overallStoreData.genderAnalysis || [];
3119
- setTimeout(() => {
3120
- this.genderchart();
3121
- }, 200);
3113
+ this.cardDataLoading = true;
3114
+ this.cardNoData = false;
3115
+ this.Zonev2Service.getAnalaysisSummary(requestData)
3116
+ .pipe(takeUntil(this.destroy$))
3117
+ .subscribe({
3118
+ next: (response) => {
3119
+ const zoneData = response?.data?.zoneConcentrationData || [];
3120
+ if (zoneData.length) {
3121
+ this.overallStoreData = zoneData[0];
3122
+ this.ageAnalysis = this.overallStoreData.ageAnalysis || [];
3123
+ this.genderAnalysis = this.overallStoreData.genderAnalysis || [];
3124
+ setTimeout(() => this.genderchart(), 200);
3125
+ this.cardNoData = false;
3126
+ }
3127
+ else {
3128
+ this.overallStoreData = [];
3129
+ this.cardNoData = true;
3130
+ }
3122
3131
  this.cardDataLoading = false;
3123
- this.cardNoData = false;
3124
- }
3125
- else {
3126
- // this.cardData = []
3132
+ },
3133
+ error: () => {
3127
3134
  this.overallStoreData = [];
3128
3135
  this.cardDataLoading = false;
3129
3136
  this.cardNoData = true;
3130
- }
3131
- }, error => {
3132
- // this.cardData = []
3133
- this.overallStoreData = [];
3134
- this.changeDetector.detectChanges();
3137
+ },
3135
3138
  });
3136
3139
  }
3137
3140
  getAgeArray() {