Update all non-major dependencies
[ProtonMail-WebClient.git] / applications / calendar / src / app / containers / setup / UnlockCalendarsContainer.tsx
blobb90989e059f544904fbce63a848ddfce63fcd665
1 import { useActiveBreakpoint } from '@proton/components/index';
2 import { getPersonalCalendars } from '@proton/shared/lib/calendar/calendar';
3 import type { VIEWS } from '@proton/shared/lib/calendar/constants';
4 import type { VisualCalendar } from '@proton/shared/lib/interfaces/calendar';
6 import DummyCalendarContainerView from '../calendar/DummyCalendarContainerView';
7 import UnlockCalendarsModal from './UnlockCalendarsModal';
9 interface Props {
10     calendars: VisualCalendar[];
11     calendarsToUnlock: VisualCalendar[];
12     onDone: () => void;
13     drawerView?: VIEWS;
14     hasReactivatedCalendarsRef: React.MutableRefObject<boolean>;
16 const UnlockCalendarsContainer = ({
17     calendars,
18     calendarsToUnlock,
19     onDone,
20     drawerView,
21     hasReactivatedCalendarsRef,
22 }: Props) => {
23     const { viewportWidth } = useActiveBreakpoint();
24     // Don't take into account subscribed calendars to decide whether to show a partial list of the calendars that need reset.
25     // Although we do need to reset the calendar keys for those, they will be immediately re-synced so the users should not see them "locked"
26     const numberOfPersonalCalendars = getPersonalCalendars(calendars).length;
27     const numberOfPersonalCalendarsToUnlock = getPersonalCalendars(calendarsToUnlock).length;
28     const hasOnlySubscribedCalendarsToUnlock = numberOfPersonalCalendarsToUnlock === 0;
29     const unlockAll =
30         hasOnlySubscribedCalendarsToUnlock || numberOfPersonalCalendars === numberOfPersonalCalendarsToUnlock;
32     return (
33         <>
34             <UnlockCalendarsModal
35                 calendars={calendarsToUnlock}
36                 unlockAll={unlockAll}
37                 hasReactivatedCalendarsRef={hasReactivatedCalendarsRef}
38                 onDone={onDone}
39             />
40             <DummyCalendarContainerView drawerView={drawerView} isSmallViewport={viewportWidth['<=small']} />
41         </>
42     );
45 export default UnlockCalendarsContainer;