Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import React, { useState } from "react";
import Checkbox from "@material-ui/core/Checkbox";
import { SketchPicker } from "react-color";
import FormGroup from "@material-ui/core/FormGroup";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import { TextField, makeStyles } from "@material-ui/core";
import Typography from "@material-ui/core/Typography";
import CustomImgDropZone from "components/CustomImgDropZone/CustomImgDropZone";
import i18next from "i18next";
const styles = {
colorButtonStyle: {
borderRadius: "50%",
width: "20px",
height: "20px",
border: "1px solid grey",
outline: "none",
cursor: "pointer",
},
popover: {
position: "absolute",
zIndex: "2",
},
cover: {
position: "fixed",
top: "0px",
right: "0px",
bottom: "0px",
left: "0px",
},
};
const useStyles = makeStyles(styles);
const IsCustomizationEnabledForm = ({
isCustomizationEnabled,
handleUpdateUi,
}) => {
return (
<FormGroup row>
<FormControlLabel
control={
<Checkbox
checked={isCustomizationEnabled}
color="primary"
onChange={(e) => {
handleUpdateUi("isCustomizationEnabled", e.target.checked);
}}
name="isCustomizationEnabled"
/>
}
label={i18next.t("is_customization_enabled", "Enable customization")}
/>
</FormGroup>
);
};
const HasTitleForm = ({ uiCustomization, handleUpdateUi }) => {
return (
<FormGroup row>
<FormControlLabel
control={
<Checkbox
checked={uiCustomization.hasTitle}
color="primary"
onChange={(e) => {
handleUpdateUi("hasTitle", e.target.checked);
}}
name="hasTitle"
/>
}
label={i18next.t("welcome_has_title", "Title")}
/>
</FormGroup>
);
};
const TitleForm = ({ uiCustomization, handleUpdateUi }) => {
if (!uiCustomization.hasTitle) {
return null;
}
return (
<FormGroup row>
<span>
{i18next.t(
"instruction_title",
"Use Jami title or personalize it (max 40 characters)"
)}
</span>
<TextField
id="title"
placeholder={i18next.t("welcome_title", "Welcome to Jami")}
value={uiCustomization.title}
handleUpdateUi("title", e.target.value);
inputProps={{ maxLength: 40 }}
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/>
</FormGroup>
);
};
const HasDescriptionForm = ({ uiCustomization, handleUpdateUi }) => {
return (
<FormGroup row>
<FormControlLabel
control={
<Checkbox
checked={uiCustomization.hasDescription}
color="primary"
name="hasDescription"
onChange={(e) => {
handleUpdateUi("hasDescription", e.target.checked);
}}
/>
}
label={i18next.t("welcome_has_description", "Description")}
/>
</FormGroup>
);
};
const DescriptionForm = ({ uiCustomization, handleUpdateUi }) => {
return (
<FormGroup row>
{uiCustomization.hasDescription && (
<>
<span>
{i18next.t(
"instruction_description",
"Use Jami description or personalize it (max 100 characters)"
)}
</span>
<TextField
id="description"
placeholder={i18next.t(
"welcome_Description",
"Here is your Jami identifier, don’t hesitate to share it in order to be contacted more easily!"
)}
value={uiCustomization.description}
handleUpdateUi("description", e.target.value);
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
}}
fullWidth
inputProps={{ maxLength: 100 }}
/>
</>
)}
</FormGroup>
);
};
const HasTipsForm = ({ uiCustomization, handleUpdateUi }) => {
return (
<FormGroup row>
<FormControlLabel
control={
<Checkbox
checked={uiCustomization.hasTips}
color="primary"
onChange={(e) => {
handleUpdateUi("hasTips", e.target.checked);
}}
name="hasTips"
/>
}
label={i18next.t("welcome_has_Tips", "Tips")}
/>
</FormGroup>
);
};
const HasBackgroundCustomForm = ({ uiCustomization, handleUpdateUi }) => {
return (
<FormGroup row>
<FormControlLabel
control={
<Checkbox
checked={uiCustomization.hasBackground}
color="primary"
onChange={(e) => {
handleUpdateUi("hasBackground", e.target.checked);
name="hasBackground"
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/>
}
label={i18next.t("welcome_has_BackgroundCustom", "Background")}
/>
</FormGroup>
);
};
const CustomBackgroundForm = ({
uiCustomization,
handleColorChange,
handleUpdateUi,
handleImgDrop,
bgFile,
}) => {
const classes = useStyles();
const [displayColorPicker, setDisplayColorPicker] = useState(false);
const handleClickColor = () => {
setDisplayColorPicker(!displayColorPicker);
};
const setBgFile = (value) => {
handleUpdateUi("bgFile", value);
};
const handleCloseColor = () => {
setDisplayColorPicker(false);
};
return (
<FormGroup row>
{uiCustomization.hasBackground && (
<>
<span>
{i18next.t(
"instruction_background",
"Choose a background color or a background image"
)}
</span>
<FormGroup
style={{
display: "flex",
alignItems: "center",
justifyContent: "left",
flexDirection: "row",
padding: "10px 0",
}}
>
<div style={{ padding: "0 20px" }}>
<button
style={{
backgroundColor: uiCustomization.backgroundColor,
}}
className={classes.colorButtonStyle}
onClick={() => {
handleClickColor();
}}
/>
{displayColorPicker && (
<div className={classes.popover}>
<div className={classes.cover} onClick={handleCloseColor} />
<SketchPicker
color={uiCustomization.backgroundColor}
onChange={(color) => {
handleColorChange(color);
handleUpdateUi("backgroundColor", color.hex);
}}
/>
</div>
)}
</div>
<div style={{ padding: "0 20px" }}>
<Typography>{i18next.t("or", "or")}</Typography>
</div>
<div style={{ padding: "0 20px" }}>
<CustomImgDropZone
onDrop={(files) => {
handleImgDrop(files, "background");
}}
label={i18next.t("upload_an_image", "Upload an image").toUpperCase()}
file={bgFile}
setFile={setBgFile}
handleDelete={(e) => {
handleUpdateUi("backgroundUrl", "");
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
e.preventDefault();
e.stopPropagation();
}}
/>
</div>
</FormGroup>
</>
)}
</FormGroup>
);
};
const HasLogoForm = ({ uiCustomization, handleUpdateUi }) => {
return (
<FormGroup row>
<FormControlLabel
control={
<Checkbox
checked={uiCustomization.hasLogo}
color="primary"
onChange={(e) => {
handleUpdateUi("hasLogo", e.target.checked);
}}
name="hasLogo"
/>
}
label={i18next.t("welcome_has_Logo", "Logotype")}
/>
</FormGroup>
);
};
const LogoForm = ({
handleImgDrop,
handleDeleteLogo,
handleUpdateUi,
logoFile,
}) => {
const setLogoFile = (value) => {
handleUpdateUi("logoFile", value);
};
return (
<>
<span>
{i18next.t(
"instruction_logo",
"Use Jami logotype or upload a logotype"
)}
</span>
<FormGroup row style={{ padding: "10px 0" }}>
<CustomImgDropZone
onDrop={(files) => handleImgDrop(files, "logo")}
label={i18next.t("upload_a_logotype", "Upload a logotype").toUpperCase()}
file={logoFile}
setFile={setLogoFile}
handleDelete={(e) => {
handleDeleteLogo(e);
handleUpdateUi("logoUrl", null);
}}
/>
</FormGroup>
</>
);
};
const EditBlueprintUiForm = ({
uiCustomization,
setUiCustomization,
handleUpdateUi,
handleImgDrop,
}) => {
const { isCustomizationEnabled } = uiCustomization;
const bgFile = uiCustomization.backgroundUrl?.split("/").pop();
const logoFile = uiCustomization.logoUrl?.split("/").pop();
const handleDeleteLogo = (e) => {
setUiCustomization({
...uiCustomization,
logoUrl: "",
});
e.stopPropagation();
};
const handleColorChange = (color) => {
setUiCustomization({
...uiCustomization,
backgroundColor: color.hex,
backgroundUrl: "",
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
});
};
return (
<>
<IsCustomizationEnabledForm
isCustomizationEnabled={isCustomizationEnabled}
handleUpdateUi={handleUpdateUi}
/>
{isCustomizationEnabled && (
<>
<HasTitleForm
uiCustomization={uiCustomization}
handleUpdateUi={handleUpdateUi}
/>
<TitleForm
uiCustomization={uiCustomization}
handleUpdateUi={handleUpdateUi}
/>
<HasDescriptionForm
uiCustomization={uiCustomization}
handleUpdateUi={handleUpdateUi}
/>
<DescriptionForm
uiCustomization={uiCustomization}
handleUpdateUi={handleUpdateUi}
/>
<HasTipsForm
uiCustomization={uiCustomization}
handleUpdateUi={handleUpdateUi}
/>
<HasBackgroundCustomForm
uiCustomization={uiCustomization}
handleUpdateUi={handleUpdateUi}
/>
<CustomBackgroundForm
uiCustomization={uiCustomization}
handleColorChange={handleColorChange}
handleUpdateUi={handleUpdateUi}
handleImgDrop={handleImgDrop}
bgFile={bgFile}
/>
<HasLogoForm
uiCustomization={uiCustomization}
handleUpdateUi={handleUpdateUi}
/>
{uiCustomization.hasLogo && (
<LogoForm
handleImgDrop={handleImgDrop}
handleDeleteLogo={handleDeleteLogo}
handleUpdateUi={handleUpdateUi}
logoFile={logoFile}
/>
)}
</>
)}
</>
);
};
export default EditBlueprintUiForm;