-
Notifications
You must be signed in to change notification settings - Fork 374
/
layout.jsx
74 lines (68 loc) · 2.02 KB
/
layout.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as React from 'react';
import { styled } from '@mui/material/styles';
import PropTypes from 'prop-types';
import DialogActions from '@mui/material/DialogActions';
import DialogTitle from '@mui/material/DialogTitle';
import { SMALL_LAYOUT_MEDIA_QUERY } from '../constants';
const PREFIX = 'Layout';
export const classes = {
title: `${PREFIX}-title`,
};
const StyledDialogTitle = styled(DialogTitle)(({ theme: { typography } }) => ({
[`&.${classes.title}`]: {
...typography.h6,
},
[`${SMALL_LAYOUT_MEDIA_QUERY}`]: {
[`&.${classes.title}`]: {
fontSize: '1.1rem',
},
},
}));
export const Layout = React.memo(({
buttonComponent: Button,
handleCancel,
handleConfirm,
getMessage,
isDeleting,
appointmentData,
...restProps
}) => (
<div
{...restProps}
>
<StyledDialogTitle className={classes.title}>
{getMessage(isDeleting ? 'confirmDeleteMessage' : 'confirmCancelMessage')}
</StyledDialogTitle>
<DialogActions>
<Button onClick={handleCancel} title={getMessage('cancelButton')} />
<Button
onClick={handleConfirm}
title={getMessage(isDeleting ? 'deleteButton' : 'discardButton')}
color="primary"
/>
</DialogActions>
</div>
));
Layout.propTypes = {
buttonComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
handleCancel: PropTypes.func,
handleConfirm: PropTypes.func,
getMessage: PropTypes.func,
isDeleting: PropTypes.bool,
appointmentData: PropTypes.shape({
title: PropTypes.string,
startDate: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
endDate: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
rRule: PropTypes.string,
notes: PropTypes.string,
additionalInformation: PropTypes.string,
allDay: PropTypes.bool,
}),
};
Layout.defaultProps = {
handleCancel: () => undefined,
handleConfirm: () => undefined,
getMessage: () => undefined,
isDeleting: false,
appointmentData: { startDate: new Date(), endDate: new Date() },
};