Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -15,6 +15,8 @@ import { formatDateToYYYYMMDDTHHMMSS } from "../../../utils/dateUtils";
|
||||
import { getEvent } from "../../../features/Events/EventApi";
|
||||
import { refreshCalendars } from "../../Event/utils/eventUtils";
|
||||
import { updateTempCalendar } from "../utils/calendarUtils";
|
||||
import { User } from "../../Attendees/PeopleSearch";
|
||||
import { formatLocalDateTime } from "../../../features/Events/EventModal";
|
||||
|
||||
export interface EventHandlersProps {
|
||||
setSelectedRange: (range: DateSelectArg | null) => void;
|
||||
@@ -32,6 +34,9 @@ export interface EventHandlersProps {
|
||||
setSelectedEvent: (event: CalendarEvent) => void;
|
||||
setAfterChoiceFunc: (func: Function) => void;
|
||||
setOpenEditModePopup: (open: string) => void;
|
||||
tempUsers: User[];
|
||||
setTempEvent: (event: CalendarEvent) => void;
|
||||
timezone: string;
|
||||
}
|
||||
|
||||
export const createEventHandlers = (props: EventHandlersProps) => {
|
||||
@@ -51,10 +56,33 @@ export const createEventHandlers = (props: EventHandlersProps) => {
|
||||
setSelectedEvent,
|
||||
setAfterChoiceFunc,
|
||||
setOpenEditModePopup,
|
||||
tempUsers,
|
||||
setTempEvent,
|
||||
timezone,
|
||||
} = props;
|
||||
|
||||
const handleDateSelect = (selectInfo: DateSelectArg) => {
|
||||
setSelectedRange(selectInfo);
|
||||
if (tempUsers) {
|
||||
const newEvent: CalendarEvent = {
|
||||
start: selectInfo?.start
|
||||
? formatLocalDateTime(selectInfo?.start, timezone)
|
||||
: "",
|
||||
end: selectInfo?.end
|
||||
? formatLocalDateTime(selectInfo?.end, timezone)
|
||||
: "",
|
||||
attendee: tempUsers.map((u) => ({
|
||||
cn: u.displayName,
|
||||
cal_address: u.email,
|
||||
partstat: "NEED-ACTION",
|
||||
role: "REQ-PARTICIPANT",
|
||||
rsvp: "TRUE",
|
||||
cutype: "INDIVIDUAL",
|
||||
})),
|
||||
} as CalendarEvent;
|
||||
|
||||
setTempEvent(newEvent);
|
||||
}
|
||||
setAnchorEl(document.body);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user