@eric-emg/symphiq-components 1.2.282 → 1.2.284

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.
@@ -2676,16 +2676,20 @@ const DERIVED_METRICS$1 = new Set([
2676
2676
  function isDerivedMetric$1(metric) {
2677
2677
  return DERIVED_METRICS$1.has(metric);
2678
2678
  }
2679
- function generateTargetsFromCalculations(shopId, calculations) {
2679
+ function generateTargetsFromCalculations(shopId, calculations, existingTargets) {
2680
2680
  const startDate = getCurrentYearStart();
2681
2681
  const endDate = getCurrentYearEnd();
2682
- return calculations.map((calc) => ({
2683
- shopId,
2684
- metric: calc.metric,
2685
- amount: calc.targetValue,
2686
- startDate,
2687
- endDate
2688
- }));
2682
+ return calculations.map((calc) => {
2683
+ const existingTarget = existingTargets?.find(t => t.metric === calc.metric);
2684
+ return {
2685
+ ...(existingTarget?.id !== undefined && { id: existingTarget.id }),
2686
+ shopId,
2687
+ metric: calc.metric,
2688
+ amount: calc.targetValue,
2689
+ startDate,
2690
+ endDate
2691
+ };
2692
+ });
2689
2693
  }
2690
2694
  function groupMetricsByFunnelStage(calculations) {
2691
2695
  const grouped = new Map();
@@ -61682,7 +61686,8 @@ class InitialTargetSettingComponent {
61682
61686
  const pendingChanges = this.pendingTargetChanges();
61683
61687
  if (pendingChanges.size > 0) {
61684
61688
  const calculations = this.displayedMetricCalculations();
61685
- const updatedTargets = generateTargetsFromCalculations(this.shopId(), calculations);
61689
+ const existingTargets = this.targets();
61690
+ const updatedTargets = generateTargetsFromCalculations(this.shopId(), calculations, existingTargets);
61686
61691
  this.targetsUpdated.emit(updatedTargets);
61687
61692
  this.pendingTargetChanges.set(new Map());
61688
61693
  }
@@ -61690,6 +61695,7 @@ class InitialTargetSettingComponent {
61690
61695
  }
61691
61696
  onDiscardChanges() {
61692
61697
  this.pendingTargetChanges.set(new Map());
61698
+ this.storedCalculateResponse.set(null);
61693
61699
  this.discardChangesClick.emit();
61694
61700
  }
61695
61701
  saveFooterClasses() {