Skip to content

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

Update create page

Krzysztof Bialoglowicz4118d22f150c
diff --git a/saleor/static/dashboard-next/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx b/saleor/static/dashboard-next/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx
index b2be131489..166520caeb 100644
--- a/saleor/static/dashboard-next/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx
+++ b/saleor/static/dashboard-next/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx
@@ -11,8 +11,8 @@ import SaveButtonBar from "@saleor/components/SaveButtonBar";
import i18n from "../../../i18n";
import { UserError } from "../../../types";
import {
- VoucherDiscountValueType,
- VoucherType
+ DiscountValueTypeEnum,
+ VoucherTypeEnum
} from "../../../types/globalTypes";
import VoucherDates from "../VoucherDates";
import VoucherInfo from "../VoucherInfo";
@@ -20,16 +20,19 @@ import VoucherLimits from "../VoucherLimits";
import VoucherRequirements from "../VoucherRequirements";
import VoucherTypes from "../VoucherTypes";
+import VoucherValue from "../VoucherValue";
export interface FormData {
applyOncePerOrder: boolean;
code: string;
- discountType: VoucherDiscountValueType;
+ discountType: DiscountValueTypeEnum;
endDate: string;
endTime: string;
+ hasEndDate: boolean;
+ hasUsageLimit: boolean;
minAmountSpent: number;
startDate: string;
startTime: string;
- type: VoucherType;
+ type: VoucherTypeEnum;
usageLimit: number;
value: number;
}
@@ -54,13 +57,15 @@ const VoucherCreatePage: React.StatelessComponent<VoucherCreatePageProps> = ({
const initialForm: FormData = {
applyOncePerOrder: false,
code: "",
- discountType: VoucherDiscountValueType.FIXED,
+ discountType: DiscountValueTypeEnum.FIXED,
endDate: "",
endTime: "",
+ hasEndDate: false,
+ hasUsageLimit: false,
minAmountSpent: 0,
startDate: "",
startTime: "",
- type: VoucherType.ENTIRE_ORDER,
+ type: VoucherTypeEnum.ENTIRE_ORDER,
usageLimit: 0,
value: 0
};
@@ -78,6 +83,7 @@ const VoucherCreatePage: React.StatelessComponent<VoucherCreatePageProps> = ({
errors={formErrors}
disabled={disabled}
onChange={change}
+ variant="create"
/>
<CardSpacer />
<VoucherTypes
@@ -86,6 +92,16 @@ const VoucherCreatePage: React.StatelessComponent<VoucherCreatePageProps> = ({
errors={formErrors}
onChange={change}
/>
+ {data.discountType.toString() !== "SHIPPING" ? (
+ <VoucherValue
+ data={data}
+ disabled={disabled}
+ defaultCurrency={defaultCurrency}
+ errors={formErrors}
+ onChange={change}
+ variant="create"
+ />
+ ) : null}
<CardSpacer />
<VoucherRequirements
data={data}