myio-js-library 0.1.201 → 0.1.203

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/dist/index.cjs CHANGED
@@ -42471,6 +42471,8 @@ var ContractDevicesModalView = class {
42471
42471
  border-radius: 6px;
42472
42472
  margin-bottom: 16px;
42473
42473
  font-size: 14px;
42474
+ white-space: pre-line;
42475
+ line-height: 1.6;
42474
42476
  }
42475
42477
 
42476
42478
  .myio-contract-devices-modal .customer-info {
@@ -42986,6 +42988,11 @@ var ContractDevicesController = class {
42986
42988
  }
42987
42989
  async handleSave(formData) {
42988
42990
  if (!this.view) return;
42991
+ const validationError = this.validateTotals(formData);
42992
+ if (validationError) {
42993
+ this.view.showError(validationError);
42994
+ return;
42995
+ }
42989
42996
  this.view.showLoadingState(true);
42990
42997
  this.view.hideError();
42991
42998
  try {
@@ -43031,6 +43038,32 @@ var ContractDevicesController = class {
43031
43038
  this.params.onClose();
43032
43039
  }
43033
43040
  }
43041
+ /**
43042
+ * Validate that totals match sum of components for each domain
43043
+ * Returns error message if validation fails, null if valid
43044
+ */
43045
+ validateTotals(formData) {
43046
+ const errors = [];
43047
+ if (formData.energy.total !== null) {
43048
+ const energySum = (formData.energy.entries || 0) + (formData.energy.commonArea || 0) + (formData.energy.stores || 0);
43049
+ if (formData.energy.total !== energySum) {
43050
+ errors.push(`Energia: Total (${formData.energy.total}) deve ser igual a Entradas + Area Comum + Lojas (${energySum})`);
43051
+ }
43052
+ }
43053
+ if (formData.water.total !== null) {
43054
+ const waterSum = (formData.water.entries || 0) + (formData.water.commonArea || 0) + (formData.water.stores || 0);
43055
+ if (formData.water.total !== waterSum) {
43056
+ errors.push(`Agua: Total (${formData.water.total}) deve ser igual a Entradas + Area Comum + Lojas (${waterSum})`);
43057
+ }
43058
+ }
43059
+ if (formData.temperature.total !== null) {
43060
+ const tempSum = (formData.temperature.internal || 0) + (formData.temperature.stores || 0);
43061
+ if (formData.temperature.total !== tempSum) {
43062
+ errors.push(`Temperatura: Total (${formData.temperature.total}) deve ser igual a Sensores Internos + Lojas (${tempSum})`);
43063
+ }
43064
+ }
43065
+ return errors.length > 0 ? errors.join("\n") : null;
43066
+ }
43034
43067
  mergeCounts(seed, fetched) {
43035
43068
  return {
43036
43069
  energy: {
package/dist/index.js CHANGED
@@ -42299,6 +42299,8 @@ var ContractDevicesModalView = class {
42299
42299
  border-radius: 6px;
42300
42300
  margin-bottom: 16px;
42301
42301
  font-size: 14px;
42302
+ white-space: pre-line;
42303
+ line-height: 1.6;
42302
42304
  }
42303
42305
 
42304
42306
  .myio-contract-devices-modal .customer-info {
@@ -42814,6 +42816,11 @@ var ContractDevicesController = class {
42814
42816
  }
42815
42817
  async handleSave(formData) {
42816
42818
  if (!this.view) return;
42819
+ const validationError = this.validateTotals(formData);
42820
+ if (validationError) {
42821
+ this.view.showError(validationError);
42822
+ return;
42823
+ }
42817
42824
  this.view.showLoadingState(true);
42818
42825
  this.view.hideError();
42819
42826
  try {
@@ -42859,6 +42866,32 @@ var ContractDevicesController = class {
42859
42866
  this.params.onClose();
42860
42867
  }
42861
42868
  }
42869
+ /**
42870
+ * Validate that totals match sum of components for each domain
42871
+ * Returns error message if validation fails, null if valid
42872
+ */
42873
+ validateTotals(formData) {
42874
+ const errors = [];
42875
+ if (formData.energy.total !== null) {
42876
+ const energySum = (formData.energy.entries || 0) + (formData.energy.commonArea || 0) + (formData.energy.stores || 0);
42877
+ if (formData.energy.total !== energySum) {
42878
+ errors.push(`Energia: Total (${formData.energy.total}) deve ser igual a Entradas + Area Comum + Lojas (${energySum})`);
42879
+ }
42880
+ }
42881
+ if (formData.water.total !== null) {
42882
+ const waterSum = (formData.water.entries || 0) + (formData.water.commonArea || 0) + (formData.water.stores || 0);
42883
+ if (formData.water.total !== waterSum) {
42884
+ errors.push(`Agua: Total (${formData.water.total}) deve ser igual a Entradas + Area Comum + Lojas (${waterSum})`);
42885
+ }
42886
+ }
42887
+ if (formData.temperature.total !== null) {
42888
+ const tempSum = (formData.temperature.internal || 0) + (formData.temperature.stores || 0);
42889
+ if (formData.temperature.total !== tempSum) {
42890
+ errors.push(`Temperatura: Total (${formData.temperature.total}) deve ser igual a Sensores Internos + Lojas (${tempSum})`);
42891
+ }
42892
+ }
42893
+ return errors.length > 0 ? errors.join("\n") : null;
42894
+ }
42862
42895
  mergeCounts(seed, fetched) {
42863
42896
  return {
42864
42897
  energy: {
@@ -42108,6 +42108,8 @@
42108
42108
  border-radius: 6px;
42109
42109
  margin-bottom: 16px;
42110
42110
  font-size: 14px;
42111
+ white-space: pre-line;
42112
+ line-height: 1.6;
42111
42113
  }
42112
42114
 
42113
42115
  .myio-contract-devices-modal .customer-info {
@@ -42623,6 +42625,11 @@
42623
42625
  }
42624
42626
  async handleSave(formData) {
42625
42627
  if (!this.view) return;
42628
+ const validationError = this.validateTotals(formData);
42629
+ if (validationError) {
42630
+ this.view.showError(validationError);
42631
+ return;
42632
+ }
42626
42633
  this.view.showLoadingState(true);
42627
42634
  this.view.hideError();
42628
42635
  try {
@@ -42668,6 +42675,32 @@
42668
42675
  this.params.onClose();
42669
42676
  }
42670
42677
  }
42678
+ /**
42679
+ * Validate that totals match sum of components for each domain
42680
+ * Returns error message if validation fails, null if valid
42681
+ */
42682
+ validateTotals(formData) {
42683
+ const errors = [];
42684
+ if (formData.energy.total !== null) {
42685
+ const energySum = (formData.energy.entries || 0) + (formData.energy.commonArea || 0) + (formData.energy.stores || 0);
42686
+ if (formData.energy.total !== energySum) {
42687
+ errors.push(`Energia: Total (${formData.energy.total}) deve ser igual a Entradas + Area Comum + Lojas (${energySum})`);
42688
+ }
42689
+ }
42690
+ if (formData.water.total !== null) {
42691
+ const waterSum = (formData.water.entries || 0) + (formData.water.commonArea || 0) + (formData.water.stores || 0);
42692
+ if (formData.water.total !== waterSum) {
42693
+ errors.push(`Agua: Total (${formData.water.total}) deve ser igual a Entradas + Area Comum + Lojas (${waterSum})`);
42694
+ }
42695
+ }
42696
+ if (formData.temperature.total !== null) {
42697
+ const tempSum = (formData.temperature.internal || 0) + (formData.temperature.stores || 0);
42698
+ if (formData.temperature.total !== tempSum) {
42699
+ errors.push(`Temperatura: Total (${formData.temperature.total}) deve ser igual a Sensores Internos + Lojas (${tempSum})`);
42700
+ }
42701
+ }
42702
+ return errors.length > 0 ? errors.join("\n") : null;
42703
+ }
42671
42704
  mergeCounts(seed, fetched) {
42672
42705
  return {
42673
42706
  energy: {