From 53342d808f402a9f1d93b718a4a8473de9643b5a Mon Sep 17 00:00:00 2001 From: lethemanh Date: Mon, 27 Apr 2026 15:32:44 +0700 Subject: [PATCH] #809 extract event actions component (#831) Co-authored-by: lethemanh --- src/features/Events/EventActions.tsx | 55 ++++++++++++++++++++++++ src/features/Events/EventModal.tsx | 38 ++++++---------- src/features/Events/EventUpdateModal.tsx | 48 +++++---------------- 3 files changed, 78 insertions(+), 63 deletions(-) create mode 100644 src/features/Events/EventActions.tsx diff --git a/src/features/Events/EventActions.tsx b/src/features/Events/EventActions.tsx new file mode 100644 index 0000000..036756a --- /dev/null +++ b/src/features/Events/EventActions.tsx @@ -0,0 +1,55 @@ +import { useScreenSizeDetection } from '@/useScreenSizeDetection' +import { Box, Button } from '@linagora/twake-mui' +import AddIcon from '@mui/icons-material/Add' +import { useI18n } from 'twake-i18n' + +interface EventActionsProps { + showExpandedBtn: boolean + isEdit?: boolean + onExpanded: () => void + onClose: () => void + onSave: () => Promise +} + +export const EventActions: React.FC = ({ + showExpandedBtn, + isEdit, + onExpanded, + onClose, + onSave +}) => { + const { t } = useI18n() + const { isTooSmall: isMobile } = useScreenSizeDetection() + + return ( + + {showExpandedBtn && ( + + )} + + {(!showExpandedBtn || isEdit) && ( + + )} + + + + ) +} diff --git a/src/features/Events/EventModal.tsx b/src/features/Events/EventModal.tsx index 0eae511..aa0ba13 100644 --- a/src/features/Events/EventModal.tsx +++ b/src/features/Events/EventModal.tsx @@ -26,8 +26,6 @@ import { import { TIMEZONES } from '@/utils/timezone-data' import { addVideoConferenceToDescription } from '@/utils/videoConferenceUtils' import { CalendarApi, DateSelectArg } from '@fullcalendar/core' -import { Box, Button } from '@linagora/twake-mui' -import AddIcon from '@mui/icons-material/Add' import React, { startTransition, useCallback, @@ -44,6 +42,7 @@ import { CalendarEvent, RepetitionObject } from './EventsTypes' import { useEventOrganizer } from './useEventOrganizer' import { buildDelegatedEventURL } from './utils/buildDelegatedEventURL' import { Resource } from '@/components/Attendees/ResourceSearch' +import { EventActions } from './EventActions' function EventPopover({ open, @@ -158,7 +157,9 @@ function EventPopover({ : [] ) const [alarm, setAlarm] = useState(event?.alarm?.trigger ?? '') - const [eventClass, setEventClass] = useState(event?.class ?? 'PUBLIC') + const [eventClass, setEventClass] = useState< + 'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL' + >(event?.class ?? 'PUBLIC') const [busy, setBusy] = useState(event?.transp ?? 'OPAQUE') const [timezone, setTimezone] = useState( event?.timezone ? resolveTimezone(event.timezone) : resolvedCalendarTimezone @@ -789,7 +790,7 @@ function EventPopover({ uid: newEventUID, description, location, - class: eventClass as 'PUBLIC' | 'PRIVATE' | 'CONFIDENTIAL', + class: eventClass, repetition, organizer, timezone, @@ -916,26 +917,6 @@ function EventPopover({ } } - const dialogActions = ( - - {!showMore && ( - - )} - - {showMore && ( - - )} - - - - ) - return ( setShowMore(!showMore)} - actions={dialogActions} + actions={ + setShowMore(!showMore)} + /> + } > - {!showMore && ( - - )} - - - - - - ) - if (!event) return null return ( @@ -1101,7 +1065,15 @@ const EventUpdateModal: React.FC<{ title={t('event.updateEvent')} isExpanded={showMore} onExpandToggle={() => setShowMore(!showMore)} - actions={dialogActions} + actions={ + setShowMore(!showMore)} + /> + } sx={{ '& .MuiDialogActions-root': { paddingLeft: isMobile ? 2 : 4,