refactor: replace timezone Select with Autocomplete

- Replace timezone Select field with Autocomplete in EventModal and EventFormFields
- Add search functionality for timezones with text input
- Add timezone icon to match PeopleSearch component style
- Remove 'Mark as important' checkbox from EventModal (re showup when rebase)
- Remove gap space in description when desc field show up
This commit is contained in:
lenhanphung
2025-10-15 14:22:54 +07:00
committed by Benoit TELLIER
parent adbb77fe8a
commit 2ab7c448bf
2 changed files with 120 additions and 70 deletions
+60 -29
View File
@@ -14,6 +14,7 @@ import {
Typography,
ToggleButtonGroup,
ToggleButton,
Autocomplete,
} from "@mui/material";
import {
Description as DescriptionIcon,
@@ -22,6 +23,7 @@ import {
CameraAlt as VideocamIcon,
ContentCopy as CopyIcon,
Close as DeleteIcon,
PublicOutlined as TimezoneIcon,
} from "@mui/icons-material";
import AttendeeSelector from "../Attendees/AttendeeSearch";
import RepeatEvent from "./EventRepeat";
@@ -261,22 +263,23 @@ export default function EventFormFields({
/>
</FieldWithLabel>
<FieldWithLabel label=" " isExpanded={showMore}>
<Box display="flex" gap={1} mb={1}>
<Button
startIcon={<DescriptionIcon />}
onClick={() => setShowDescription(true)}
size="small"
sx={{
textTransform: "none",
color: "text.secondary",
display: showDescription ? "none" : "flex",
}}
>
Add description
</Button>
</Box>
</FieldWithLabel>
{!showDescription && (
<FieldWithLabel label=" " isExpanded={showMore}>
<Box display="flex" gap={1} mb={1}>
<Button
startIcon={<DescriptionIcon />}
onClick={() => setShowDescription(true)}
size="small"
sx={{
textTransform: "none",
color: "text.secondary",
}}
>
Add description
</Button>
</Box>
</FieldWithLabel>
)}
{showDescription && (
<FieldWithLabel label="Description" isExpanded={showMore}>
@@ -404,19 +407,47 @@ export default function EventFormFields({
}
label="Repeat"
/>
<FormControl size="small" sx={{ width: 160 }}>
<Select
value={timezone}
onChange={(e: SelectChangeEvent) => setTimezone(e.target.value)}
displayEmpty
>
{timezoneList.zones.map((tz) => (
<MenuItem key={tz} value={tz}>
({timezoneList.getTimezoneOffset(tz)}) {tz.replace(/_/g, " ")}
</MenuItem>
))}
</Select>
</FormControl>
<Autocomplete
value={timezone}
options={timezoneList.zones}
size="small"
sx={{ width: 240 }}
getOptionLabel={(option) =>
`(${timezoneList.getTimezoneOffset(option)}) ${option.replace(/_/g, " ")}`
}
onChange={(event, newValue) => {
if (newValue) {
setTimezone(newValue);
}
}}
renderInput={(params) => (
<TextField
{...params}
placeholder="Select timezone"
autoComplete="off"
slotProps={{
input: {
...params.InputProps,
startAdornment: (
<>
<TimezoneIcon
style={{
marginRight: 8,
color: "rgba(0, 0, 0, 0.54)",
}}
/>
{params.InputProps.startAdornment}
</>
),
},
}}
inputProps={{
...params.inputProps,
autoComplete: "new-password",
}}
/>
)}
/>
</Box>
</FieldWithLabel>
+60 -41
View File
@@ -12,6 +12,7 @@ import {
Typography,
ToggleButtonGroup,
ToggleButton,
Autocomplete,
} from "@mui/material";
import {
Description as DescriptionIcon,
@@ -20,6 +21,7 @@ import {
CameraAlt as VideocamIcon,
ContentCopy as CopyIcon,
Close as DeleteIcon,
PublicOutlined as TimezoneIcon,
} from "@mui/icons-material";
import { Box, Button } from "@mui/material";
import AddIcon from "@mui/icons-material/Add";
@@ -184,7 +186,6 @@ function EventPopover({
const [alarm, setAlarm] = useState(event?.alarm?.trigger ?? "");
const [eventClass, setEventClass] = useState(event?.class ?? "PUBLIC");
const [busy, setBusy] = useState(event?.transp ?? "OPAQUE");
const [important, setImportant] = useState(false);
const [timezone, setTimezone] = useState(
event?.timezone ? resolveTimezone(event.timezone) : calendarTimezone
);
@@ -220,7 +221,6 @@ function EventPopover({
setAlarm("");
setEventClass("PUBLIC");
setBusy("OPAQUE");
setImportant(false);
setTimezone(calendarTimezone);
setHasVideoConference(false);
setMeetingLink(null);
@@ -308,7 +308,6 @@ function EventPopover({
setAlarm("");
setEventClass("PUBLIC");
setBusy("OPAQUE");
setImportant(false);
setTimezone(timezoneList.browserTz);
setHasVideoConference(false);
setMeetingLink(null);
@@ -454,22 +453,23 @@ function EventPopover({
/>
</FieldWithLabel>
<FieldWithLabel label=" " isExpanded={showMore}>
<Box display="flex" gap={1} mb={1}>
<Button
startIcon={<DescriptionIcon />}
onClick={() => setShowDescription(true)}
size="small"
sx={{
textTransform: "none",
color: "text.secondary",
display: showDescription ? "none" : "flex",
}}
>
Add description
</Button>
</Box>
</FieldWithLabel>
{!showDescription && (
<FieldWithLabel label=" " isExpanded={showMore}>
<Box display="flex" gap={1} mb={1}>
<Button
startIcon={<DescriptionIcon />}
onClick={() => setShowDescription(true)}
size="small"
sx={{
textTransform: "none",
color: "text.secondary",
}}
>
Add description
</Button>
</Box>
</FieldWithLabel>
)}
{showDescription && (
<FieldWithLabel label="Description" isExpanded={showMore}>
@@ -558,15 +558,6 @@ function EventPopover({
</FieldWithLabel>
<FieldWithLabel label=" " isExpanded={showMore}>
<Box display="flex" gap={2} alignItems="center">
<FormControlLabel
control={
<Checkbox
checked={important}
onChange={() => setImportant(!important)}
/>
}
label="Mark as important"
/>
<FormControlLabel
control={
<Checkbox
@@ -629,19 +620,47 @@ function EventPopover({
}
label="Repeat"
/>
<FormControl size="small" sx={{ width: 160 }}>
<Select
value={timezone}
onChange={(e: SelectChangeEvent) => setTimezone(e.target.value)}
displayEmpty
>
{timezoneList.zones.map((tz) => (
<MenuItem key={tz} value={tz}>
({getTimezoneOffset(tz)}) {tz.replace(/_/g, " ")}
</MenuItem>
))}
</Select>
</FormControl>
<Autocomplete
value={timezone}
options={timezoneList.zones}
size="small"
sx={{ width: 240 }}
getOptionLabel={(option) =>
`(${getTimezoneOffset(option)}) ${option.replace(/_/g, " ")}`
}
onChange={(event, newValue) => {
if (newValue) {
setTimezone(newValue);
}
}}
renderInput={(params) => (
<TextField
{...params}
placeholder="Select timezone"
autoComplete="off"
slotProps={{
input: {
...params.InputProps,
startAdornment: (
<>
<TimezoneIcon
style={{
marginRight: 8,
color: "rgba(0, 0, 0, 0.54)",
}}
/>
{params.InputProps.startAdornment}
</>
),
},
}}
inputProps={{
...params.inputProps,
autoComplete: "new-password",
}}
/>
)}
/>
</Box>
</FieldWithLabel>