1 import { c } from 'ttag';
3 import { encodeImageUri, forgeImageURL } from '@proton/shared/lib/helpers/image';
4 import { isBase64Image } from '@proton/shared/lib/helpers/validators';
6 export const getAllFields = () => [
7 // translator: this field is used to specify the display name of the contact (e.g. Jane Appleseed)
8 { text: c('Contact field label').t`Display name`, value: 'fn' },
9 // translator: this field is used to specify the first name of the contact (e.g. Jane)
10 { text: c('Contact field label').t`First name`, value: 'firstName' },
11 // translator: this field is used to specify the last name of the contact (e.g. Appleseed)
12 { text: c('Contact field label').t`Last name`, value: 'lastName' },
13 // translator: this field is used to specify the email of the contact (e.g. jane.appleseed@pm.me)
14 { text: c('Contact field label').t`Email`, value: 'email' },
15 // translator: this field is used to specify the phone number of the contact
16 { text: c('Contact field label').t`Phone`, value: 'tel' },
17 // translator: this field is used to specify the address of the contact
18 { text: c('Contact field label').t`Address`, value: 'adr' },
19 // translator: this field is used to add a picture for the contact
20 { text: c('Contact field label').t`Photo`, value: 'photo' },
21 // translator: this field is used to specify the organization's name of the contact
22 { text: c('Contact field label').t`Organization`, value: 'org' },
23 // translator: this field is used to specify the birth date of the contact
24 { text: c('Contact field label').t`Birthday`, value: 'bday' },
25 // translator: this field is used to specify the anniversary date of the contact (e.g. marriage, or equivalent)
26 { text: c('Contact field label').t`Anniversary`, value: 'anniversary' },
27 // translator: this field is used to specify the position or job of the contact
28 { text: c('Contact field label').t`Title`, value: 'title' },
29 // translator: this field is used to specify the specific role of the contact given the type of relationship with the user
30 { text: c('Contact field label').t`Role`, value: 'role' },
31 // translator: this field is used to add a note about the contact
32 { text: c('Contact field label').t`Note`, value: 'note' },
33 // translator: this field is used to add a URL for the contact
34 { text: c('Contact field label').t`URL`, value: 'url' },
35 // translator: this field is used to specify the gender of the contact
36 { text: c('Contact field label').t`Gender`, value: 'gender' },
37 // translator: this field is used to specify the primary language of the contact
38 { text: c('Contact field label').t`Language`, value: 'lang' },
39 // translator: this field is used to specify the timezone of the contact
40 { text: c('Contact field label').t`Time zone`, value: 'tz' },
41 // translator: this field is used to add a logo for the contact
42 { text: c('Contact field label').t`Logo`, value: 'logo' },
43 // translator: this field is used to specify the group a contact would be a member of
44 { text: c('Contact field label').t`Member`, value: 'member' },
47 export const getEditableFields = () => [
48 { text: c('Contact field label').t`Name`, value: 'fn' },
49 { text: c('Contact field label').t`Email`, value: 'email' },
50 { text: c('Contact field label').t`Phone`, value: 'tel' },
51 { text: c('Contact field label').t`Address`, value: 'adr' },
52 { text: c('Contact field label').t`Photo`, value: 'photo' },
53 { text: c('Contact field label').t`Organization`, value: 'org' },
54 // translator: this field is used to specify the birth date of the contact
55 { text: c('Contact field label').t`Birthday`, value: 'bday' },
56 // translator: this field is used to specify the anniversary date of the contact (e.g. marriage, or equivalent)
57 { text: c('Contact field label').t`Anniversary`, value: 'anniversary' },
58 { text: c('Contact field label').t`Title`, value: 'title' },
59 { text: c('Contact field label').t`Role`, value: 'role' },
60 { text: c('Contact field label').t`Member`, value: 'member' },
61 { text: c('Contact field label').t`Note`, value: 'note' },
62 { text: c('Contact field label').t`URL`, value: 'url' },
63 { text: c('Contact field label').t`Gender`, value: 'gender' },
64 { text: c('Contact field label').t`Language`, value: 'lang' },
65 { text: c('Contact field label').t`Time zone`, value: 'tz' },
66 { text: c('Contact field label').t`Logo`, value: 'logo' },
68 export const getOtherInformationFields = () => [
69 { text: c('Contact field label').t`Photo`, value: 'photo' },
70 { text: c('Contact field label').t`Organization`, value: 'org' },
71 // translator: this field is used to specify the anniversary date of the contact (e.g. marriage, or equivalent)
72 { text: c('Contact field label').t`Anniversary`, value: 'anniversary' },
73 { text: c('Contact field label').t`Title`, value: 'title' },
74 { text: c('Contact field label').t`Role`, value: 'role' },
75 { text: c('Contact field label').t`Member`, value: 'member' },
76 { text: c('Contact field label').t`URL`, value: 'url' },
77 { text: c('Contact field label').t`Gender`, value: 'gender' },
78 { text: c('Contact field label').t`Language`, value: 'lang' },
79 { text: c('Contact field label').t`Time zone`, value: 'tz' },
80 { text: c('Contact field label').t`Logo`, value: 'logo' },
83 // The first and last name fields are here since they are splitted from the N field
84 export const getAllFieldLabels = () => ({
85 lastName: c('Contact field label').t`Last name`,
86 firstName: c('Contact field label').t`First name`,
87 n: c('Contact field label').t`Name`,
88 fn: c('Contact field label').t`Display name`,
89 email: c('Contact field label').t`Email`,
90 tel: c('Contact field label').t`Phone`,
91 adr: c('Contact field label').t`Address`,
92 photo: c('Contact field label').t`Photo`,
93 org: c('Contact field label').t`Organization`,
94 // translator: this field is used to specify the birth date of the contact
95 bday: c('Contact field label').t`Birthday`,
96 // translator: this field is used to specify the anniversary date of the contact (e.g. marriage, or equivalent)
97 anniversary: c('Contact field label').t`Anniversary`,
98 title: c('Contact field label').t`Title`,
99 role: c('Contact field label').t`Role`,
100 note: c('Contact field label').t`Note`,
101 url: c('Contact field label').t`URL`,
102 gender: c('Contact field label').t`Gender`,
103 lang: c('Contact field label').t`Language`,
104 tz: c('Contact field label').t`Time zone`,
105 logo: c('Contact field label').t`Logo`,
106 member: c('Contact field label').t`Member`,
109 export const getTypeLabels = () => ({
110 work: c('Contact type label').t`Work`,
111 home: c('Contact type label').t`Personal`,
112 cell: c('Contact type label').t`Mobile`,
113 main: c('Contact type label').t`Main`,
114 // translator: Yomi name is a field for entering the phonetic equivalent for Japanese names
115 yomi: c('Contact type label').t`Yomi`,
116 other: c('Contact type label').t`Other`,
117 fax: c('Contact type label').t`Fax`,
118 // translator: https://en.wikipedia.org/wiki/Pager
119 pager: c('Contact type label').t`Pager`,
122 export const getAllTypes: () => { [key: string]: { text: string; value: string }[] } = () => ({
126 { text: c('Property type').t`Email`, value: '' },
127 { text: c('Property type').t`Home`, value: 'home' },
128 { text: c('Property type').t`Work`, value: 'work' },
129 { text: c('Property type').t`Other`, value: 'other' },
132 { text: c('Property type').t`Phone`, value: '' },
133 { text: c('Property type').t`Home`, value: 'home' },
134 { text: c('Property type').t`Work`, value: 'work' },
135 { text: c('Property type').t`Other`, value: 'other' },
136 { text: c('Property type').t`Mobile`, value: 'cell' },
137 { text: c('Property type').t`Main`, value: 'main' },
138 { text: c('Property type').t`Fax`, value: 'fax' },
139 { text: c('Property type').t`Pager`, value: 'pager' },
142 { text: c('Property type').t`Address`, value: '' },
143 { text: c('Property type').t`Home`, value: 'home' },
144 { text: c('Property type').t`Work`, value: 'work' },
145 { text: c('Property type').t`Other`, value: 'other' },
162 export const getTypeValues: () => { [key: string]: string[] } = () => ({
164 email: ['', 'home', 'work', 'other'],
165 tel: ['', 'home', 'work', 'other', 'cell', 'main', 'fax', 'pager'],
166 adr: ['', 'home', 'work', 'other'],
183 * Get the source of the contact image (can be contact profile image, Logo or Photo fields)
184 * It will allow to load the image normally if a base 64 or using the Proton proxy is disabled
185 * Else we will forge the url to load it through the Proton proxy
187 export const getContactImageSource = ({
200 // If the image is not a base64 but a URL, then we want to load the image through the proxy
201 if (!isBase64Image(url) && useProxy) {
202 const encodedImageUrl = encodeImageUri(url);
203 return forgeImageURL({ apiUrl, url: encodedImageUrl, uid, origin });