Skip to content

Commit

Permalink
Voucher create save button stay active (#5107)
Browse files Browse the repository at this point in the history
* Voucher create save button stay active

* Add changeset
  • Loading branch information
poulch committed Aug 12, 2024
1 parent edaf42b commit e730343
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-spies-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can click save button on voucher creation page to trigger validation
5 changes: 1 addition & 4 deletions src/products/components/ProductVariantCreatePage/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import { ProductStockFormsetData, ProductStockInput } from "../ProductStocks";
import {
concatChannelsBySelection,
createChannelsWithPreorderInfo,
validateChannels,
} from "../ProductVariantChannels/formOpretations";

export interface ProductVariantCreateFormData extends MetadataFormData {
Expand Down Expand Up @@ -281,11 +280,9 @@ function useProductVariantCreateForm(

useEffect(() => setExitDialogSubmitRef(submit), [submit]);

const invalidChannels = validateChannels(channels?.data);
const invalidPreorder =
data.isPreorder && data.hasPreorderEndDate && !!form.errors.preorderEndDateTime;
const formDisabled = invalidPreorder || invalidChannels;
const isSaveDisabled = disabled || formDisabled || !data.variantName || !onSubmit;
const isSaveDisabled = disabled || invalidPreorder || !onSubmit;

setIsSubmitDisabled(isSaveDisabled);

Expand Down

0 comments on commit e730343

Please sign in to comment.