Navigate to order draft list after canceling order draft (#2010)
This commit is contained in:
parent
ede1026a09
commit
8f25e1b9ed
1 changed files with 15 additions and 2 deletions
|
@ -2,6 +2,8 @@ import { WindowTitle } from "@saleor/components/WindowTitle";
|
||||||
import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
|
import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
|
||||||
import {
|
import {
|
||||||
OrderDetailsQuery,
|
OrderDetailsQuery,
|
||||||
|
OrderDraftCancelMutation,
|
||||||
|
OrderDraftCancelMutationVariables,
|
||||||
OrderDraftUpdateMutation,
|
OrderDraftUpdateMutation,
|
||||||
OrderDraftUpdateMutationVariables,
|
OrderDraftUpdateMutationVariables,
|
||||||
StockAvailability,
|
StockAvailability,
|
||||||
|
@ -56,7 +58,10 @@ interface OrderDraftDetailsProps {
|
||||||
OrderDraftUpdateMutation,
|
OrderDraftUpdateMutation,
|
||||||
OrderDraftUpdateMutationVariables
|
OrderDraftUpdateMutationVariables
|
||||||
>;
|
>;
|
||||||
orderDraftCancel: any;
|
orderDraftCancel: PartialMutationProviderOutput<
|
||||||
|
OrderDraftCancelMutation,
|
||||||
|
OrderDraftCancelMutationVariables
|
||||||
|
>;
|
||||||
orderDraftFinalize: any;
|
orderDraftFinalize: any;
|
||||||
openModal: (action: OrderUrlDialog, newParams?: OrderUrlQueryParams) => void;
|
openModal: (action: OrderUrlDialog, newParams?: OrderUrlQueryParams) => void;
|
||||||
closeModal: any;
|
closeModal: any;
|
||||||
|
@ -166,6 +171,14 @@ export const OrderDraftDetails: React.FC<OrderDraftDetailsProps> = ({
|
||||||
input: data
|
input: data
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleOrderDraftCancel = async () => {
|
||||||
|
const errors = await extractMutationErrors(orderDraftCancel.mutate({ id }));
|
||||||
|
if (!errors.length) {
|
||||||
|
navigate(orderDraftListUrl());
|
||||||
|
}
|
||||||
|
return errors;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WindowTitle
|
<WindowTitle
|
||||||
|
@ -225,7 +238,7 @@ export const OrderDraftDetails: React.FC<OrderDraftDetailsProps> = ({
|
||||||
confirmButtonState={orderDraftCancel.opts.status}
|
confirmButtonState={orderDraftCancel.opts.status}
|
||||||
errors={orderDraftCancel.opts.data?.draftOrderDelete.errors || []}
|
errors={orderDraftCancel.opts.data?.draftOrderDelete.errors || []}
|
||||||
onClose={closeModal}
|
onClose={closeModal}
|
||||||
onConfirm={() => orderDraftCancel.mutate({ id })}
|
onConfirm={handleOrderDraftCancel}
|
||||||
open={params.action === "cancel"}
|
open={params.action === "cancel"}
|
||||||
orderNumber={getStringOrPlaceholder(order?.number)}
|
orderNumber={getStringOrPlaceholder(order?.number)}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue