@treely/strapi-slices 5.11.2 → 5.11.3
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/strapi-slices.cjs.development.js +10 -8
- package/dist/strapi-slices.cjs.development.js.map +1 -1
- package/dist/strapi-slices.cjs.production.min.js +1 -1
- package/dist/strapi-slices.cjs.production.min.js.map +1 -1
- package/dist/strapi-slices.esm.js +10 -8
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/portfolio/SmallCheckout/SmallCheckout.tsx +33 -24
|
@@ -4358,6 +4358,11 @@ var BlogCards = function BlogCards(_ref) {
|
|
|
4358
4358
|
}))))));
|
|
4359
4359
|
};
|
|
4360
4360
|
|
|
4361
|
+
var calculateTaxIncludedValue = function calculateTaxIncludedValue(values, taxInPercent) {
|
|
4362
|
+
var value = parseInt(values.contributionValueCurrency);
|
|
4363
|
+
if (isNaN(value)) return 0;
|
|
4364
|
+
return value + value * (taxInPercent / 100);
|
|
4365
|
+
};
|
|
4361
4366
|
var SmallCheckout = function SmallCheckout(_ref) {
|
|
4362
4367
|
var pricePerKg = _ref.pricePerKg,
|
|
4363
4368
|
currency = _ref.currency,
|
|
@@ -4374,9 +4379,6 @@ var SmallCheckout = function SmallCheckout(_ref) {
|
|
|
4374
4379
|
locale = _useContext.locale;
|
|
4375
4380
|
var _useRouter = router.useRouter(),
|
|
4376
4381
|
push = _useRouter.push;
|
|
4377
|
-
var _useState = React.useState(initialContributionValue),
|
|
4378
|
-
contributionValue = _useState[0],
|
|
4379
|
-
setContributionValue = _useState[1];
|
|
4380
4382
|
var validateForm = React.useCallback(function (values) {
|
|
4381
4383
|
var errors = {};
|
|
4382
4384
|
var value = parseInt(values.contributionValueCurrency);
|
|
@@ -4394,7 +4396,7 @@ var SmallCheckout = function SmallCheckout(_ref) {
|
|
|
4394
4396
|
});
|
|
4395
4397
|
}
|
|
4396
4398
|
return errors;
|
|
4397
|
-
}, [locale]);
|
|
4399
|
+
}, [currency, locale]);
|
|
4398
4400
|
var onSubmit = /*#__PURE__*/function () {
|
|
4399
4401
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
4400
4402
|
var contributionValueCurrency, checkoutURL, currentURL;
|
|
@@ -4459,7 +4461,8 @@ var SmallCheckout = function SmallCheckout(_ref) {
|
|
|
4459
4461
|
var errors = _ref4.errors,
|
|
4460
4462
|
touched = _ref4.touched,
|
|
4461
4463
|
handleSubmit = _ref4.handleSubmit,
|
|
4462
|
-
setValues = _ref4.setValues
|
|
4464
|
+
setValues = _ref4.setValues,
|
|
4465
|
+
values = _ref4.values;
|
|
4463
4466
|
return React__default.default.createElement(formik.Form, {
|
|
4464
4467
|
onSubmit: handleSubmit
|
|
4465
4468
|
}, React__default.default.createElement(boemly.Flex, {
|
|
@@ -4478,7 +4481,6 @@ var SmallCheckout = function SmallCheckout(_ref) {
|
|
|
4478
4481
|
value: field.value || '',
|
|
4479
4482
|
onChange: function onChange(e) {
|
|
4480
4483
|
var value = e.target.valueAsNumber;
|
|
4481
|
-
setContributionValue(value);
|
|
4482
4484
|
setValues({
|
|
4483
4485
|
contributionValueCurrency: value.toString(),
|
|
4484
4486
|
contributionValueKgs: (value / pricePerKg / 1000).toString()
|
|
@@ -4525,13 +4527,13 @@ var SmallCheckout = function SmallCheckout(_ref) {
|
|
|
4525
4527
|
isInvalid: !!errors.contributionValueKgs && touched.contributionValueKgs,
|
|
4526
4528
|
errorMessage: errors.contributionValueKgs
|
|
4527
4529
|
});
|
|
4528
|
-
}))),
|
|
4530
|
+
}))), values.contributionValueCurrency && taxInPercent && taxInPercent > 0 && React__default.default.createElement(boemly.Text, {
|
|
4529
4531
|
size: "smLowNormal",
|
|
4530
4532
|
mt: "2"
|
|
4531
4533
|
}, formatMessage({
|
|
4532
4534
|
id: 'portfolio.smallCheckout.price.taxIncluded'
|
|
4533
4535
|
}, {
|
|
4534
|
-
number: formatNumber(
|
|
4536
|
+
number: formatNumber(calculateTaxIncludedValue(values, taxInPercent), {
|
|
4535
4537
|
style: 'currency',
|
|
4536
4538
|
currency: currency,
|
|
4537
4539
|
maximumFractionDigits: 2
|