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

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,51 @@ 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;
3012
2997
  }
3013
- }
3014
- else {
2998
+ },
2999
+ error: () => {
3015
3000
  this.heatmapLoading = false;
3016
3001
  this.heatmapNoData = true;
3017
- }
3018
- }, error => {
3019
- this.heatmapLoading = false;
3020
- this.heatmapNoData = true;
3021
- // console.error('API call failed', error);
3002
+ },
3022
3003
  });
3023
3004
  }
3024
3005
  onDateChange(date) {
3025
3006
  if (this.selectedDate !== date) {
3026
3007
  this.selectedDate = date;
3027
3008
  this.getOverallStoreConcentrationData();
3009
+ this.getAnalaysisSummary();
3028
3010
  }
3029
3011
  }
3030
3012
  selectPlan(selectedType) {
3031
3013
  this.type = selectedType;
3032
- this.getOverallStoreHeatmapDates();
3033
- // this.getOverallStoreConcentrationData();
3014
+ this.getOverallStoreHeatmapDates(); // auto handles everything
3034
3015
  }
3035
3016
  onZoneClick(zoneName) {
3036
3017
  this.zoneName = zoneName;
@@ -3100,38 +3081,57 @@ class StoreHeatmapComponent {
3100
3081
  series.appear(1000, 100);
3101
3082
  }, 100);
3102
3083
  }
3084
+ // --- Utility: format date string (single or range)
3085
+ formatDateInput(dateStr) {
3086
+ if (!dateStr) {
3087
+ return { fromDate: this.headerData.date.startDate, toDate: this.headerData.date.endDate };
3088
+ }
3089
+ const formatLocalDate = (d) => {
3090
+ const date = new Date(d);
3091
+ const y = date.getFullYear();
3092
+ const m = String(date.getMonth() + 1).padStart(2, '0');
3093
+ const day = String(date.getDate()).padStart(2, '0');
3094
+ return `${y}-${m}-${day}`;
3095
+ };
3096
+ const parts = dateStr.split(' - ').map(p => p.trim());
3097
+ const from = formatLocalDate(parts[0]);
3098
+ const to = formatLocalDate(parts[1] || parts[0]);
3099
+ return { fromDate: from, toDate: to };
3100
+ }
3103
3101
  getAnalaysisSummary() {
3104
- this.cardDataLoading = true;
3105
- this.cardNoData = false;
3102
+ const { fromDate, toDate } = this.formatDateInput(this.selectedDate);
3106
3103
  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"],
3104
+ fromDate,
3105
+ toDate,
3106
+ storeId: this.headerData.stores.filter((s) => s.checked).map((s) => s.storeId),
3111
3107
  clientId: this.headerData.client,
3112
3108
  zoneName: this.zoneName,
3113
3109
  };
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);
3110
+ this.cardDataLoading = true;
3111
+ this.cardNoData = false;
3112
+ this.Zonev2Service.getAnalaysisSummary(requestData)
3113
+ .pipe(takeUntil(this.destroy$))
3114
+ .subscribe({
3115
+ next: (response) => {
3116
+ const zoneData = response?.data?.zoneConcentrationData || [];
3117
+ if (zoneData.length) {
3118
+ this.overallStoreData = zoneData[0];
3119
+ this.ageAnalysis = this.overallStoreData.ageAnalysis || [];
3120
+ this.genderAnalysis = this.overallStoreData.genderAnalysis || [];
3121
+ setTimeout(() => this.genderchart(), 200);
3122
+ this.cardNoData = false;
3123
+ }
3124
+ else {
3125
+ this.overallStoreData = [];
3126
+ this.cardNoData = true;
3127
+ }
3122
3128
  this.cardDataLoading = false;
3123
- this.cardNoData = false;
3124
- }
3125
- else {
3126
- // this.cardData = []
3129
+ },
3130
+ error: () => {
3127
3131
  this.overallStoreData = [];
3128
3132
  this.cardDataLoading = false;
3129
3133
  this.cardNoData = true;
3130
- }
3131
- }, error => {
3132
- // this.cardData = []
3133
- this.overallStoreData = [];
3134
- this.changeDetector.detectChanges();
3134
+ },
3135
3135
  });
3136
3136
  }
3137
3137
  getAgeArray() {