1 import { useRef } from 'react';
3 import { c } from 'ttag';
5 import { MemoizedIconRow as IconRow } from '@proton/components';
6 import type { VIEWS } from '@proton/shared/lib/calendar/constants';
7 import { PARTICIPANTS_INPUT_ID } from '@proton/shared/lib/calendar/constants';
8 import { getIsProtonUID } from '@proton/shared/lib/calendar/helper';
9 import type { Address } from '@proton/shared/lib/interfaces';
10 import type { AttendeeModel, EventModel } from '@proton/shared/lib/interfaces/calendar';
12 import BusySlotsSpotlight from '../BusySlotsSpotlight';
13 import { getOrganizerAndSelfAddressModel } from '../eventForm/state';
14 import ParticipantsInput from '../inputs/ParticipantsInput';
17 canEditSharedEventData: boolean;
18 isCreateEvent: boolean;
20 setModel: (value: EventModel) => void;
23 onDisplayBusySlots?: () => void;
24 setParticipantError?: (value: boolean) => void;
28 export const RowParticipants = ({
29 canEditSharedEventData,
39 const isOrganizerOfInvitationRef = useRef(!isCreateEvent && !!model.isOrganizer);
40 const isOrganizerOfInvitation = isOrganizerOfInvitationRef.current;
42 const isImportedEvent = model.uid && !getIsProtonUID(model.uid);
43 if (!canEditSharedEventData || isImportedEvent) {
47 const handleChangeAttendees = (value: AttendeeModel[]) => {
48 const { organizer: newOrganizer, selfAddress: newSelfAddress } = getOrganizerAndSelfAddressModel({
50 addressID: model.member.addressID,
58 isOrganizer: isOrganizerOfInvitation ? true : !!value.length,
59 organizer: isOrganizerOfInvitation ? model.organizer : newOrganizer,
60 selfAddress: isOrganizerOfInvitation ? model.selfAddress : newSelfAddress,
65 <BusySlotsSpotlight view={view} isDisplayedInPopover={!!isMinimal}>
66 <IconRow icon="users" title={c('Label').t`Participants`} id={PARTICIPANTS_INPUT_ID}>
68 placeholder={c('Placeholder').t`Add participants`}
69 id={PARTICIPANTS_INPUT_ID}
70 value={model.attendees}
71 isOwnedCalendar={model.calendar.isOwned}
72 onChange={handleChangeAttendees}
73 organizer={model.organizer}
75 collapsible={!isMinimal}
76 setParticipantError={setParticipantError}
77 onDisplayBusySlots={onDisplayBusySlots}
78 displayBusySlots={!!isMinimal}