Skip to content

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

Fix VoucherTypes component

Krzysztof Bialoglowicz4607d2aef760
diff --git a/saleor/static/dashboard-next/discounts/components/VoucherTypes/VoucherTypes.tsx b/saleor/static/dashboard-next/discounts/components/VoucherTypes/VoucherTypes.tsx
index fee89a9368..047e896d17 100644
--- a/saleor/static/dashboard-next/discounts/components/VoucherTypes/VoucherTypes.tsx
+++ b/saleor/static/dashboard-next/discounts/components/VoucherTypes/VoucherTypes.tsx
@@ -12,8 +12,10 @@ import CardTitle from "@saleor/components/CardTitle";
import RadioGroupField from "@saleor/components/RadioGroupField";
import i18n from "../../../i18n";
import { FormErrors } from "../../../types";
-import { VoucherType } from "../../../types/globalTypes";
-import { translateVoucherTypes } from "../../translations";
+import {
+ DiscountValueTypeEnum,
+ VoucherDiscountValueType
+} from "../../../types/globalTypes";
import { FormData } from "../VoucherDetailsPage";
interface VoucherTypesProps {
@@ -42,11 +44,30 @@ const VoucherTypes = withStyles(styles, {
errors,
onChange
}: VoucherTypesProps & WithStyles<typeof styles>) => {
- const translatedVoucherTypes = translateVoucherTypes();
- const voucherTypeChoices = Object.values(VoucherType).map(type => ({
- label: translatedVoucherTypes[type],
- value: type
- }));
+ const voucherTypeChoices = Object.values(VoucherDiscountValueType).map(
+ type => {
+ switch (type.toString()) {
+ case DiscountValueTypeEnum.FIXED:
+ return {
+ hidden: false,
+ label: i18n.t("Fixed Amount"),
+ value: type
+ };
+ case DiscountValueTypeEnum.PERCENTAGE:
+ return {
+ hidden: false,
+ label: i18n.t("Percentage"),
+ value: type
+ };
+ case DiscountValueTypeEnum.SHIPPING:
+ return {
+ hidden: false,
+ label: i18n.t("Free Shipping"),
+ value: type
+ };
+ }
+ }
+ );
return (
<Card>
@@ -58,8 +79,8 @@ const VoucherTypes = withStyles(styles, {
disabled={disabled}
error={!!errors.type}
hint={errors.type}
- name={"type" as keyof FormData}
- value={data.type}
+ name={"discountType" as keyof FormData}
+ value={data.discountType}
onChange={onChange}
/>
</div>