Skip to content

Commit 568d655

Browse files
author
mcmcphillips
committedOct 11, 2023
update dateTimeField component to use utc adapter.
1 parent 1e0d307 commit 568d655

File tree

1 file changed

+66
-57
lines changed

1 file changed

+66
-57
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,85 @@
11
import React from "react";
22
import PropTypes from "prop-types";
3-
import InputLabel from "../InputLabel";
3+
import { InputLabel } from "@madie/madie-design-system/dist/react";
44
import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
55
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
66
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
7+
import dayjs from "dayjs";
8+
import utc from "dayjs/plugin/utc";
9+
710
import { FormControl } from "@mui/material";
811
import { kebabCase } from "lodash";
912

13+
dayjs.extend(utc);
1014
export const dateTimeTextFieldStyle = {
11-
width: "240px",
15+
width: "240px",
16+
borderRadius: "3px",
17+
height: 40,
18+
border: "1px solid #B0B0B0",
19+
marginTop: "8px",
20+
"& .MuiOutlinedInput-notchedOutline": {
1221
borderRadius: "3px",
13-
height: 40,
14-
border: "1px solid #B0B0B0",
15-
marginTop: "8px",
16-
"& .MuiOutlinedInput-notchedOutline": {
17-
borderRadius: "3px",
18-
"& legend": {
19-
width: 0,
20-
},
22+
"& legend": {
23+
width: 0,
2124
},
22-
"& .MuiOutlinedInput-root": {
23-
"&&": {
24-
borderRadius: "3px",
25-
},
25+
},
26+
"& .MuiOutlinedInput-root": {
27+
"&&": {
28+
borderRadius: "3px",
2629
},
27-
"& .MuiInputBase-input": {
28-
color: "#333333",
29-
fontFamily: "Rubik",
30-
fontSize: 14,
31-
borderRadius: "3px",
32-
padding: "9px",
33-
Width: "240px",
34-
"&::placeholder": {
35-
opacity: 1,
36-
color: "#717171",
37-
fontFamily: "Rubik",
38-
fontSize: 14,
39-
},
30+
},
31+
"& .MuiInputBase-input": {
32+
color: "#333333",
33+
fontFamily: "Rubik",
34+
fontSize: 14,
35+
borderRadius: "3px",
36+
padding: "9px",
37+
Width: "240px",
38+
"&::placeholder": {
39+
opacity: 1,
40+
color: "#717171",
41+
fontFamily: "Rubik",
42+
fontSize: 14,
4043
},
44+
},
4145
};
4246

43-
const DateTimeField = ({ label, dateTimeValue, handleDateTimeChange,disabled }) => {
44-
return (
45-
<FormControl>
46-
<LocalizationProvider dateAdapter={AdapterDayjs}>
47-
<InputLabel
48-
style={{ marginBottom: 0, height: 16 }}
49-
data-testId={`${kebabCase(label)}`}
50-
>
51-
{`${label}`}
52-
</InputLabel>
53-
<DateTimePicker
54-
value={dateTimeValue ? dateTimeValue : null}
55-
onChange={handleDateTimeChange}
56-
views={["year", "day", "hours", "minutes"]}
57-
disabled={disabled}
58-
slotProps={{
59-
textField: {
60-
id: "dateTime",
61-
sx: dateTimeTextFieldStyle,
62-
},
63-
}}
64-
/>
65-
</LocalizationProvider>
66-
</FormControl>
67-
);
47+
const DateTimeField = ({
48+
label,
49+
dateTimeValue,
50+
handleDateTimeChange,
51+
disabled,
52+
}) => {
53+
return (
54+
<FormControl>
55+
<LocalizationProvider dateAdapter={AdapterDayjs}>
56+
<InputLabel
57+
style={{ marginBottom: 0, height: 16 }}
58+
data-testId={`${kebabCase(label)}`}
59+
>
60+
{`${label}`}
61+
</InputLabel>
62+
<DateTimePicker
63+
value={dateTimeValue ? dateTimeValue : null}
64+
onChange={handleDateTimeChange}
65+
views={["year", "day", "hours", "minutes"]}
66+
disabled={disabled}
67+
slotProps={{
68+
textField: {
69+
id: "dateTime",
70+
sx: dateTimeTextFieldStyle,
71+
},
72+
}}
73+
/>
74+
</LocalizationProvider>
75+
</FormControl>
76+
);
6877
};
6978
DateTimeField.propTypes = {
70-
dateTimeValue: PropTypes.object,
71-
handleDateTimeChange: PropTypes.func.isRequired,
72-
label: PropTypes.string.isRequired,
73-
disabled:PropTypes.bool
79+
dateTimeValue: PropTypes.object,
80+
handleDateTimeChange: PropTypes.func.isRequired,
81+
label: PropTypes.string.isRequired,
82+
disabled: PropTypes.bool,
7483
};
7584

76-
export default DateTimeField;
85+
export default DateTimeField;

0 commit comments

Comments
 (0)
Please sign in to comment.