Remove payments API routing initialization
[ProtonMail-WebClient.git] / packages / components / containers / contacts / edit / fields / ContactFieldProperty.tsx
blob08e0f9c954be5b048a0ca62fbce4940ee4405d9a
1 import type { Ref } from 'react';
2 import { forwardRef } from 'react';
4 import type { VCardContact, VCardProperty } from '@proton/shared/lib/interfaces/contacts/VCard';
6 import type { ContactImageProps } from '../../modals/ContactImageModal';
7 import ContactFieldAdr from './ContactFieldAdr';
8 import ContactFieldDate from './ContactFieldDate';
9 import ContactFieldEmail from './ContactFieldEmail';
10 import ContactFieldFn from './ContactFieldFn';
11 import ContactFieldGender from './ContactFieldGender';
12 import ContactFieldImage from './ContactFieldImage';
13 import ContactFieldN from './ContactFieldN';
14 import ContactFieldNote from './ContactFieldNote';
15 import ContactFieldOrg from './ContactFieldOrg';
16 import ContactFieldString from './ContactFieldString';
17 import ContactFieldTel from './ContactFieldTel';
19 interface Props {
20     vCardContact: VCardContact;
21     vCardProperty: VCardProperty<any>;
22     onChangeVCard: (vCardProperty: VCardProperty) => void;
23     onSelectImage: (props: ContactImageProps) => void;
24     isSubmitted?: boolean;
27 const ContactFieldProperty = (
28     { vCardContact, vCardProperty, onChangeVCard, onSelectImage, isSubmitted = false, ...rest }: Props,
29     ref: Ref<HTMLInputElement>
30 ) => {
31     const { field } = vCardProperty;
33     if (field === 'email') {
34         return <ContactFieldEmail vCardProperty={vCardProperty} onChange={onChangeVCard} {...rest} />;
35     }
37     if (field === 'tel') {
38         return <ContactFieldTel vCardProperty={vCardProperty} onChange={onChangeVCard} {...rest} />;
39     }
41     if (field === 'adr') {
42         return <ContactFieldAdr vCardProperty={vCardProperty} onChange={onChangeVCard} {...rest} />;
43     }
45     if (field === 'note') {
46         return <ContactFieldNote vCardProperty={vCardProperty} onChange={onChangeVCard} {...rest} />;
47     }
49     if (field === 'bday' || field === 'anniversary') {
50         return <ContactFieldDate vCardProperty={vCardProperty} onChange={onChangeVCard} {...rest} />;
51     }
53     if (field === 'photo' || field === 'logo') {
54         return (
55             <ContactFieldImage
56                 vCardProperty={vCardProperty}
57                 onChange={onChangeVCard}
58                 onSelectImage={onSelectImage}
59                 {...rest}
60             />
61         );
62     }
64     if (field === 'fn') {
65         return (
66             <ContactFieldFn
67                 ref={ref}
68                 vCardProperty={vCardProperty}
69                 vCardContact={vCardContact}
70                 onChange={onChangeVCard}
71                 isSubmitted={isSubmitted}
72                 {...rest}
73             />
74         );
75     }
77     if (field === 'gender') {
78         return <ContactFieldGender vCardProperty={vCardProperty} onChange={onChangeVCard} {...rest} />;
79     }
81     if (field === 'n') {
82         return (
83             <ContactFieldN
84                 ref={ref}
85                 vCardContact={vCardContact}
86                 isSubmitted={isSubmitted}
87                 vCardProperty={vCardProperty}
88                 onChangeVCard={onChangeVCard}
89                 {...rest}
90             />
91         );
92     }
94     if (field === 'org') {
95         return <ContactFieldOrg vCardProperty={vCardProperty} onChange={onChangeVCard} {...rest} />;
96     }
98     return <ContactFieldString vCardProperty={vCardProperty} onChange={onChangeVCard} {...rest} />;
101 export default forwardRef(ContactFieldProperty);