Skip to content

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

Set zero value if usage limit unchecked

Krzysztof Bialoglowicz8b38dcffd196
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
index caa3d563fe..2bd42abf7c 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherCreate.tsx
@@ -72,7 +72,9 @@ export const VoucherDetails: React.StatelessComponent = () => {
formData.discountType.toString() === "SHIPPING"
? VoucherTypeEnum.ENTIRE_ORDER
: formData.type,
- usageLimit: formData.usageLimit
+ usageLimit: formData.hasUsageLimit
+ ? formData.usageLimit
+ : 0
}
}
})
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx b/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
index 680d0cc36c..18da70e5b8 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherDetails.tsx
@@ -310,7 +310,8 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({
activeTab={params.activeTab}
onBack={() => navigate(voucherListUrl())}
onTabClick={changeTab}
- onSubmit={formData =>
+ onSubmit={formData => {
+ console.log(formData);
voucherUpdate({
variables: {
id,
@@ -341,11 +342,13 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({
"SHIPPING"
? VoucherTypeEnum.SHIPPING
: formData.type,
- usageLimit: formData.usageLimit
+ usageLimit: formData.hasUsageLimit
+ ? formData.usageLimit
+ : 0
}
}
- })
- }
+ });
+ }}
onRemove={() => openModal("remove")}
saveButtonBarState={formTransitionState}
categoryListToolbar={