Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / applications / drive / src / app / components / modals / ShareLinkModal / DirectSharing / helpers / getAddressInputItemAttributes.tsx
blob4b4ae01739308366f5942fa27360e01b9f4f9b8c
1 import { c } from 'ttag';
3 import { Icon, Loader } from '@proton/components';
5 import type { ShareInvitee } from '../../../../../store';
7 /**
8  * Generates attributes for an address input item based on the loading state, error state, and email.
9  * This function is meant to be use with the adress autocomplete input.
10  */
11 export const getAddressInputItemAttributes = ({ isLoading, error, email, isExternal }: ShareInvitee) => {
12     if (isLoading) {
13         return {
14             icon: <Loader className="icon-size-4 pl-2 m-auto flex shrink-0" />,
15         };
16     }
17     if (error) {
18         return {
19             icon: (
20                 <div className="flex items-center shrink-0 ml-2">
21                     <Icon
22                         name="exclamation-circle-filled"
23                         className="color-danger"
24                         data-testid="invite-address-error"
25                     />
26                 </div>
27             ),
28             iconTooltip: error.message,
29             labelTooltip: email,
30         };
31     }
32     if (isExternal) {
33         return null;
34     }
35     return {
36         icon: (
37             <span className="inline-flex pl-2 shrink-0 my-auto">
38                 <Icon size={4} name="lock-filled" className={'color-info'} data-testid="invite-address-ok" />
39             </span>
40         ),
41         iconTooltip: c('Tooltip').t`Shared with end-to-end encryption`,
42         labelTooltip: email,
43     };