pixelize-design-library 2.2.81 → 2.2.82
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.
|
@@ -96,6 +96,7 @@ var ContactForm = function (_a) {
|
|
|
96
96
|
isSuccess: false,
|
|
97
97
|
}), response = _f[0], setResponse = _f[1];
|
|
98
98
|
var _g = (0, react_1.useState)({}), errors = _g[0], setErrors = _g[1];
|
|
99
|
+
var _h = (0, react_1.useState)(false), isLoading = _h[0], setIsLoading = _h[1];
|
|
99
100
|
var handleChange = function (field, value) {
|
|
100
101
|
setFormData(function (prev) {
|
|
101
102
|
var _a;
|
|
@@ -147,7 +148,8 @@ var ContactForm = function (_a) {
|
|
|
147
148
|
payload = __assign(__assign({ name: (formData === null || formData === void 0 ? void 0 : formData.firstName) + " " + (formData === null || formData === void 0 ? void 0 : formData.lastName), firstName: formData === null || formData === void 0 ? void 0 : formData.firstName, lastName: formData === null || formData === void 0 ? void 0 : formData.lastName, email: formData.email, phone: formData.phone, message: formData.enquiry }, customValues), { customerId: customerId, organizationId: organizationId });
|
|
148
149
|
_b.label = 1;
|
|
149
150
|
case 1:
|
|
150
|
-
_b.trys.push([1, 4, ,
|
|
151
|
+
_b.trys.push([1, 4, 5, 6]);
|
|
152
|
+
setIsLoading(true);
|
|
151
153
|
return [4 /*yield*/, fetch(apiKey, {
|
|
152
154
|
method: "POST",
|
|
153
155
|
headers: {
|
|
@@ -174,15 +176,18 @@ var ContactForm = function (_a) {
|
|
|
174
176
|
title: "Message Sent Successfully",
|
|
175
177
|
isSuccess: true,
|
|
176
178
|
});
|
|
177
|
-
return [3 /*break*/,
|
|
179
|
+
return [3 /*break*/, 6];
|
|
178
180
|
case 4:
|
|
179
181
|
error_1 = _b.sent();
|
|
180
182
|
setResponse({
|
|
181
183
|
title: "Failed to send message",
|
|
182
184
|
isSuccess: false,
|
|
183
185
|
});
|
|
184
|
-
return [3 /*break*/,
|
|
185
|
-
case 5:
|
|
186
|
+
return [3 /*break*/, 6];
|
|
187
|
+
case 5:
|
|
188
|
+
setIsLoading(false);
|
|
189
|
+
return [7 /*endfinally*/];
|
|
190
|
+
case 6: return [2 /*return*/];
|
|
186
191
|
}
|
|
187
192
|
});
|
|
188
193
|
}); };
|
|
@@ -211,6 +216,6 @@ var ContactForm = function (_a) {
|
|
|
211
216
|
react_1.default.createElement(react_2.Text, { fontSize: "sm", mb: 1 }, "Enquiry"),
|
|
212
217
|
react_1.default.createElement(react_2.Box, null,
|
|
213
218
|
react_1.default.createElement(InputTextArea_1.default, { placeholder: "Enter your enquiry", rows: 4, width: "100%", value: formData.enquiry, onChange: function (e) { return handleChange("enquiry", e.target.value); } }))),
|
|
214
|
-
react_1.default.createElement(Button_1.default, { type: "submit", isDisabled: isDisabled, colorScheme: buttonColorScheme, width: "full", sx: buttonSx }, "Send Message")))));
|
|
219
|
+
react_1.default.createElement(Button_1.default, { type: "submit", isDisabled: isDisabled, colorScheme: buttonColorScheme, width: "full", sx: buttonSx, isLoading: isLoading, loadingText: "Sending..." }, "Send Message")))));
|
|
215
220
|
};
|
|
216
221
|
exports.default = ContactForm;
|