@crystaldesign/diva-seller 24.15.0-beta.40 → 24.15.0-beta.41

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.
@@ -7931,10 +7931,16 @@ function Priceedit (_ref) {
7931
7931
  discount.percentageDiscount = isPercentage ? value : undefined;
7932
7932
  var price = (_productData$addedPri = productData.addedPrice) !== null && _productData$addedPri !== void 0 ? _productData$addedPri : 0;
7933
7933
  if (isPercentage) {
7934
- var discountPrice = (discount.percentageDiscount || 0) / 100 * price;
7935
- discount = _objectSpread$i(_objectSpread$i({}, discount), {}, {
7936
- calcDiscountPrice: formatTwoDecimals(price - discountPrice)
7937
- });
7934
+ if (discount.percentageDiscount == 0 || discount.percentageDiscount == undefined) {
7935
+ discount = _objectSpread$i(_objectSpread$i({}, discount), {}, {
7936
+ calcDiscountPrice: ''
7937
+ });
7938
+ } else {
7939
+ var discountPrice = (discount.percentageDiscount || 0) / 100 * price;
7940
+ discount = _objectSpread$i(_objectSpread$i({}, discount), {}, {
7941
+ calcDiscountPrice: formatTwoDecimals(price - discountPrice)
7942
+ });
7943
+ }
7938
7944
  } else {
7939
7945
  discount = _objectSpread$i(_objectSpread$i({}, discount), {}, {
7940
7946
  percentageDiscount: formatOneDecimals((price - value || 0) / price * 100)
@@ -7942,8 +7948,8 @@ function Priceedit (_ref) {
7942
7948
  }
7943
7949
  setDiscount(discount);
7944
7950
  update(_objectSpread$i(_objectSpread$i({}, productData), {}, {
7945
- discountedPrice: isPercentage ? formatTwoDecimals(discount.calcDiscountPrice) : value,
7946
- percentageDiscount: discount.percentageDiscount
7951
+ discountedPrice: isPercentage ? discount.calcDiscountPrice ? formatTwoDecimals(discount.calcDiscountPrice) : undefined : value,
7952
+ percentageDiscount: discount.percentageDiscount > 0 ? discount.percentageDiscount : undefined
7947
7953
  }));
7948
7954
  }, [productData, update]);
7949
7955
  function formatTwoDecimals(value) {
@@ -10156,8 +10162,14 @@ function _preUpdateData(field, value, row) {
10156
10162
  var calcedValue = (price - myValue || 0) / price * 100;
10157
10163
  if (fieldName === 'percentageDiscount') {
10158
10164
  calcedField = 'discountedPrice';
10159
- var discountedPrice = Math.round((myValue || 0) / 100 * price);
10160
- calcedValue = price - discountedPrice;
10165
+ myValue = isNaN(myValue) ? 0 : myValue;
10166
+ if (myValue > 0) {
10167
+ var discountedPrice = Math.round(myValue / 100 * price);
10168
+ calcedValue = price - discountedPrice;
10169
+ } else {
10170
+ myValue = 0;
10171
+ calcedValue = undefined;
10172
+ }
10161
10173
  }
10162
10174
  return _objectSpread$7(_objectSpread$7({}, row.original), {}, _defineProperty(_defineProperty({}, fieldName, myValue), calcedField, calcedValue));
10163
10175
  }
@@ -11600,6 +11612,12 @@ function updateVariants(prevState, currentState, configurationData, baseDataFiel
11600
11612
  if (field == 'shortDescription' || field == ' customData') {
11601
11613
  //updated shortDescription as last value
11602
11614
  continue;
11615
+ } else if (field == 'discountedPrice' && (newVariant === null || newVariant === void 0 ? void 0 : newVariant['percentageDiscount']) === 0 && (newVariant === null || newVariant === void 0 ? void 0 : newVariant[field]) === undefined) {
11616
+ finalVariant[field] = undefined;
11617
+ newModified[field] = variant[field] !== undefined;
11618
+ } else if (field == 'percentageDiscount' && (newVariant === null || newVariant === void 0 ? void 0 : newVariant[field]) === 0) {
11619
+ finalVariant[field] = 0;
11620
+ newModified[field] = variant[field] !== 0;
11603
11621
  } else if (field == 'addedPrice' || field == 'calculatedPrice') {
11604
11622
  var _currentState$modifie;
11605
11623
  var _ProductHandler$calcu = ProductHandler.calculateComputedValue(variant[field], newVariant === null || newVariant === void 0 ? void 0 : newVariant[field], currentState.baseData[field], (_currentState$modifie = currentState.modified.variantData[_i]) === null || _currentState$modifie === void 0 ? void 0 : _currentState$modifie[field]),
@@ -1 +1 @@
1
- {"version":3,"file":"Priceedit.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/ProductCreator/components/Priceedit.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,MAAM,CAAC,OAAO,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAA;CAAE,qBAmH/G"}
1
+ {"version":3,"file":"Priceedit.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/ProductCreator/components/Priceedit.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,MAAM,CAAC,OAAO,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;IAAE,WAAW,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAA;CAAE,qBAuH/G"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/diva-seller",
3
- "version": "24.15.0-beta.40",
3
+ "version": "24.15.0-beta.41",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -29,9 +29,9 @@
29
29
  "react-dom": "^18.3.1"
30
30
  },
31
31
  "dependencies": {
32
- "@crystaldesign/analytics": "24.15.0-beta.40",
33
- "@crystaldesign/products-component": "24.15.0-beta.40",
34
- "@crystaldesign/real-time-viewer": "24.15.0-beta.40",
32
+ "@crystaldesign/analytics": "24.15.0-beta.41",
33
+ "@crystaldesign/products-component": "24.15.0-beta.41",
34
+ "@crystaldesign/real-time-viewer": "24.15.0-beta.41",
35
35
  "@emotion/react": "^11.4.1",
36
36
  "@emotion/styled": "^11.3.0",
37
37
  "@mui/icons-material": "^6.1.5",
@@ -43,5 +43,5 @@
43
43
  },
44
44
  "types": "./build/types/seller/src/index.d.ts",
45
45
  "module": "build/esm/index.js",
46
- "gitHead": "ed900e671d4442ebd8a0dc07ebf3b1013fc20dce"
46
+ "gitHead": "2aeb96e27cc6aba71d7a6221333b800fe3068b88"
47
47
  }