Update submit next action handling
This commit is contained in:
parent
6d39899db3
commit
73fe19011b
3 changed files with 11 additions and 21 deletions
|
@ -281,14 +281,10 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
|||
null
|
||||
);
|
||||
|
||||
const [submitNextAction, setSubmitNextAction] = React.useState<
|
||||
ProductUpdatePageSubmitNextAction
|
||||
>(null);
|
||||
const handleSubmitNextAction = (
|
||||
nextAction?: ProductUpdatePageSubmitNextAction
|
||||
) => {
|
||||
const action = nextAction || submitNextAction;
|
||||
if (action === "warehouse-configure") {
|
||||
if (nextAction === "warehouse-configure") {
|
||||
navigate(warehouseListPath);
|
||||
}
|
||||
};
|
||||
|
@ -322,8 +318,6 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
|||
const errors = await handleSubmit(data);
|
||||
if (errors?.length === 0) {
|
||||
handleSubmitNextAction(nextAction);
|
||||
} else {
|
||||
setSubmitNextAction(null);
|
||||
}
|
||||
}}
|
||||
onSubmitSkip={handleSubmitNextAction}
|
||||
|
|
|
@ -198,14 +198,10 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
|||
variables => updatePrivateMetadata({ variables })
|
||||
);
|
||||
|
||||
const [submitNextAction, setSubmitNextAction] = React.useState<
|
||||
ProductVariantPageSubmitNextAction
|
||||
>(null);
|
||||
const handleSubmitNextAction = (
|
||||
nextAction?: ProductVariantPageSubmitNextAction
|
||||
) => {
|
||||
const action = nextAction || submitNextAction;
|
||||
if (action === "warehouse-configure") {
|
||||
if (nextAction === "warehouse-configure") {
|
||||
navigate(warehouseListPath);
|
||||
}
|
||||
};
|
||||
|
@ -233,8 +229,6 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
|||
const errors = await handleSubmit(data);
|
||||
if (errors?.length === 0) {
|
||||
handleSubmitNextAction(nextAction);
|
||||
} else {
|
||||
setSubmitNextAction(null);
|
||||
}
|
||||
}}
|
||||
onSubmitSkip={handleSubmitNextAction}
|
||||
|
|
|
@ -52,17 +52,19 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
|
|||
|
||||
const [variantCreate, variantCreateResult] = useVariantCreateMutation({
|
||||
onCompleted: data => {
|
||||
if (data.productVariantCreate.errors.length === 0 && !submitNextAction) {
|
||||
if (data.productVariantCreate.errors.length === 0) {
|
||||
notify({
|
||||
status: "success",
|
||||
text: intl.formatMessage(commonMessages.savedChanges)
|
||||
});
|
||||
navigate(
|
||||
productVariantEditUrl(
|
||||
productId,
|
||||
data.productVariantCreate.productVariant.id
|
||||
)
|
||||
);
|
||||
if (!submitNextAction) {
|
||||
navigate(
|
||||
productVariantEditUrl(
|
||||
productId,
|
||||
data.productVariantCreate.productVariant.id
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue