@enyxs/wikex-components 0.11.14 → 0.11.15
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/README.md +15 -0
- package/dist/consultation-model.d.mts +37 -0
- package/dist/consultation-model.d.ts +37 -0
- package/dist/consultation-model.js +42 -0
- package/dist/consultation-model.js.map +1 -0
- package/dist/consultation-model.mjs +15 -0
- package/dist/consultation-model.mjs.map +1 -0
- package/dist/consultations.d.mts +27 -0
- package/dist/consultations.d.ts +27 -0
- package/dist/consultations.js +226 -0
- package/dist/consultations.js.map +1 -0
- package/dist/consultations.mjs +200 -0
- package/dist/consultations.mjs.map +1 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +67 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -1
package/dist/index.mjs
CHANGED
|
@@ -3888,6 +3888,7 @@ import styled4 from "styled-components";
|
|
|
3888
3888
|
// src/commodity-original/components/LandingPage/RegisterSection.tsx
|
|
3889
3889
|
import Image2 from "next/image.js";
|
|
3890
3890
|
import { useRef as useRef2, useState as useState4 } from "react";
|
|
3891
|
+
import Alert from "@mui/material/Alert";
|
|
3891
3892
|
import Select from "@mui/material/Select";
|
|
3892
3893
|
import MenuItem from "@mui/material/MenuItem";
|
|
3893
3894
|
import Checkbox from "@mui/material/Checkbox";
|
|
@@ -4058,6 +4059,7 @@ var registerMenuProps = (container) => ({
|
|
|
4058
4059
|
}
|
|
4059
4060
|
});
|
|
4060
4061
|
function RegisterSelect({
|
|
4062
|
+
disabled = false,
|
|
4061
4063
|
ariaLabel,
|
|
4062
4064
|
defaultValue = "",
|
|
4063
4065
|
name,
|
|
@@ -4069,6 +4071,7 @@ function RegisterSelect({
|
|
|
4069
4071
|
return /* @__PURE__ */ jsxs7(
|
|
4070
4072
|
Select,
|
|
4071
4073
|
{
|
|
4074
|
+
disabled,
|
|
4072
4075
|
ref: root,
|
|
4073
4076
|
name,
|
|
4074
4077
|
value: value4,
|
|
@@ -4090,6 +4093,7 @@ function RegisterSelect({
|
|
|
4090
4093
|
);
|
|
4091
4094
|
}
|
|
4092
4095
|
function RegisterCheckboxSelect({
|
|
4096
|
+
disabled = false,
|
|
4093
4097
|
labelledBy,
|
|
4094
4098
|
name,
|
|
4095
4099
|
options,
|
|
@@ -4107,6 +4111,7 @@ function RegisterCheckboxSelect({
|
|
|
4107
4111
|
/* @__PURE__ */ jsx10(
|
|
4108
4112
|
Select,
|
|
4109
4113
|
{
|
|
4114
|
+
disabled,
|
|
4110
4115
|
ref: root,
|
|
4111
4116
|
multiple: true,
|
|
4112
4117
|
fullWidth: true,
|
|
@@ -4146,10 +4151,58 @@ function RegisterCheckboxSelect({
|
|
|
4146
4151
|
] });
|
|
4147
4152
|
}
|
|
4148
4153
|
function RegisterSection({
|
|
4149
|
-
variant = "landing"
|
|
4154
|
+
variant = "landing",
|
|
4155
|
+
editable = false,
|
|
4156
|
+
onConsultationSubmit
|
|
4150
4157
|
}) {
|
|
4151
4158
|
const { isMobile } = useResponsive();
|
|
4152
|
-
const { t } = useTranslation();
|
|
4159
|
+
const { t, i18n } = useTranslation();
|
|
4160
|
+
const english = i18n.resolvedLanguage?.startsWith("en") ?? false;
|
|
4161
|
+
const [pending, setPending] = useState4(false);
|
|
4162
|
+
const [formVersion, setFormVersion] = useState4(0);
|
|
4163
|
+
const [notice, setNotice] = useState4(null);
|
|
4164
|
+
const submitting = useRef2(false);
|
|
4165
|
+
const submissionId = useRef2("");
|
|
4166
|
+
const submitConsultation = async (event) => {
|
|
4167
|
+
event.preventDefault();
|
|
4168
|
+
if (submitting.current) return;
|
|
4169
|
+
if (editable || !onConsultationSubmit) {
|
|
4170
|
+
setNotice({ severity: "error", message: english ? "This form is only available on the public website." : "Vui l\xF2ng g\u1EEDi form tr\xEAn trang website c\xF4ng khai." });
|
|
4171
|
+
return;
|
|
4172
|
+
}
|
|
4173
|
+
const form = event.currentTarget;
|
|
4174
|
+
const values = new FormData(form);
|
|
4175
|
+
if (!submissionId.current) submissionId.current = crypto.randomUUID();
|
|
4176
|
+
const text = (key) => String(values.get(key) ?? "").trim();
|
|
4177
|
+
const data = {
|
|
4178
|
+
submissionId: submissionId.current,
|
|
4179
|
+
name: text("name"),
|
|
4180
|
+
phone: text("phone"),
|
|
4181
|
+
email: text("email"),
|
|
4182
|
+
city: text("city"),
|
|
4183
|
+
markets: values.getAll("market").map(String),
|
|
4184
|
+
otherMarket: text("market-other"),
|
|
4185
|
+
capital: text("capital"),
|
|
4186
|
+
language: english ? "en" : "vi",
|
|
4187
|
+
sourcePath: window.location.pathname,
|
|
4188
|
+
website: text("website")
|
|
4189
|
+
};
|
|
4190
|
+
submitting.current = true;
|
|
4191
|
+
setPending(true);
|
|
4192
|
+
setNotice(null);
|
|
4193
|
+
try {
|
|
4194
|
+
await onConsultationSubmit(data);
|
|
4195
|
+
form.reset();
|
|
4196
|
+
setFormVersion((current) => current + 1);
|
|
4197
|
+
submissionId.current = "";
|
|
4198
|
+
setNotice({ severity: "success", message: english ? "Your consultation request has been sent. We will contact you soon." : "\u0110\xE3 g\u1EEDi \u0111\u0103ng k\xFD t\u01B0 v\u1EA5n th\xE0nh c\xF4ng. Ch\xFAng t\xF4i s\u1EBD li\xEAn h\u1EC7 v\u1EDBi b\u1EA1n s\u1EDBm." });
|
|
4199
|
+
} catch (error) {
|
|
4200
|
+
setNotice({ severity: "error", message: error instanceof Error ? error.message : english ? "Unable to submit. Please try again." : "Kh\xF4ng th\u1EC3 g\u1EEDi \u0111\u0103ng k\xFD. Vui l\xF2ng th\u1EED l\u1EA1i." });
|
|
4201
|
+
} finally {
|
|
4202
|
+
submitting.current = false;
|
|
4203
|
+
setPending(false);
|
|
4204
|
+
}
|
|
4205
|
+
};
|
|
4153
4206
|
const aboutVisual = useCmsImage(
|
|
4154
4207
|
"registerAboutVisualImage",
|
|
4155
4208
|
"/about-us/register_visual.webp"
|
|
@@ -4329,7 +4382,9 @@ function RegisterSection({
|
|
|
4329
4382
|
"form",
|
|
4330
4383
|
{
|
|
4331
4384
|
className: "register-form-frame",
|
|
4332
|
-
onSubmit:
|
|
4385
|
+
onSubmit: submitConsultation,
|
|
4386
|
+
"aria-busy": pending,
|
|
4387
|
+
"data-consultation-form": true,
|
|
4333
4388
|
children: [
|
|
4334
4389
|
!isMobile && /* @__PURE__ */ jsx10(
|
|
4335
4390
|
Button_default,
|
|
@@ -4359,7 +4414,8 @@ function RegisterSection({
|
|
|
4359
4414
|
/* @__PURE__ */ jsx10("h2", { children: t("landing.register.title") }),
|
|
4360
4415
|
/* @__PURE__ */ jsx10("p", { children: t("landing.register.confidential") })
|
|
4361
4416
|
] }),
|
|
4362
|
-
/* @__PURE__ */ jsxs7("
|
|
4417
|
+
/* @__PURE__ */ jsxs7("fieldset", { className: "register-fields", disabled: pending, style: { border: 0, padding: 0, margin: 0, minWidth: 0 }, children: [
|
|
4418
|
+
/* @__PURE__ */ jsx10("div", { "aria-hidden": "true", style: { display: "none" }, children: /* @__PURE__ */ jsx10("input", { name: "website", tabIndex: -1, autoComplete: "off" }) }),
|
|
4363
4419
|
/* @__PURE__ */ jsxs7("div", { className: "field-row", children: [
|
|
4364
4420
|
/* @__PURE__ */ jsxs7("label", { children: [
|
|
4365
4421
|
t("landing.register.fields.name"),
|
|
@@ -4407,6 +4463,7 @@ function RegisterSection({
|
|
|
4407
4463
|
/* @__PURE__ */ jsx10(
|
|
4408
4464
|
RegisterSelect,
|
|
4409
4465
|
{
|
|
4466
|
+
disabled: pending,
|
|
4410
4467
|
name: "city",
|
|
4411
4468
|
ariaLabel: t("landing.register.fields.city"),
|
|
4412
4469
|
placeholder: t("landing.register.cityPlaceholder"),
|
|
@@ -4427,6 +4484,7 @@ function RegisterSection({
|
|
|
4427
4484
|
/* @__PURE__ */ jsx10(
|
|
4428
4485
|
RegisterCheckboxSelect,
|
|
4429
4486
|
{
|
|
4487
|
+
disabled: pending,
|
|
4430
4488
|
legend: t("landing.register.marketLegend"),
|
|
4431
4489
|
name: "market",
|
|
4432
4490
|
labelledBy: "register-market-label",
|
|
@@ -4442,6 +4500,7 @@ function RegisterSection({
|
|
|
4442
4500
|
/* @__PURE__ */ jsx10(
|
|
4443
4501
|
RegisterSelect,
|
|
4444
4502
|
{
|
|
4503
|
+
disabled: pending,
|
|
4445
4504
|
name: "capital",
|
|
4446
4505
|
ariaLabel: t("landing.register.fields.capital"),
|
|
4447
4506
|
placeholder: t("landing.register.capitalPlaceholder"),
|
|
@@ -4449,12 +4508,14 @@ function RegisterSection({
|
|
|
4449
4508
|
}
|
|
4450
4509
|
)
|
|
4451
4510
|
] })
|
|
4452
|
-
] }),
|
|
4511
|
+
] }, formVersion),
|
|
4512
|
+
notice && /* @__PURE__ */ jsx10(Alert, { severity: notice.severity, role: notice.severity === "success" ? "status" : "alert", sx: { mt: 2, mb: 2, textAlign: "left" }, children: notice.message }),
|
|
4453
4513
|
/* @__PURE__ */ jsx10(
|
|
4454
4514
|
Button_default,
|
|
4455
4515
|
{
|
|
4456
4516
|
className: "register-submit",
|
|
4457
4517
|
type: "submit",
|
|
4518
|
+
disabled: pending,
|
|
4458
4519
|
size: "md",
|
|
4459
4520
|
radius: 8,
|
|
4460
4521
|
tint: "#F9BB3A",
|
|
@@ -4467,7 +4528,7 @@ function RegisterSection({
|
|
|
4467
4528
|
speed: 1.5,
|
|
4468
4529
|
followMouse: false,
|
|
4469
4530
|
autoAnimate: true,
|
|
4470
|
-
children: t("landing.register.submit")
|
|
4531
|
+
children: pending ? english ? "Sending\u2026" : "\u0110ang g\u1EEDi\u2026" : t("landing.register.submit")
|
|
4471
4532
|
}
|
|
4472
4533
|
)
|
|
4473
4534
|
] })
|