Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Handle case when user provided no range

dominik-zeglen9dffdfb6e61a
diff --git a/saleor/static/dashboard-next/components/MoneyRange/MoneyRange.tsx b/saleor/static/dashboard-next/components/MoneyRange/MoneyRange.tsx
index 787b14cac5..c2d1ac1038 100644
--- a/saleor/static/dashboard-next/components/MoneyRange/MoneyRange.tsx
+++ b/saleor/static/dashboard-next/components/MoneyRange/MoneyRange.tsx
@@ -32,10 +32,12 @@ export const MoneyRange: React.StatelessComponent<MoneyRangeProps> = ({
context: "money",
money: formatMoney(from, locale)
})
- : i18n.t("to {{ money }}", {
+ : !from && to
+ ? i18n.t("to {{ money }}", {
context: "money",
money: formatMoney(to, locale)
})
+ : "-"
}
</LocaleConsumer>
);
diff --git a/saleor/static/dashboard-next/components/WeightRange/WeightRange.tsx b/saleor/static/dashboard-next/components/WeightRange/WeightRange.tsx
index 71d41d4da8..2552fae688 100644
--- a/saleor/static/dashboard-next/components/WeightRange/WeightRange.tsx
+++ b/saleor/static/dashboard-next/components/WeightRange/WeightRange.tsx
@@ -25,9 +25,11 @@ const WeightRange: React.StatelessComponent<WeightRangeProps> = ({
context: "weight",
...from
})
- : i18n.t("to {{ value }} {{ unit }}", {
+ : !from && to
+ ? i18n.t("to {{ value }} {{ unit }}", {
context: "weight",
...to
- });
+ })
+ : "-";
WeightRange.displayName = "WeightRange";
export default WeightRange;