2019-06-19 14:40:52 +00:00
|
|
|
import DialogContentText from "@material-ui/core/DialogContentText";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-26 17:44:42 +00:00
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
const OrderBulkCancelDialog: React.StatelessComponent<
|
|
|
|
OrderBulkCancelDialogProps
|
|
|
|
> = ({ confirmButtonState, numberOfOrders, open, onClose, onConfirm }) => {
|
2019-08-26 17:44:42 +00:00
|
|
|
const intl = useIntl();
|
2019-06-19 14:40:52 +00:00
|
|
|
const [restock, setRestock] = React.useState(true);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ActionDialog
|
|
|
|
confirmButtonState={confirmButtonState}
|
|
|
|
open={open}
|
|
|
|
variant="delete"
|
2019-08-26 17:44:42 +00:00
|
|
|
title={intl.formatMessage({
|
|
|
|
defaultMessage: "Cancel Orders",
|
|
|
|
description: "dialog header"
|
|
|
|
})}
|
2019-06-19 14:40:52 +00:00
|
|
|
onClose={onClose}
|
|
|
|
onConfirm={() => onConfirm(restock)}
|
|
|
|
>
|
2019-08-26 17:44:42 +00:00
|
|
|
<DialogContentText>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Are you sure you want to cancel {counter, plural,
|
|
|
|
one {this order}
|
|
|
|
other {{displayQuantity} orders}
|
|
|
|
}?"
|
|
|
|
values={{
|
|
|
|
counter: numberOfOrders,
|
|
|
|
displayQuantity: <strong>{numberOfOrders}</strong>
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</DialogContentText>
|
2019-06-19 14:40:52 +00:00
|
|
|
<ControlledCheckbox
|
|
|
|
checked={restock}
|
2019-08-26 17:44:42 +00:00
|
|
|
label={intl.formatMessage({
|
|
|
|
defaultMessage: "Release all stock allocated to these orders",
|
|
|
|
description: "switch button"
|
|
|
|
})}
|
2019-06-19 14:40:52 +00:00
|
|
|
name="restock"
|
|
|
|
onChange={event => setRestock(event.target.value)}
|
|
|
|
/>
|
|
|
|
</ActionDialog>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
OrderBulkCancelDialog.displayName = "OrderBulkCancelDialog";
|
|
|
|
export default OrderBulkCancelDialog;
|