1
1
import React from "react" ;
2
2
import PropTypes from "prop-types" ;
3
- import InputLabel from "../InputLabel " ;
3
+ import { InputLabel } from "@madie/madie-design-system/dist/react " ;
4
4
import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker" ;
5
5
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider" ;
6
6
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs" ;
7
+ import dayjs from "dayjs" ;
8
+ import utc from "dayjs/plugin/utc" ;
9
+
7
10
import { FormControl } from "@mui/material" ;
8
11
import { kebabCase } from "lodash" ;
9
12
13
+ dayjs . extend ( utc ) ;
10
14
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" : {
12
21
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 ,
21
24
} ,
22
- "& .MuiOutlinedInput-root" : {
23
- "&& " : {
24
- borderRadius : "3px" ,
25
- } ,
25
+ } ,
26
+ "& .MuiOutlinedInput-root " : {
27
+ "&&" : {
28
+ borderRadius : "3px" ,
26
29
} ,
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 ,
40
43
} ,
44
+ } ,
41
45
} ;
42
46
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
+ ) ;
68
77
} ;
69
78
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 ,
74
83
} ;
75
84
76
- export default DateTimeField ;
85
+ export default DateTimeField ;
0 commit comments