ublo-lib 1.12.9 → 1.12.11
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.
|
@@ -54,7 +54,8 @@ const CustomContactForm = ({
|
|
|
54
54
|
data,
|
|
55
55
|
fields,
|
|
56
56
|
subjectPrefix: subject?.prefix,
|
|
57
|
-
subjectSuffix: subject?.suffix
|
|
57
|
+
subjectSuffix: subject?.suffix,
|
|
58
|
+
kind
|
|
58
59
|
});
|
|
59
60
|
if (error) {
|
|
60
61
|
snackbar.show({
|
|
@@ -67,7 +68,7 @@ const CustomContactForm = ({
|
|
|
67
68
|
message: Messages.get(lang, "sent")
|
|
68
69
|
});
|
|
69
70
|
Plausible.sendGoal("Contact-us (other requests)");
|
|
70
|
-
setData(getInitialFormState(fields));
|
|
71
|
+
setData(getInitialFormState(fields, undefined, true));
|
|
71
72
|
resetForm();
|
|
72
73
|
}
|
|
73
74
|
setSending(false);
|
|
@@ -79,7 +80,7 @@ const CustomContactForm = ({
|
|
|
79
80
|
};
|
|
80
81
|
const resetForm = () => {
|
|
81
82
|
presets?.setter?.(undefined);
|
|
82
|
-
setData(getInitialFormState(fields));
|
|
83
|
+
setData(getInitialFormState(fields, undefined, true));
|
|
83
84
|
};
|
|
84
85
|
const blurForm = () => {
|
|
85
86
|
document.activeElement.blur();
|
|
@@ -100,7 +101,7 @@ const CustomContactForm = ({
|
|
|
100
101
|
}
|
|
101
102
|
}, [customSend, ready, settings, site]);
|
|
102
103
|
React.useEffect(() => {
|
|
103
|
-
setData(getInitialFormState(fields, presets?.values));
|
|
104
|
+
setData(getInitialFormState(fields, presets?.values, true));
|
|
104
105
|
}, [fields, presets?.values]);
|
|
105
106
|
const classes = classNames(styles.root, className);
|
|
106
107
|
const innerClasses = classNames(styles.inner, {
|
|
@@ -131,7 +132,7 @@ const CustomContactForm = ({
|
|
|
131
132
|
settings: settings,
|
|
132
133
|
presets: presets?.values
|
|
133
134
|
}, key))
|
|
134
|
-
}
|
|
135
|
+
}), _jsxs("div", {
|
|
135
136
|
className: styles.bottom,
|
|
136
137
|
children: [presets?.allowReset && _jsx(Button, {
|
|
137
138
|
className: styles.resetButton,
|
|
@@ -154,6 +155,6 @@ const CustomContactForm = ({
|
|
|
154
155
|
children: Messages.get(lang, "sending")
|
|
155
156
|
})]
|
|
156
157
|
})]
|
|
157
|
-
});
|
|
158
|
+
}, formKey);
|
|
158
159
|
};
|
|
159
160
|
export default React.memo(CustomContactFormWithSnackbar);
|
|
@@ -17,7 +17,7 @@ export const FIELD_TESTS_ERROR_CODES = {
|
|
|
17
17
|
"multiple-select": "TESTS_MULTIPLE_SELECT_ERROR"
|
|
18
18
|
};
|
|
19
19
|
const IGNORED_FIELDS = ["title", "subject", "attachment", "checkbox"];
|
|
20
|
-
export const getInitialFormState = (fields, presets) => Object.keys(fields).reduce((acc, key) => {
|
|
20
|
+
export const getInitialFormState = (fields, presets, skipSubject) => Object.keys(fields).reduce((acc, key) => {
|
|
21
21
|
const field = fields[key];
|
|
22
22
|
const {
|
|
23
23
|
required,
|
|
@@ -25,6 +25,9 @@ export const getInitialFormState = (fields, presets) => Object.keys(fields).redu
|
|
|
25
25
|
} = field;
|
|
26
26
|
if (type === "title") return acc;
|
|
27
27
|
if (key === "subject") {
|
|
28
|
+
if (skipSubject) {
|
|
29
|
+
return acc;
|
|
30
|
+
}
|
|
28
31
|
const value = presets?.[key] ?? "";
|
|
29
32
|
return {
|
|
30
33
|
...acc,
|
|
@@ -92,7 +95,8 @@ export const send = async ({
|
|
|
92
95
|
data,
|
|
93
96
|
fields,
|
|
94
97
|
subjectPrefix,
|
|
95
|
-
subjectSuffix
|
|
98
|
+
subjectSuffix,
|
|
99
|
+
kind
|
|
96
100
|
}) => {
|
|
97
101
|
const endpoint = `https://contacts.valraiso.net/api/contact/${site}`;
|
|
98
102
|
const dataKeys = Object.keys(data);
|
|
@@ -116,6 +120,9 @@ export const send = async ({
|
|
|
116
120
|
if (subjectSuffix) {
|
|
117
121
|
formData.append("subjectSuffix", subjectSuffix);
|
|
118
122
|
}
|
|
123
|
+
if (kind) {
|
|
124
|
+
formData.append("kind", kind);
|
|
125
|
+
}
|
|
119
126
|
const response = await fetch(endpoint, {
|
|
120
127
|
method: "POST",
|
|
121
128
|
body: formData
|