1 import { useState } from 'react';
3 import { c } from 'ttag';
5 import { Href } from '@proton/atoms';
10 CollapsibleHeaderIconButton,
12 } from '@proton/components';
13 import CalendarSelectIcon from '@proton/components/components/calendarSelect/CalendarSelectIcon';
14 import { getKnowledgeBaseUrl } from '@proton/shared/lib/helpers/url';
15 import type { VisualCalendar } from '@proton/shared/lib/interfaces/calendar';
16 import encryptedEventSvg from '@proton/styles/assets/img/illustrations/encrypted-event.svg';
18 const getFirstParagraphText = (resetAll: boolean) => {
20 return c('Info; reset calendar keys modal; part 1')
21 .t`Your calendars will not show details of previously created events.`;
23 return c('Info; reset calendar keys modal; part 1')
24 .t`Some of your calendars will not show details of previously created events.`;
28 calendarsToReset: VisualCalendar[];
31 const CalendarResetSection = ({ calendarsToReset = [], resetAll }: Props) => {
32 const altText = c('Title').t`Encrypted event`;
34 const [show, setShow] = useState(false);
35 const clickShow = () => setShow((show) => !show);
37 const calendarsList = (
39 {calendarsToReset.map(({ ID, Name, Color }) => (
40 <div key={ID} className="flex flex-nowrap w-full items-center mb-2">
41 <span className="flex shrink-0">
42 <CalendarSelectIcon color={Color} className="mr-2" />
44 <span className="text-ellipsis" title={Name}>
54 <p>{getFirstParagraphText(resetAll)}</p>
60 <CollapsibleHeaderIconButton onClick={clickShow}>
61 <Icon name="chevron-down" />
62 </CollapsibleHeaderIconButton>
67 {show ? c('Action').t`Hide affected calendars` : c('Action').t`Show affected calendars`}
69 <CollapsibleContent>{calendarsList}</CollapsibleContent>
73 <div className="flex w-full">
74 <img src={encryptedEventSvg} alt={altText} className="m-auto" />
77 {c('Info; reset calendar keys modal; part 2')
78 .t`This is because your password was recently reset without using a recovery method.`}
81 {c('Info; reset calendar keys modal; part 3')
82 .t`You can recover your encrypted data with a recovery file, recovery phrase, or your old password.`}
85 <Href href={getKnowledgeBaseUrl('/set-account-recovery-methods')}>
86 {c('Link; reset calendar keys modal').t`What's a recovery method?`}
93 export default CalendarResetSection;