Minor tweaks

This commit is contained in:
dominik-zeglen 2020-04-28 03:09:31 +02:00
parent 037ace2a1b
commit 932349a27a
30 changed files with 296 additions and 32 deletions

View file

@ -121,6 +121,10 @@ export const buttonMessages = defineMessages({
defaultMessage: "Manage",
description: "button"
},
ok: {
defaultMessage: "OK",
description: "button"
},
remove: {
defaultMessage: "Remove",
description: "button"

View file

@ -4,14 +4,13 @@ import { FormattedMessage, useIntl } from "react-intl";
import ActionDialog from "@saleor/components/ActionDialog";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
export interface OrderBulkCancelDialogProps {
confirmButtonState: ConfirmButtonTransitionState;
numberOfOrders: string;
open: boolean;
onClose: () => void;
onConfirm: (restock: boolean) => void;
onConfirm: () => void;
}
const OrderBulkCancelDialog: React.FC<OrderBulkCancelDialogProps> = ({
@ -22,7 +21,6 @@ const OrderBulkCancelDialog: React.FC<OrderBulkCancelDialogProps> = ({
onConfirm
}) => {
const intl = useIntl();
const [restock, setRestock] = React.useState(true);
return (
<ActionDialog
@ -34,7 +32,7 @@ const OrderBulkCancelDialog: React.FC<OrderBulkCancelDialogProps> = ({
description: "dialog header"
})}
onClose={onClose}
onConfirm={() => onConfirm(restock)}
onConfirm={onConfirm}
>
<DialogContentText>
<FormattedMessage
@ -45,15 +43,6 @@ const OrderBulkCancelDialog: React.FC<OrderBulkCancelDialogProps> = ({
}}
/>
</DialogContentText>
<ControlledCheckbox
checked={restock}
label={intl.formatMessage({
defaultMessage: "Release all stock allocated to these orders",
description: "switch button"
})}
name="restock"
onChange={event => setRestock(event.target.value)}
/>
</ActionDialog>
);
};

View file

@ -21,8 +21,8 @@ export interface OrderCancelDialogProps {
errors: OrderErrorFragment[];
number: string;
open: boolean;
onClose?();
onSubmit();
onClose: () => void;
onSubmit: () => void;
}
const OrderCancelDialog: React.FC<OrderCancelDialogProps> = props => {
@ -50,8 +50,9 @@ const OrderCancelDialog: React.FC<OrderCancelDialogProps> = props => {
<DialogContent>
<DialogContentText>
<FormattedMessage
defaultMessage="Cancelling this order will release unfulfilled stocks, so they can be bought by other customers. Fulfilled items will be left untouched. Are you sure you want to cancel this order?"
defaultMessage="Cancelling this order will release unfulfilled stocks, so they can be bought by other customers. <b>Order will not be refunded when cancelling order - You need to do it manually.</b> Are you sure you want to cancel this order?"
values={{
b: (...chunks) => <b>{chunks}</b>,
orderNumber
}}
/>

View file

@ -0,0 +1,57 @@
import Button from "@material-ui/core/Button";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogContentText from "@material-ui/core/DialogContentText";
import DialogTitle from "@material-ui/core/DialogTitle";
import makeStyles from "@material-ui/core/styles/makeStyles";
import React from "react";
import { FormattedMessage } from "react-intl";
import { buttonMessages } from "@saleor/intl";
import { DialogProps } from "@saleor/types";
const useStyles = makeStyles(
theme => ({
button: {
backgroundColor: theme.palette.error.main
}
}),
{
name: "OrderCannotCancelOrderDialog"
}
);
const OrderCannotCancelOrderDialog: React.FC<DialogProps> = ({
open,
onClose
}) => {
const classes = useStyles({});
return (
<Dialog onClose={onClose} open={open} maxWidth="sm">
<DialogTitle>
<FormattedMessage
defaultMessage="Saleor couldnt cancel order"
description="dialog header"
/>
</DialogTitle>
<DialogContent>
<DialogContentText>
<FormattedMessage defaultMessage="There are still fulfillments created for this order. Cancel the fulfillments first before you cancel the order." />
</DialogContentText>
</DialogContent>
<DialogActions>
<Button
variant="contained"
className={classes.button}
onClick={onClose}
>
<FormattedMessage {...buttonMessages.ok} />
</Button>
</DialogActions>
</Dialog>
);
};
OrderCannotCancelOrderDialog.displayName = "OrderCannotCancelOrderDialog";
export default OrderCannotCancelOrderDialog;

View file

@ -0,0 +1,2 @@
export { default } from "./OrderCannotCancelOrderDialog";
export * from "./OrderCannotCancelOrderDialog";

View file

@ -3,11 +3,13 @@ import React from "react";
import Decorator from "@saleor/storybook/Decorator";
import { warehouseList } from "@saleor/warehouses/fixtures";
import { OrderErrorCode } from "@saleor/types/globalTypes";
import OrderFulfillPage, { OrderFulfillPageProps } from "./OrderFulfillPage";
import { orderToFulfill } from "./fixtures";
const props: OrderFulfillPageProps = {
disabled: false,
errors: [],
onBack: () => undefined,
onSubmit: () => undefined,
order: orderToFulfill,
@ -25,4 +27,18 @@ storiesOf("Views / Orders / Fulfill order", module)
order={undefined}
warehouses={undefined}
/>
))
.add("error", () => (
<OrderFulfillPage
{...props}
errors={[
{
__typename: "OrderError",
code: OrderErrorCode.INSUFFICIENT_STOCK,
field: null,
orderLine: orderToFulfill.lines[0].id,
warehouse: warehouseList[0].id
}
]}
/>
));

View file

@ -240,7 +240,7 @@ const OrderFulfillment: React.FC<OrderFulfillmentProps> = props => {
color="textPrimary"
variant="body2"
>
default
{fulfillment.warehouse.name}
</Typography>
)
}}

View file

@ -1,5 +1,6 @@
import { SearchCustomers_search_edges_node } from "@saleor/searches/types/SearchCustomers";
import { MessageDescriptor } from "react-intl";
import { warehouseList } from "@saleor/warehouses/fixtures";
import { transformOrderStatus, transformPaymentStatus } from "../misc";
import {
FulfillmentStatus,
@ -865,7 +866,8 @@ export const order = (placeholder: string): OrderDetails_order => ({
}
],
status: FulfillmentStatus.FULFILLED,
trackingNumber: ""
trackingNumber: "",
warehouse: warehouseList[1]
},
{
__typename: "Fulfillment",
@ -905,7 +907,8 @@ export const order = (placeholder: string): OrderDetails_order => ({
}
],
status: FulfillmentStatus.FULFILLED,
trackingNumber: "01nn12399su12nndfsy"
trackingNumber: "01nn12399su12nndfsy",
warehouse: warehouseList[0]
}
],
id: "T3JkZXI6OQ==",

View file

@ -71,8 +71,8 @@ export const orderErrorFragment = gql`
const orderCancelMutation = gql`
${fragmentOrderDetails}
${orderErrorFragment}
mutation OrderCancel($id: ID!, $restock: Boolean!) {
orderCancel(id: $id, restock: $restock) {
mutation OrderCancel($id: ID!) {
orderCancel(id: $id) {
errors: orderErrors {
...OrderErrorFragment
}
@ -89,8 +89,8 @@ export const TypedOrderCancelMutation = TypedMutation<
const orderBulkCancelMutation = gql`
${orderErrorFragment}
mutation OrderBulkCancel($ids: [ID]!, $restock: Boolean!) {
orderBulkCancel(ids: $ids, restock: $restock) {
mutation OrderBulkCancel($ids: [ID]!) {
orderBulkCancel(ids: $ids) {
errors: orderErrors {
...OrderErrorFragment
}

View file

@ -2,6 +2,7 @@ import gql from "graphql-tag";
import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch";
import makeQuery from "@saleor/hooks/makeQuery";
import { warehouseFragment } from "@saleor/warehouses/queries";
import { TypedQuery } from "../queries";
import { OrderDetails, OrderDetailsVariables } from "./types/OrderDetails";
import {
@ -79,6 +80,7 @@ export const fragmentOrderLine = gql`
`;
export const fulfillmentFragment = gql`
${fragmentOrderLine}
${warehouseFragment}
fragment FulfillmentFragment on Fulfillment {
id
lines {
@ -91,6 +93,9 @@ export const fulfillmentFragment = gql`
fulfillmentOrder
status
trackingNumber
warehouse {
...WarehouseFragment
}
}
`;

View file

@ -99,6 +99,12 @@ export interface FulfillOrder_orderFulfill_order_fulfillments_lines {
orderLine: FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine | null;
}
export interface FulfillOrder_orderFulfill_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface FulfillOrder_orderFulfill_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -106,6 +112,7 @@ export interface FulfillOrder_orderFulfill_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: FulfillOrder_orderFulfill_order_fulfillments_warehouse | null;
}
export interface FulfillOrder_orderFulfill_order_lines_unitPrice_gross {

View file

@ -0,0 +1,67 @@
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { FulfillmentStatus } from "./../../types/globalTypes";
// ====================================================
// GraphQL fragment: FulfillmentFragment
// ====================================================
export interface FulfillmentFragment_lines_orderLine_unitPrice_gross {
__typename: "Money";
amount: number;
currency: string;
}
export interface FulfillmentFragment_lines_orderLine_unitPrice_net {
__typename: "Money";
amount: number;
currency: string;
}
export interface FulfillmentFragment_lines_orderLine_unitPrice {
__typename: "TaxedMoney";
gross: FulfillmentFragment_lines_orderLine_unitPrice_gross;
net: FulfillmentFragment_lines_orderLine_unitPrice_net;
}
export interface FulfillmentFragment_lines_orderLine_thumbnail {
__typename: "Image";
url: string;
}
export interface FulfillmentFragment_lines_orderLine {
__typename: "OrderLine";
id: string;
isShippingRequired: boolean;
productName: string;
productSku: string;
quantity: number;
quantityFulfilled: number;
unitPrice: FulfillmentFragment_lines_orderLine_unitPrice | null;
thumbnail: FulfillmentFragment_lines_orderLine_thumbnail | null;
}
export interface FulfillmentFragment_lines {
__typename: "FulfillmentLine";
id: string;
quantity: number;
orderLine: FulfillmentFragment_lines_orderLine | null;
}
export interface FulfillmentFragment_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface FulfillmentFragment {
__typename: "Fulfillment";
id: string;
lines: (FulfillmentFragment_lines | null)[] | null;
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: FulfillmentFragment_warehouse | null;
}

View file

@ -25,5 +25,4 @@ export interface OrderBulkCancel {
export interface OrderBulkCancelVariables {
ids: (string | null)[];
restock: boolean;
}

View file

@ -97,6 +97,12 @@ export interface OrderCancel_orderCancel_order_fulfillments_lines {
orderLine: OrderCancel_orderCancel_order_fulfillments_lines_orderLine | null;
}
export interface OrderCancel_orderCancel_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderCancel_orderCancel_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderCancel_orderCancel_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderCancel_orderCancel_order_fulfillments_warehouse | null;
}
export interface OrderCancel_orderCancel_order_lines_unitPrice_gross {
@ -278,5 +285,4 @@ export interface OrderCancel {
export interface OrderCancelVariables {
id: string;
restock: boolean;
}

View file

@ -97,6 +97,12 @@ export interface OrderCapture_orderCapture_order_fulfillments_lines {
orderLine: OrderCapture_orderCapture_order_fulfillments_lines_orderLine | null;
}
export interface OrderCapture_orderCapture_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderCapture_orderCapture_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderCapture_orderCapture_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderCapture_orderCapture_order_fulfillments_warehouse | null;
}
export interface OrderCapture_orderCapture_order_lines_unitPrice_gross {

View file

@ -91,6 +91,12 @@ export interface OrderDetails_order_fulfillments_lines {
orderLine: OrderDetails_order_fulfillments_lines_orderLine | null;
}
export interface OrderDetails_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderDetails_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -98,6 +104,7 @@ export interface OrderDetails_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderDetails_order_fulfillments_warehouse | null;
}
export interface OrderDetails_order_lines_unitPrice_gross {

View file

@ -91,6 +91,12 @@ export interface OrderDetailsFragment_fulfillments_lines {
orderLine: OrderDetailsFragment_fulfillments_lines_orderLine | null;
}
export interface OrderDetailsFragment_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderDetailsFragment_fulfillments {
__typename: "Fulfillment";
id: string;
@ -98,6 +104,7 @@ export interface OrderDetailsFragment_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderDetailsFragment_fulfillments_warehouse | null;
}
export interface OrderDetailsFragment_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderDraftCancel_draftOrderDelete_order_fulfillments_lines {
orderLine: OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orderLine | null;
}
export interface OrderDraftCancel_draftOrderDelete_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderDraftCancel_draftOrderDelete_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderDraftCancel_draftOrderDelete_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderDraftCancel_draftOrderDelete_order_fulfillments_warehouse | null;
}
export interface OrderDraftCancel_draftOrderDelete_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines
orderLine: OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_orderLine | null;
}
export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderDraftFinalize_draftOrderComplete_order_fulfillments_warehouse | null;
}
export interface OrderDraftFinalize_draftOrderComplete_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines {
orderLine: OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orderLine | null;
}
export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderDraftUpdate_draftOrderUpdate_order_fulfillments_warehouse | null;
}
export interface OrderDraftUpdate_draftOrderUpdate_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillment
orderLine: OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_lines_orderLine | null;
}
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillment
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_warehouse | null;
}
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o
orderLine: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_lines_orderLine | null;
}
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_warehouse | null;
}
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderLineDelete_draftOrderLineDelete_order_fulfillments_lines {
orderLine: OrderLineDelete_draftOrderLineDelete_order_fulfillments_lines_orderLine | null;
}
export interface OrderLineDelete_draftOrderLineDelete_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderLineDelete_draftOrderLineDelete_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderLineDelete_draftOrderLineDelete_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderLineDelete_draftOrderLineDelete_order_fulfillments_warehouse | null;
}
export interface OrderLineDelete_draftOrderLineDelete_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderLineUpdate_draftOrderLineUpdate_order_fulfillments_lines {
orderLine: OrderLineUpdate_draftOrderLineUpdate_order_fulfillments_lines_orderLine | null;
}
export interface OrderLineUpdate_draftOrderLineUpdate_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderLineUpdate_draftOrderLineUpdate_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderLineUpdate_draftOrderLineUpdate_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderLineUpdate_draftOrderLineUpdate_order_fulfillments_warehouse | null;
}
export interface OrderLineUpdate_draftOrderLineUpdate_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderLinesAdd_draftOrderLinesCreate_order_fulfillments_lines {
orderLine: OrderLinesAdd_draftOrderLinesCreate_order_fulfillments_lines_orderLine | null;
}
export interface OrderLinesAdd_draftOrderLinesCreate_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderLinesAdd_draftOrderLinesCreate_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderLinesAdd_draftOrderLinesCreate_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderLinesAdd_draftOrderLinesCreate_order_fulfillments_warehouse | null;
}
export interface OrderLinesAdd_draftOrderLinesCreate_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines {
orderLine: OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderLine | null;
}
export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_warehouse | null;
}
export interface OrderMarkAsPaid_orderMarkAsPaid_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderRefund_orderRefund_order_fulfillments_lines {
orderLine: OrderRefund_orderRefund_order_fulfillments_lines_orderLine | null;
}
export interface OrderRefund_orderRefund_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderRefund_orderRefund_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderRefund_orderRefund_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderRefund_orderRefund_order_fulfillments_warehouse | null;
}
export interface OrderRefund_orderRefund_order_lines_unitPrice_gross {

View file

@ -97,6 +97,12 @@ export interface OrderVoid_orderVoid_order_fulfillments_lines {
orderLine: OrderVoid_orderVoid_order_fulfillments_lines_orderLine | null;
}
export interface OrderVoid_orderVoid_order_fulfillments_warehouse {
__typename: "Warehouse";
id: string;
name: string;
}
export interface OrderVoid_orderVoid_order_fulfillments {
__typename: "Fulfillment";
id: string;
@ -104,6 +110,7 @@ export interface OrderVoid_orderVoid_order_fulfillments {
fulfillmentOrder: number;
status: FulfillmentStatus;
trackingNumber: string;
warehouse: OrderVoid_orderVoid_order_fulfillments_warehouse | null;
}
export interface OrderVoid_orderVoid_order_lines_unitPrice_gross {

View file

@ -9,6 +9,7 @@ import useCustomerSearch from "@saleor/searches/useCustomerSearch";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
import NotFoundPage from "@saleor/components/NotFoundPage";
import { useWarehouseList } from "@saleor/warehouses/queries";
import OrderCannotCancelOrderDialog from "@saleor/orders/components/OrderCannotCancelOrderDialog";
import { customerUrl } from "../../../customers/urls";
import {
maybe,
@ -16,7 +17,7 @@ import {
getStringOrPlaceholder
} from "../../../misc";
import { productUrl } from "../../../products/urls";
import { OrderStatus } from "../../../types/globalTypes";
import { OrderStatus, FulfillmentStatus } from "../../../types/globalTypes";
import OrderAddressEditDialog from "../../components/OrderAddressEditDialog";
import OrderCancelDialog from "../../components/OrderCancelDialog";
import OrderDetailsPage from "../../components/OrderDetailsPage";
@ -229,6 +230,17 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
navigate(customerUrl(order.user.id))
}
/>
<OrderCannotCancelOrderDialog
onClose={closeModal}
open={
params.action === "cancel" &&
order?.fulfillments.some(
fulfillment =>
fulfillment.status ===
FulfillmentStatus.FULFILLED
)
}
/>
<OrderCancelDialog
confirmButtonState={orderCancel.opts.status}
errors={
@ -237,10 +249,9 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
number={order?.number}
open={params.action === "cancel"}
onClose={closeModal}
onSubmit={variables =>
onSubmit={() =>
orderCancel.mutate({
id,
...variables
id
})
}
/>

View file

@ -164,11 +164,10 @@ export const OrderList: React.FC<OrderListProps> = ({ params }) => {
return (
<TypedOrderBulkCancelMutation onCompleted={handleOrderBulkCancel}>
{(orderBulkCancel, orderBulkCancelOpts) => {
const onOrderBulkCancel = (restock: boolean) =>
const onOrderBulkCancel = () =>
orderBulkCancel({
variables: {
ids: params.ids,
restock
ids: params.ids
}
});