cozy-ui 128.1.0 → 128.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.json +5 -1
- package/react/ActionsMenu/Actions/viewInDrive.js +2 -1
- package/react/Contacts/AddModal/ContactAddressDialog/helpers.js +22 -0
- package/react/Contacts/AddModal/ContactAddressDialog/helpers.spec.js +64 -0
- package/react/Contacts/AddModal/ContactAddressDialog/index.jsx +84 -0
- package/react/Contacts/AddModal/ContactAddressDialog/locales/en.json +25 -0
- package/react/Contacts/AddModal/ContactAddressDialog/locales/fr.json +25 -0
- package/react/Contacts/AddModal/ContactAddressDialog/locales/index.jsx +7 -0
- package/react/Contacts/AddModal/ContactForm/FieldInput.jsx +117 -0
- package/react/Contacts/AddModal/ContactForm/FieldInputArray.jsx +80 -0
- package/react/Contacts/AddModal/ContactForm/FieldInputLayout.jsx +65 -0
- package/react/Contacts/AddModal/ContactForm/FieldInputWrapper.jsx +41 -0
- package/react/Contacts/AddModal/ContactForm/HasValueCondition.jsx +31 -0
- package/react/Contacts/AddModal/ContactForm/HasValueCondition.spec.jsx +79 -0
- package/react/Contacts/AddModal/ContactForm/RelatedContactList.jsx +37 -0
- package/react/Contacts/AddModal/ContactForm/TextFieldCustomLabelSelect.jsx +78 -0
- package/react/Contacts/AddModal/ContactForm/TextFieldSelect.jsx +39 -0
- package/react/Contacts/AddModal/ContactForm/__snapshots__/HasValueCondition.spec.jsx.snap +33 -0
- package/react/Contacts/AddModal/ContactForm/contactToFormValues.js +99 -0
- package/react/Contacts/AddModal/ContactForm/contactToFormValues.spec.js +128 -0
- package/react/Contacts/AddModal/ContactForm/fieldsConfig.jsx +341 -0
- package/react/Contacts/AddModal/ContactForm/formValuesToContact.js +100 -0
- package/react/Contacts/AddModal/ContactForm/formValuesToContact.spec.js +494 -0
- package/react/Contacts/AddModal/ContactForm/helpers.js +324 -0
- package/react/Contacts/AddModal/ContactForm/helpers.spec.js +152 -0
- package/react/Contacts/AddModal/ContactForm/index.jsx +104 -0
- package/react/Contacts/AddModal/ContactForm/index.spec.jsx +289 -0
- package/react/Contacts/AddModal/ContactForm/locales/en.json +73 -0
- package/react/Contacts/AddModal/ContactForm/locales/fr.json +73 -0
- package/react/Contacts/AddModal/ContactForm/locales/index.jsx +7 -0
- package/react/Contacts/AddModal/ContactForm/styles.styl +2 -0
- package/react/Contacts/AddModal/CustomLabelDialog/index.jsx +108 -0
- package/react/Contacts/AddModal/CustomLabelDialog/locales/en.json +15 -0
- package/react/Contacts/AddModal/CustomLabelDialog/locales/fr.json +15 -0
- package/react/Contacts/AddModal/CustomLabelDialog/locales/index.jsx +7 -0
- package/react/Contacts/AddModal/Readme.md +46 -0
- package/react/Contacts/AddModal/index.jsx +78 -0
- package/react/Contacts/AddModal/locales/en.json +13 -0
- package/react/Contacts/AddModal/locales/fr.json +13 -0
- package/react/Contacts/AddModal/locales/index.jsx +7 -0
- package/react/Contacts/AddModal/mocks.js +249 -0
- package/react/Contacts/AddModal/types.js +57 -0
- package/react/Contacts/Header/Readme.md +0 -2
- package/react/providers/DemoProvider.jsx +3 -2
- package/transpiled/react/ActionsMenu/Actions/viewInDrive.js +2 -1
- package/transpiled/react/Contacts/AddModal/ContactAddressDialog/helpers.d.ts +4 -0
- package/transpiled/react/Contacts/AddModal/ContactAddressDialog/helpers.js +20 -0
- package/transpiled/react/Contacts/AddModal/ContactAddressDialog/helpers.spec.d.ts +1 -0
- package/transpiled/react/Contacts/AddModal/ContactAddressDialog/index.d.ts +39 -0
- package/transpiled/react/Contacts/AddModal/ContactAddressDialog/index.js +87 -0
- package/transpiled/react/Contacts/AddModal/ContactAddressDialog/locales/index.d.ts +6 -0
- package/transpiled/react/Contacts/AddModal/ContactAddressDialog/locales/index.js +54 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInput.d.ts +35 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInput.js +126 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputArray.d.ts +14 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputArray.js +82 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputLayout.d.ts +20 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputLayout.js +70 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputWrapper.d.ts +16 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputWrapper.js +31 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/HasValueCondition.d.ts +18 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/HasValueCondition.js +32 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/HasValueCondition.spec.d.ts +1 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/RelatedContactList.d.ts +15 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/RelatedContactList.js +39 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/TextFieldCustomLabelSelect.d.ts +9 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/TextFieldCustomLabelSelect.js +81 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/TextFieldSelect.d.ts +5 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/TextFieldSelect.js +42 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/contactToFormValues.d.ts +2 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/contactToFormValues.js +88 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/contactToFormValues.spec.d.ts +1 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/fieldsConfig.d.ts +4 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/fieldsConfig.js +278 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/formValuesToContact.d.ts +6 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/formValuesToContact.js +94 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/formValuesToContact.spec.d.ts +1 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/helpers.d.ts +28 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/helpers.js +335 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/helpers.spec.d.ts +1 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/index.d.ts +11 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/index.js +114 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/index.spec.d.ts +1 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/locales/index.d.ts +6 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/locales/index.js +150 -0
- package/transpiled/react/Contacts/AddModal/CustomLabelDialog/index.d.ts +22 -0
- package/transpiled/react/Contacts/AddModal/CustomLabelDialog/index.js +113 -0
- package/transpiled/react/Contacts/AddModal/CustomLabelDialog/locales/index.d.ts +6 -0
- package/transpiled/react/Contacts/AddModal/CustomLabelDialog/locales/index.js +34 -0
- package/transpiled/react/Contacts/AddModal/index.d.ts +7 -0
- package/transpiled/react/Contacts/AddModal/index.js +109 -0
- package/transpiled/react/Contacts/AddModal/locales/index.d.ts +6 -0
- package/transpiled/react/Contacts/AddModal/locales/index.js +30 -0
- package/transpiled/react/Contacts/AddModal/mocks.d.ts +270 -0
- package/transpiled/react/Contacts/AddModal/mocks.js +214 -0
- package/transpiled/react/Contacts/AddModal/types.d.ts +54 -0
- package/transpiled/react/Contacts/AddModal/types.js +49 -0
- package/transpiled/react/providers/DemoProvider.d.ts +2 -1
- package/transpiled/react/providers/DemoProvider.js +7 -3
- package/transpiled/react/stylesheet.css +1 -1
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import Icon from '../../../Icon'
|
|
4
|
+
import BottomIcon from '../../../Icons/Bottom'
|
|
5
|
+
import CalendarIcon from '../../../Icons/Calendar'
|
|
6
|
+
import CloudIcon from '../../../Icons/Cloud'
|
|
7
|
+
import CommentIcon from '../../../Icons/Comment'
|
|
8
|
+
import CompanyIcon from '../../../Icons/Company'
|
|
9
|
+
import EmailIcon from '../../../Icons/Email'
|
|
10
|
+
import LocationIcon from '../../../Icons/Location'
|
|
11
|
+
import PeopleIcon from '../../../Icons/People'
|
|
12
|
+
import RelationshipIcon from '../../../Icons/Relationship'
|
|
13
|
+
import TelephoneIcon from '../../../Icons/Telephone'
|
|
14
|
+
import InputAdornment from '../../../InputAdornment'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {import('../../../types').Field[]}
|
|
18
|
+
*/
|
|
19
|
+
export const fields = [
|
|
20
|
+
{
|
|
21
|
+
name: 'gender',
|
|
22
|
+
icon: PeopleIcon,
|
|
23
|
+
select: true,
|
|
24
|
+
options: [
|
|
25
|
+
{
|
|
26
|
+
value: 'male',
|
|
27
|
+
label: 'Contacts.AddModal.ContactForm.gender.man'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
value: 'female',
|
|
31
|
+
label: 'Contacts.AddModal.ContactForm.gender.woman'
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'givenName',
|
|
37
|
+
icon: null,
|
|
38
|
+
type: 'text'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'additionalName',
|
|
42
|
+
icon: null,
|
|
43
|
+
type: 'text'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'familyName',
|
|
47
|
+
icon: null,
|
|
48
|
+
type: 'text'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'surname',
|
|
52
|
+
icon: null,
|
|
53
|
+
type: 'text'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'company',
|
|
57
|
+
icon: CompanyIcon,
|
|
58
|
+
type: 'text'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'jobTitle',
|
|
62
|
+
icon: null,
|
|
63
|
+
type: 'text'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'phone',
|
|
67
|
+
icon: TelephoneIcon,
|
|
68
|
+
type: 'tel',
|
|
69
|
+
label: {
|
|
70
|
+
name: 'phoneLabel',
|
|
71
|
+
select: true,
|
|
72
|
+
customLabelOptions: {
|
|
73
|
+
defaultType: '',
|
|
74
|
+
defaultLabel: 'home'
|
|
75
|
+
},
|
|
76
|
+
options: [
|
|
77
|
+
{
|
|
78
|
+
value: '',
|
|
79
|
+
label: 'Contacts.AddModal.ContactForm.label.none'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
value: '{"type":"cell","label":"home"}',
|
|
83
|
+
label: 'Contacts.AddModal.ContactForm.label.phone.cell-home'
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
value: '{"type":"cell","label":"work"}',
|
|
87
|
+
label: 'Contacts.AddModal.ContactForm.label.phone.cell-work'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
value: '{"type":"voice","label":"home"}',
|
|
91
|
+
label: 'Contacts.AddModal.ContactForm.label.phone.voice-home'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
value: '{"type":"voice","label":"work"}',
|
|
95
|
+
label: 'Contacts.AddModal.ContactForm.label.phone.voice-work'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
value: '{"type":"fax","label":"home"}',
|
|
99
|
+
label: 'Contacts.AddModal.ContactForm.label.phone.fax-home'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
value: '{"type":"fax","label":"work"}',
|
|
103
|
+
label: 'Contacts.AddModal.ContactForm.label.phone.fax-work'
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
isArray: true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'email',
|
|
111
|
+
icon: EmailIcon,
|
|
112
|
+
type: 'email',
|
|
113
|
+
label: {
|
|
114
|
+
name: 'emailLabel',
|
|
115
|
+
select: true,
|
|
116
|
+
customLabelOptions: {
|
|
117
|
+
defaultType: '',
|
|
118
|
+
defaultLabel: 'home'
|
|
119
|
+
},
|
|
120
|
+
options: [
|
|
121
|
+
{
|
|
122
|
+
value: '',
|
|
123
|
+
label: 'Contacts.AddModal.ContactForm.label.none'
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
value: '{"label":"home"}',
|
|
127
|
+
label: 'Contacts.AddModal.ContactForm.label.home'
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
value: '{"label":"work"}',
|
|
131
|
+
label: 'Contacts.AddModal.ContactForm.label.work'
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
isArray: true
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'address',
|
|
139
|
+
icon: LocationIcon,
|
|
140
|
+
type: 'text',
|
|
141
|
+
InputProps: {
|
|
142
|
+
readOnly: true
|
|
143
|
+
},
|
|
144
|
+
subFields: [
|
|
145
|
+
{
|
|
146
|
+
name: 'street',
|
|
147
|
+
icon: null,
|
|
148
|
+
type: 'text'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'number',
|
|
152
|
+
icon: null,
|
|
153
|
+
type: 'text'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'building',
|
|
157
|
+
icon: null,
|
|
158
|
+
type: 'text'
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'stairs',
|
|
162
|
+
icon: null,
|
|
163
|
+
type: 'text'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'floor',
|
|
167
|
+
icon: null,
|
|
168
|
+
type: 'text'
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: 'apartment',
|
|
172
|
+
icon: null,
|
|
173
|
+
type: 'text'
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'entrycode',
|
|
177
|
+
icon: null,
|
|
178
|
+
type: 'text'
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: 'locality',
|
|
182
|
+
icon: null,
|
|
183
|
+
type: 'text'
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: 'code',
|
|
187
|
+
icon: null,
|
|
188
|
+
type: 'text'
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'city',
|
|
192
|
+
icon: null,
|
|
193
|
+
type: 'text'
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'region',
|
|
197
|
+
icon: null,
|
|
198
|
+
type: 'text'
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'country',
|
|
202
|
+
icon: null,
|
|
203
|
+
type: 'text'
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
label: {
|
|
207
|
+
name: 'addressLabel',
|
|
208
|
+
select: true,
|
|
209
|
+
customLabelOptions: {
|
|
210
|
+
defaultType: '',
|
|
211
|
+
defaultLabel: 'home'
|
|
212
|
+
},
|
|
213
|
+
options: [
|
|
214
|
+
{
|
|
215
|
+
value: '',
|
|
216
|
+
label: 'Contacts.AddModal.ContactForm.label.none'
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
value: '{"label":"home"}',
|
|
220
|
+
label: 'Contacts.AddModal.ContactForm.label.address.home'
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
value: '{"label":"work"}',
|
|
224
|
+
label: 'Contacts.AddModal.ContactForm.label.address.work'
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
isArray: true
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'cozy',
|
|
232
|
+
icon: CloudIcon,
|
|
233
|
+
type: 'url',
|
|
234
|
+
label: {
|
|
235
|
+
name: 'cozyLabel',
|
|
236
|
+
select: true,
|
|
237
|
+
customLabelOptions: {
|
|
238
|
+
defaultType: '',
|
|
239
|
+
defaultLabel: 'home'
|
|
240
|
+
},
|
|
241
|
+
options: [
|
|
242
|
+
{
|
|
243
|
+
value: '',
|
|
244
|
+
label: 'Contacts.AddModal.ContactForm.label.none'
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
value: '{"label":"home"}',
|
|
248
|
+
label: 'Contacts.AddModal.ContactForm.label.home'
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
value: '{"label":"work"}',
|
|
252
|
+
label: 'Contacts.AddModal.ContactForm.label.work'
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'birthday',
|
|
259
|
+
icon: CalendarIcon,
|
|
260
|
+
type: 'date',
|
|
261
|
+
InputLabelProps: { shrink: true }
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'birthplace',
|
|
265
|
+
icon: null,
|
|
266
|
+
type: 'text'
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'relatedContact',
|
|
270
|
+
icon: RelationshipIcon,
|
|
271
|
+
InputProps: {
|
|
272
|
+
readOnly: true,
|
|
273
|
+
endAdornment: (
|
|
274
|
+
<InputAdornment position="end">
|
|
275
|
+
<Icon icon={BottomIcon} color="var(--iconTextColor)" />
|
|
276
|
+
</InputAdornment>
|
|
277
|
+
)
|
|
278
|
+
},
|
|
279
|
+
label: {
|
|
280
|
+
name: 'relatedContactLabel',
|
|
281
|
+
select: true,
|
|
282
|
+
options: [
|
|
283
|
+
{
|
|
284
|
+
value: '',
|
|
285
|
+
label: 'Contacts.AddModal.ContactForm.label.none'
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
value: '{"type":"parent"}',
|
|
289
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.parent'
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
value: '{"type":"child"}',
|
|
293
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.child'
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
value: '{"type":"sibling"}',
|
|
297
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.sibling'
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
value: '{"type":"spouse"}',
|
|
301
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.spouse'
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
value: '{"type":"coResident"}',
|
|
305
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.coResident'
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
value: '{"type":"friend"}',
|
|
309
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.friend'
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
value: '{"type":"colleague"}',
|
|
313
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.colleague'
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
value: '{"type":"coWorker"}',
|
|
317
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.coWorker'
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
value: '{"type":"acquaintance"}',
|
|
321
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.acquaintance'
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
value: '{"type":"helper"}',
|
|
325
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.helper'
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
value: '{"type":"recipient"}',
|
|
329
|
+
label: 'Contacts.AddModal.ContactForm.label.relationship.recipient'
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
},
|
|
333
|
+
isArray: true
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: 'note',
|
|
337
|
+
icon: CommentIcon,
|
|
338
|
+
type: 'text',
|
|
339
|
+
multiline: true
|
|
340
|
+
}
|
|
341
|
+
]
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { updateIndexFullNameAndDisplayName } from 'cozy-client/dist/models/contact'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
removeAsscociatedData,
|
|
5
|
+
removeRelatedContactRelationships,
|
|
6
|
+
createAddress,
|
|
7
|
+
getRelatedContactRelationships,
|
|
8
|
+
makeTypeAndLabel
|
|
9
|
+
} from './helpers'
|
|
10
|
+
|
|
11
|
+
const formValuesToContact = ({ formValues, oldContact, t }) => {
|
|
12
|
+
const {
|
|
13
|
+
gender,
|
|
14
|
+
givenName,
|
|
15
|
+
additionalName,
|
|
16
|
+
surname,
|
|
17
|
+
familyName,
|
|
18
|
+
phone,
|
|
19
|
+
email,
|
|
20
|
+
address,
|
|
21
|
+
cozy,
|
|
22
|
+
company,
|
|
23
|
+
jobTitle,
|
|
24
|
+
birthday,
|
|
25
|
+
birthplace,
|
|
26
|
+
note,
|
|
27
|
+
relatedContact
|
|
28
|
+
} = formValues
|
|
29
|
+
|
|
30
|
+
const relatedContactRelationships =
|
|
31
|
+
getRelatedContactRelationships(relatedContact)
|
|
32
|
+
|
|
33
|
+
const oldContactCleaned = removeRelatedContactRelationships(
|
|
34
|
+
removeAsscociatedData(oldContact)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
const relationshipsFormValues = {
|
|
38
|
+
...oldContactCleaned?.relationships,
|
|
39
|
+
...relatedContactRelationships,
|
|
40
|
+
// If we don't create the relationships field manually, cozy-client doesn't create it automatically when needed (eg. b56ea9dd308c31555aa1433514fa3481adb92f31)
|
|
41
|
+
groups: {
|
|
42
|
+
data: []
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const contactWithFormValues = {
|
|
47
|
+
...oldContactCleaned,
|
|
48
|
+
gender: gender || '',
|
|
49
|
+
name: {
|
|
50
|
+
...oldContactCleaned?.name,
|
|
51
|
+
givenName: givenName || '',
|
|
52
|
+
additionalName: additionalName,
|
|
53
|
+
surname: surname,
|
|
54
|
+
familyName: familyName || ''
|
|
55
|
+
},
|
|
56
|
+
email: email
|
|
57
|
+
? email
|
|
58
|
+
.filter(val => val && val.email)
|
|
59
|
+
.map(({ email, emailLabel }, index) => ({
|
|
60
|
+
address: email,
|
|
61
|
+
...makeTypeAndLabel(emailLabel),
|
|
62
|
+
primary: index === 0
|
|
63
|
+
}))
|
|
64
|
+
: [],
|
|
65
|
+
address: createAddress({ address, oldContact: oldContactCleaned, t }),
|
|
66
|
+
phone: phone
|
|
67
|
+
? phone
|
|
68
|
+
.filter(val => val && val.phone)
|
|
69
|
+
.map(({ phone, phoneLabel }, index) => ({
|
|
70
|
+
number: phone,
|
|
71
|
+
...makeTypeAndLabel(phoneLabel),
|
|
72
|
+
primary: index === 0
|
|
73
|
+
}))
|
|
74
|
+
: [],
|
|
75
|
+
cozy: cozy
|
|
76
|
+
? [
|
|
77
|
+
{
|
|
78
|
+
url: cozy,
|
|
79
|
+
...makeTypeAndLabel(formValues['cozyLabel']),
|
|
80
|
+
primary: true
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
: [],
|
|
84
|
+
company: company || '',
|
|
85
|
+
jobTitle: jobTitle || '',
|
|
86
|
+
birthday: birthday || '',
|
|
87
|
+
birthplace: birthplace || '',
|
|
88
|
+
note: note || '',
|
|
89
|
+
relationships: relationshipsFormValues,
|
|
90
|
+
metadata: {
|
|
91
|
+
...oldContactCleaned?.metadata,
|
|
92
|
+
version: 1,
|
|
93
|
+
cozy: true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return updateIndexFullNameAndDisplayName(contactWithFormValues)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default formValuesToContact
|