feat(admin, js-sdk, types): update order forms (#10418)
* feat: edit shipping, billing and email forms * feat: timeline history, update change model, update tests * fix: address comments * fix: invalidation, translation schema, update label * fix: old/new
This commit is contained in:
@@ -51,6 +51,37 @@ export const useOrder = (
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useUpdateOrder = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminOrderResponse,
|
||||
FetchError,
|
||||
HttpTypes.AdminUpdateOrder
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: HttpTypes.AdminUpdateOrder) =>
|
||||
sdk.admin.order.update(id, payload),
|
||||
onSuccess: (data: any, variables: any, context: any) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.detail(id),
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.changes(id),
|
||||
})
|
||||
|
||||
// TODO: enable when needed
|
||||
// queryClient.invalidateQueries({
|
||||
// queryKey: ordersQueryKeys.lists(),
|
||||
// })
|
||||
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export const useOrderPreview = (
|
||||
id: string,
|
||||
query?: HttpTypes.AdminOrderFilters,
|
||||
|
||||
Reference in New Issue
Block a user