aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/paths/instance/orders
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-03-13 11:12:46 -0300
committerSebastian <sebasjm@gmail.com>2023-03-13 11:27:52 -0300
commit96d110379e9bfbffedfeebf44c1c972b12fffff4 (patch)
treee7065608cd1561d000f9d2eef79a4ff3e4611e16 /packages/merchant-backoffice-ui/src/paths/instance/orders
parent5f681813cf1bb7bb5c0baa41f29011d0029d003d (diff)
downloadwallet-core-96d110379e9bfbffedfeebf44c1c972b12fffff4.tar.xz
some fixes and validations
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/orders')
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx12
1 files changed, 9 insertions, 3 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx
index f4a82f377..d5c888f1c 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx
@@ -144,12 +144,18 @@ export function CreatePage({
const { i18n } = useTranslationContext();
+ const parsedPrice = !value.pricing?.order_price
+ ? undefined
+ : Amounts.parse(value.pricing.order_price);
+
const errors: FormErrors<Entity> = {
pricing: undefinedIfEmpty({
summary: !value.pricing?.summary ? i18n.str`required` : undefined,
order_price: !value.pricing?.order_price
? i18n.str`required`
- : Amounts.isZero(value.pricing.order_price)
+ : !parsedPrice
+ ? i18n.str`not valid`
+ : Amounts.isZero(parsedPrice)
? i18n.str`must be greater than 0`
: undefined,
}),
@@ -333,8 +339,8 @@ export function CreatePage({
}, [hasProducts, totalAsString]);
const discountOrRise = rate(
- value.pricing?.order_price || `${config.currency}:0`,
- totalAsString,
+ parsedPrice ?? Amounts.zeroOfCurrency(config.currency),
+ totalPrice.amount,
);
const minAgeByProducts = allProducts.reduce(