2021-05-14 08:15:15 +00:00
|
|
|
import { Avatar, Button, CardContent, TextField } from "@material-ui/core";
|
2019-06-19 14:40:52 +00:00
|
|
|
import deepPurple from "@material-ui/core/colors/deepPurple";
|
|
|
|
import PersonIcon from "@material-ui/icons/Person";
|
2021-07-21 08:59:52 +00:00
|
|
|
import { makeStyles } from "@saleor/macaw-ui";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-26 21:54:03 +00:00
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const useStyles = makeStyles(
|
|
|
|
theme => ({
|
2019-06-19 14:40:52 +00:00
|
|
|
avatar: {
|
|
|
|
"& span": {
|
|
|
|
height: "100%",
|
|
|
|
width: "100%"
|
|
|
|
},
|
|
|
|
alignSelf: "flex-start",
|
2019-10-28 16:16:49 +00:00
|
|
|
marginRight: theme.spacing(3.5)
|
|
|
|
},
|
|
|
|
button: {
|
|
|
|
zIndex: 2
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
cardActionsExpanded: {
|
2019-10-28 16:16:49 +00:00
|
|
|
maxHeight: theme.spacing(6)
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
input: {
|
2019-09-04 12:38:58 +00:00
|
|
|
"& > div": {
|
|
|
|
padding: "0 14px"
|
|
|
|
},
|
|
|
|
"& textarea": {
|
|
|
|
"&::placeholder": {
|
|
|
|
opacity: [[1], "!important"] as any
|
2019-10-28 16:16:49 +00:00
|
|
|
},
|
|
|
|
zIndex: 2
|
2019-09-04 12:38:58 +00:00
|
|
|
},
|
2019-09-10 15:17:58 +00:00
|
|
|
background: theme.palette.background.paper
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
noteRoot: {
|
2021-07-21 08:59:52 +00:00
|
|
|
left: theme.spacing(-8.5),
|
2019-10-28 16:16:49 +00:00
|
|
|
marginBottom: theme.spacing(3),
|
2019-06-19 14:40:52 +00:00
|
|
|
position: "relative",
|
2021-07-21 08:59:52 +00:00
|
|
|
width: `calc(100% + ${theme.spacing(8.5)})`
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
noteTitle: {
|
|
|
|
"&:last-child": {
|
2019-09-04 12:38:58 +00:00
|
|
|
paddingBottom: 0,
|
|
|
|
paddingRight: 0
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
alignItems: "center",
|
|
|
|
background: theme.palette.background.default,
|
2019-09-02 08:44:26 +00:00
|
|
|
display: "flex",
|
2019-10-28 16:16:49 +00:00
|
|
|
paddingLeft: theme.spacing(3)
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
root: {
|
2019-10-30 14:34:24 +00:00
|
|
|
borderColor: theme.palette.divider,
|
2019-06-19 14:40:52 +00:00
|
|
|
borderStyle: "solid",
|
|
|
|
borderWidth: "0 0 0 2px",
|
|
|
|
marginLeft: 20,
|
2019-10-28 16:16:49 +00:00
|
|
|
paddingLeft: theme.spacing(3)
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
2019-10-30 14:34:24 +00:00
|
|
|
}),
|
|
|
|
{ name: "Timeline" }
|
|
|
|
);
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
interface TimelineProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
children?: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
interface TimelineAddNoteProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
message: string;
|
2019-10-22 12:28:39 +00:00
|
|
|
reset: () => void;
|
2019-06-19 14:40:52 +00:00
|
|
|
onChange(event: React.ChangeEvent<any>);
|
|
|
|
onSubmit(event: React.FormEvent<any>);
|
|
|
|
}
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
export const Timeline: React.FC<TimelineProps> = props => {
|
|
|
|
const { children } = props;
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const classes = useStyles(props);
|
2019-08-26 21:54:03 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
return <div className={classes.root}>{children}</div>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const TimelineAddNote: React.FC<TimelineAddNoteProps> = props => {
|
|
|
|
const { message, onChange, onSubmit, reset } = props;
|
|
|
|
const classes = useStyles(props);
|
|
|
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
const submit = e => {
|
|
|
|
reset();
|
|
|
|
onSubmit(e);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classes.noteRoot}>
|
|
|
|
<CardContent className={classes.noteTitle}>
|
|
|
|
<Avatar
|
|
|
|
style={{ background: deepPurple[500] }}
|
|
|
|
className={classes.avatar}
|
|
|
|
>
|
|
|
|
<PersonIcon />
|
|
|
|
</Avatar>
|
|
|
|
<TextField
|
|
|
|
className={classes.input}
|
|
|
|
placeholder={intl.formatMessage({
|
|
|
|
defaultMessage: "Leave your note here..."
|
|
|
|
})}
|
|
|
|
onChange={onChange}
|
|
|
|
value={message}
|
|
|
|
name="message"
|
|
|
|
fullWidth
|
|
|
|
multiline
|
|
|
|
InputProps={{
|
|
|
|
endAdornment: (
|
|
|
|
<Button
|
|
|
|
className={classes.button}
|
|
|
|
color="primary"
|
|
|
|
onClick={e => submit(e)}
|
|
|
|
>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Send"
|
|
|
|
description="add order note, button"
|
|
|
|
/>
|
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
variant="outlined"
|
|
|
|
/>
|
|
|
|
</CardContent>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2019-10-22 12:28:39 +00:00
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
Timeline.displayName = "Timeline";
|
|
|
|
export default Timeline;
|