1 import { useMemo } from 'react';
3 import { useContactEmailsCache } from '@proton/components';
4 import { getContactDisplayNameEmail } from '@proton/shared/lib/contacts/contactEmail';
5 import { canonicalizeEmail } from '@proton/shared/lib/helpers/email';
7 import type { CalendarViewBusyEvent } from '../../containers/calendar/interface';
8 import { getEventStyle } from '../../helpers/color';
9 import { useCalendarSelector } from '../../store/hooks';
10 import type { PartDayEventProps } from './PartDayEvent';
11 import { PartDayEventView } from './PartDayEvent';
13 interface PartDayBusyEventProps
16 'size' | 'style' | 'formatTime' | 'eventPartDuration' | 'isSelected' | 'isBeforeNow' | 'eventRef'
18 event: CalendarViewBusyEvent;
21 const PartDayBusyEvent = ({
29 }: PartDayBusyEventProps) => {
30 const canonicalizedEmail = canonicalizeEmail(event.email);
31 const isHighlighted = useCalendarSelector(
32 (state) => state.calendarBusySlots.attendeeHighlight === canonicalizedEmail
35 const { contactEmailsMap } = useContactEmailsCache();
36 const { Name: contactName } = contactEmailsMap[canonicalizedEmail] || {};
38 const { nameEmail } = getContactDisplayNameEmail({ name: contactName, email: event.email });
40 const { color } = event;
41 const eventStyle = useMemo(() => {
42 return getEventStyle(color, style);
52 boxShadow: `0 0 0 2px ${color}`,
57 isSelected={isSelected}
61 eventPartDuration={eventPartDuration}
63 <div data-testid="calendar-day-week-view:part-day-event" className="calendar-eventcell-title">
64 <div className="flex flex-nowrap items-center">
65 <div className="text-ellipsis flex-shrink">{nameEmail}</div>
72 export default PartDayBusyEvent;