2019-06-19 14:40:52 +00:00
|
|
|
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 DialogTitle from "@material-ui/core/DialogTitle";
|
|
|
|
import {
|
|
|
|
createStyles,
|
|
|
|
Theme,
|
|
|
|
withStyles,
|
|
|
|
WithStyles
|
|
|
|
} from "@material-ui/core/styles";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-26 17:44:42 +00:00
|
|
|
import { FormattedMessage } from "react-intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
import ConfirmButton, {
|
|
|
|
ConfirmButtonTransitionState
|
|
|
|
} from "@saleor/components/ConfirmButton";
|
|
|
|
import { SingleAutocompleteSelectField } from "@saleor/components/SingleAutocompleteSelectField";
|
2019-08-26 17:44:42 +00:00
|
|
|
import { buttonMessages } from "@saleor/intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
const styles = (theme: Theme) =>
|
|
|
|
createStyles({
|
|
|
|
dialog: {
|
|
|
|
overflowY: "visible"
|
|
|
|
},
|
|
|
|
root: {
|
|
|
|
overflowY: "visible",
|
|
|
|
width: theme.breakpoints.values.sm
|
|
|
|
},
|
|
|
|
select: {
|
|
|
|
flex: 1,
|
|
|
|
marginRight: theme.spacing.unit * 2
|
|
|
|
},
|
|
|
|
textRight: {
|
|
|
|
textAlign: "right"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
interface OrderCustomerEditDialogProps extends WithStyles<typeof styles> {
|
|
|
|
confirmButtonState: ConfirmButtonTransitionState;
|
|
|
|
open: boolean;
|
2019-08-09 11:14:35 +00:00
|
|
|
user: string;
|
|
|
|
userDisplayValue: string;
|
2019-06-19 14:40:52 +00:00
|
|
|
users?: Array<{
|
|
|
|
id: string;
|
|
|
|
email: string;
|
|
|
|
}>;
|
|
|
|
loading?: boolean;
|
|
|
|
fetchUsers(value: string);
|
|
|
|
onChange(event: React.ChangeEvent<any>);
|
|
|
|
onClose?();
|
|
|
|
onConfirm?(event: React.FormEvent<any>);
|
|
|
|
}
|
|
|
|
|
|
|
|
const OrderCustomerEditDialog = withStyles(styles, {
|
|
|
|
name: "OrderCustomerEditDialog"
|
|
|
|
})(
|
|
|
|
({
|
|
|
|
classes,
|
|
|
|
confirmButtonState,
|
|
|
|
open,
|
|
|
|
loading,
|
|
|
|
user,
|
2019-08-09 11:14:35 +00:00
|
|
|
userDisplayValue,
|
2019-06-19 14:40:52 +00:00
|
|
|
users,
|
|
|
|
fetchUsers,
|
|
|
|
onChange,
|
|
|
|
onClose,
|
|
|
|
onConfirm
|
|
|
|
}: OrderCustomerEditDialogProps) => {
|
|
|
|
const choices =
|
|
|
|
!loading && users
|
|
|
|
? users.map(v => ({
|
|
|
|
label: v.email,
|
|
|
|
value: v.id
|
|
|
|
}))
|
|
|
|
: [];
|
|
|
|
return (
|
|
|
|
<Dialog onClose={onClose} open={open} classes={{ paper: classes.dialog }}>
|
2019-08-26 17:44:42 +00:00
|
|
|
<DialogTitle>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Edit customer details"
|
|
|
|
description="dialog header"
|
|
|
|
/>
|
|
|
|
</DialogTitle>
|
2019-06-19 14:40:52 +00:00
|
|
|
<DialogContent className={classes.root}>
|
|
|
|
<SingleAutocompleteSelectField
|
|
|
|
choices={choices}
|
2019-08-09 11:14:35 +00:00
|
|
|
allowCustomValues
|
2019-06-19 14:40:52 +00:00
|
|
|
loading={loading}
|
2019-08-09 11:14:35 +00:00
|
|
|
displayValue={userDisplayValue}
|
2019-06-19 14:40:52 +00:00
|
|
|
name="user"
|
|
|
|
value={user}
|
|
|
|
fetchChoices={fetchUsers}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
</DialogContent>
|
|
|
|
<DialogActions>
|
|
|
|
<Button onClick={onClose}>
|
2019-08-26 17:44:42 +00:00
|
|
|
<FormattedMessage {...buttonMessages.cancel} />
|
2019-06-19 14:40:52 +00:00
|
|
|
</Button>
|
|
|
|
<ConfirmButton
|
|
|
|
transitionState={confirmButtonState}
|
|
|
|
color="primary"
|
|
|
|
variant="contained"
|
|
|
|
onClick={onConfirm}
|
|
|
|
>
|
2019-08-26 17:44:42 +00:00
|
|
|
<FormattedMessage {...buttonMessages.confirm} />
|
2019-06-19 14:40:52 +00:00
|
|
|
</ConfirmButton>
|
|
|
|
</DialogActions>
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
OrderCustomerEditDialog.displayName = "OrderCustomerEditDialog";
|
|
|
|
export default OrderCustomerEditDialog;
|