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
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
const [submitNextAction, setSubmitNextAction] = React.useState<
|
|
||||||
ProductUpdatePageSubmitNextAction
|
|
||||||
>(null);
|
|
||||||
const handleSubmitNextAction = (
|
const handleSubmitNextAction = (
|
||||||
nextAction?: ProductUpdatePageSubmitNextAction
|
nextAction?: ProductUpdatePageSubmitNextAction
|
||||||
) => {
|
) => {
|
||||||
const action = nextAction || submitNextAction;
|
if (nextAction === "warehouse-configure") {
|
||||||
if (action === "warehouse-configure") {
|
|
||||||
navigate(warehouseListPath);
|
navigate(warehouseListPath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -322,8 +318,6 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
||||||
const errors = await handleSubmit(data);
|
const errors = await handleSubmit(data);
|
||||||
if (errors?.length === 0) {
|
if (errors?.length === 0) {
|
||||||
handleSubmitNextAction(nextAction);
|
handleSubmitNextAction(nextAction);
|
||||||
} else {
|
|
||||||
setSubmitNextAction(null);
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onSubmitSkip={handleSubmitNextAction}
|
onSubmitSkip={handleSubmitNextAction}
|
||||||
|
|
|
@ -198,14 +198,10 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
||||||
variables => updatePrivateMetadata({ variables })
|
variables => updatePrivateMetadata({ variables })
|
||||||
);
|
);
|
||||||
|
|
||||||
const [submitNextAction, setSubmitNextAction] = React.useState<
|
|
||||||
ProductVariantPageSubmitNextAction
|
|
||||||
>(null);
|
|
||||||
const handleSubmitNextAction = (
|
const handleSubmitNextAction = (
|
||||||
nextAction?: ProductVariantPageSubmitNextAction
|
nextAction?: ProductVariantPageSubmitNextAction
|
||||||
) => {
|
) => {
|
||||||
const action = nextAction || submitNextAction;
|
if (nextAction === "warehouse-configure") {
|
||||||
if (action === "warehouse-configure") {
|
|
||||||
navigate(warehouseListPath);
|
navigate(warehouseListPath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -233,8 +229,6 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
||||||
const errors = await handleSubmit(data);
|
const errors = await handleSubmit(data);
|
||||||
if (errors?.length === 0) {
|
if (errors?.length === 0) {
|
||||||
handleSubmitNextAction(nextAction);
|
handleSubmitNextAction(nextAction);
|
||||||
} else {
|
|
||||||
setSubmitNextAction(null);
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onSubmitSkip={handleSubmitNextAction}
|
onSubmitSkip={handleSubmitNextAction}
|
||||||
|
|
|
@ -52,17 +52,19 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
|
||||||
|
|
||||||
const [variantCreate, variantCreateResult] = useVariantCreateMutation({
|
const [variantCreate, variantCreateResult] = useVariantCreateMutation({
|
||||||
onCompleted: data => {
|
onCompleted: data => {
|
||||||
if (data.productVariantCreate.errors.length === 0 && !submitNextAction) {
|
if (data.productVariantCreate.errors.length === 0) {
|
||||||
notify({
|
notify({
|
||||||
status: "success",
|
status: "success",
|
||||||
text: intl.formatMessage(commonMessages.savedChanges)
|
text: intl.formatMessage(commonMessages.savedChanges)
|
||||||
});
|
});
|
||||||
navigate(
|
if (!submitNextAction) {
|
||||||
productVariantEditUrl(
|
navigate(
|
||||||
productId,
|
productVariantEditUrl(
|
||||||
data.productVariantCreate.productVariant.id
|
productId,
|
||||||
)
|
data.productVariantCreate.productVariant.id
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue