Skip to content

Commit 6ef1681

Browse files
fix(deps): update dependency @mui/x-date-pickers to v7 (#450)
* fix(deps): update dependency @mui/x-date-pickers to v7 * Fixed and upgraded MUI date picker * Fixed BuildingDrawer date picker --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jessica Feng <54833118+JessicaF@users.noreply.github.com> Co-authored-by: Jessica <Jessica.Feng101@gmail.com>
1 parent 22d171a commit 6ef1681

File tree

4 files changed

+65
-139
lines changed

4 files changed

+65
-139
lines changed

frontend/components/BookingCalendar.tsx

+13-23
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Button from "@mui/material/Button";
88
import ButtonGroup from "@mui/material/ButtonGroup";
99
import Stack from "@mui/material/Stack";
1010
import { styled, useTheme } from "@mui/material/styles";
11-
import TextField, { TextFieldProps } from "@mui/material/TextField";
1211
import ToggleButton from "@mui/material/ToggleButton";
1312
import ToggleButtonGroup from "@mui/material/ToggleButtonGroup";
1413
import Typography from "@mui/material/Typography";
@@ -30,19 +29,6 @@ import {
3029
import { selectDatetime } from "../redux/datetimeSlice";
3130
import { useSelector } from "../redux/hooks";
3231

33-
const customDatePickerComponent = (params: TextFieldProps) => (
34-
<TextField
35-
{...params}
36-
size="small"
37-
sx={{
38-
svg: { color: "#000000" },
39-
input: { color: "#000000" },
40-
width: { xs: "100%", md: 200 },
41-
borderColor: "rgba(0, 0, 0, 0.12)",
42-
}}
43-
/>
44-
);
45-
4632
const ToolBarButton = styled(Button)(({ theme }) => ({
4733
borderColor: "rgba(0, 0, 0, 0.12)",
4834
color: "black",
@@ -232,13 +218,7 @@ const BookingCalendar: React.FC<{ events: Array<Booking> }> = ({ events }) => {
232218

233219
return (
234220
<>
235-
<Stack
236-
justifyContent="flex-start"
237-
height="100%"
238-
width="100%"
239-
// px={{ xs: 3, md: 15 }}
240-
pt={3}
241-
>
221+
<Stack justifyContent="flex-start" height="100%" width="100%" pt={3}>
242222
<Stack
243223
direction={{ xs: "column", md: "row" }}
244224
justifyContent="space-between"
@@ -251,12 +231,22 @@ const BookingCalendar: React.FC<{ events: Array<Booking> }> = ({ events }) => {
251231
</Typography>
252232
<LocalizationProvider dateAdapter={AdapterDateFns}>
253233
<DatePicker
254-
inputFormat="iii, d MMM yyyy"
234+
format="iii, d MMM yyyy"
255235
value={date}
256236
onChange={(newDate) => {
257237
handleDateChange(newDate);
258238
}}
259-
renderInput={customDatePickerComponent}
239+
slotProps={{
240+
textField: {
241+
size: "small",
242+
sx: {
243+
svg: { color: "#000000" },
244+
input: { color: "#000000" },
245+
width: { xs: "100%", md: 200 },
246+
borderColor: "rgba(0, 0, 0, 0.12)",
247+
},
248+
},
249+
}}
260250
/>
261251
</LocalizationProvider>
262252
</Stack>

frontend/package-lock.json

+33-111
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@mui/icons-material": "^5.10.14",
1919
"@mui/material": "^5.10.14",
2020
"@mui/system": "^5.10.14",
21-
"@mui/x-date-pickers": "^5.0.8",
21+
"@mui/x-date-pickers": "^7.0.0",
2222
"@reduxjs/toolkit": "^1.9.5",
2323
"axios": "^1.0.0",
2424
"date-fns": "^2.29.3",

frontend/views/BuildingDrawer.tsx

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import CloseIcon from "@mui/icons-material/Close";
2-
import { Typography, TypographyProps, useMediaQuery } from "@mui/material";
2+
import { Typography, useMediaQuery } from "@mui/material";
33
import Box, { BoxProps } from "@mui/material/Box";
44
import CircularProgress from "@mui/material/CircularProgress";
55
import Divider from "@mui/material/Divider";
@@ -154,20 +154,34 @@ const BuildingDrawer: React.FC<{ open: boolean }> = ({ open }) => {
154154
}}
155155
>
156156
<DesktopDatePicker
157-
inputFormat="dd/MM/yyyy"
157+
format="dd/MM/yyyy"
158158
value={datetime}
159159
onChange={(value) =>
160160
value && dispatch(setDatetime(toSydneyTime(value)))
161161
}
162-
renderInput={customTextField}
162+
slotProps={{
163+
textField: {
164+
sx: {
165+
svg: { color: "#000000" },
166+
input: { color: "#000000" },
167+
},
168+
},
169+
}}
163170
/>
164171
<div style={{ width: 10 }} />
165172
<TimePicker
166173
value={datetime}
167174
onChange={(value) =>
168175
value && dispatch(setDatetime(toSydneyTime(value)))
169176
}
170-
renderInput={customTextField}
177+
slotProps={{
178+
textField: {
179+
sx: {
180+
svg: { color: "#000000" },
181+
input: { color: "#000000" },
182+
},
183+
},
184+
}}
171185
/>
172186
</div>
173187
</LocalizationProvider>

0 commit comments

Comments
 (0)