@sheerid/jslib-nightly
Version:
SheerID JavaScript Library
198 lines (196 loc) • 6.97 kB
JavaScript
/**
* WARNING: This file is intended to be used within MySheerID.
* This file is not intended for use in other contexts and there are no guarantees about its behavior outside of MySheerID.
*/
/**
* VERSION: 2.230.0-alpha.0
* BUILD_TIMESTAMP: 1778694697559
* BUILD_DATE: Wed May 13 2026 17:51:37 GMT+0000 (Coordinated Universal Time)
* BUILD_COMMIT: 7af1c105d5485ac4ed1190c56d492bb4590667a9
*/
import { i as g, j as e, F as o, R as u, h as p, I as E, p as R, l as V, V as w, T as I } from "../_mysheerid-preview.js";
import { I as k } from "./InputText-PEiatRRJ.js";
const y = ({
onChange: i,
value: s,
isErrored: t,
errorId: d,
intl: c,
placeholder: n = ""
}) => {
const m = (r) => {
switch (r) {
case "invalidSMSCode":
return /* @__PURE__ */ e.jsx(
o,
{
id: "step.smsLoop.errors.codeVerification",
defaultMessage: "Verification code could not be validated."
}
);
case "expiredSMSCode":
return /* @__PURE__ */ e.jsx(
o,
{
id: "step.smsLoop.errors.codeExpired",
defaultMessage: "Verification code expired."
}
);
default:
return /* @__PURE__ */ e.jsx(o, { id: "errorId.unknownError", defaultMessage: "Unknown Error" });
}
};
return /* @__PURE__ */ e.jsxs("div", { className: "sid-field sid-sms-code-id", children: [
/* @__PURE__ */ e.jsx("div", { className: "sid-l-space-top-md" }),
t ? /* @__PURE__ */ e.jsx("div", { className: "sid-field-error", children: m(d) }) : null,
/* @__PURE__ */ e.jsx(
k,
{
id: "sms-code",
isErrored: t,
required: !0,
placeholder: n || c.formatHTMLMessage({ id: "smsCodePlaceholder", defaultMessage: "SMS Code" }),
value: s,
onChange: (r) => i(r.target.value)
}
)
] });
}, T = g(y), v = ({ intl: i, verificationService: s }) => {
const t = s.viewModel, d = s.verificationResponse, c = !!s.fieldValidationErrors.smsCode, n = s.previousViewModel || void 0, [m, r] = u.useState(""), [M, f] = u.useState(
d.errorIds && d.errorIds.includes("incorrectSMSCodeAttemptLimitExceeded")
), h = i.formatHTMLMessage({
id: "step.smsLoop.successResend",
defaultMessage: "SMS message re-sent successfully"
}), x = i.formatHTMLMessage({
id: "step.smsLoop.errors.codeResendLimit",
defaultMessage: "Maximum number of re-tries has been reached."
}), S = i.formatHTMLMessage({
id: "step.smsLoop.errors.codeResendLimit",
defaultMessage: "Maximum number of re-tries has been reached."
}), j = i.formatHTMLMessage({
id: "step.smsLoop.errors.resend",
defaultMessage: "Error sending the SMS message"
});
u.useEffect(() => {
M && r(S);
}, []), p(() => d.errorIds.length) && !s.fieldValidationErrors.smsCode && s.updateFieldValidationErrors({
...s.fieldValidationErrors,
smsCode: d.errorIds[0]
});
const C = (a) => {
const l = R(t, (b) => {
b.smsCode = a, b.phoneNumber = n && n.phoneNumber;
});
s.updateViewModel(l);
}, L = () => {
V.info("StepSMSLoop submitting form"), s.submitStep(
w.smsLoop,
t,
s.verificationResponse
);
}, N = async (a) => {
const l = await I.getResendNewSmsCode(a);
l ? (f(!1), r(l.status === 204 ? h : x)) : r(j);
};
return /* @__PURE__ */ e.jsxs("div", { id: "sid-step-sms-loop", className: "sid-sms-loop-container sid-l-container", children: [
/* @__PURE__ */ e.jsx(E, { align: "center", children: /* @__PURE__ */ e.jsx(
o,
{
id: "step.smsLoop.verificationCode",
defaultMessage: "Verification Code",
tagName: "h1"
}
) }),
/* @__PURE__ */ e.jsx("div", { className: "sid-header__subtitle", children: p(() => n.phoneNumber) ? /* @__PURE__ */ e.jsx(
o,
{
id: "step.smsLoop.titleWithNumber",
defaultMessage: "We've sent an SMS message to the mobile number ending in {number}. Enter your code here.",
values: {
number: p(() => n.phoneNumber.slice(-4), "")
}
}
) : /* @__PURE__ */ e.jsx(
o,
{
id: "step.smsLoop.titleWithoutNumber",
defaultMessage: "We've sent an SMS to your mobile number. Please enter the code here."
}
) }),
/* @__PURE__ */ e.jsx("div", { className: "sid-sms-code-id-wrapper sid-l-horz-center", children: /* @__PURE__ */ e.jsx(
T,
{
onChange: C,
value: t.smsCode,
isErrored: c,
errorId: s.fieldValidationErrors.smsCode
}
) }),
m && /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx("p", { children: m }) }),
/* @__PURE__ */ e.jsxs("div", { className: "sid-submit sid-sms-loop-submit sid-l-space-top-md sid-l-horz-center", children: [
/* @__PURE__ */ e.jsx(
"button",
{
id: "sid-submit-sms-code",
onClick: L,
type: "button",
className: "sid-btn sid-sms-loop-submit-btn sid-btn--dark sid-submit__continue",
"aria-label": "submit",
disabled: !!(!t.smsCode || t.smsCode.length <= 0 || M),
children: /* @__PURE__ */ e.jsx(o, { id: "step.smsLoop.submitButton", defaultMessage: "Submit" })
}
),
/* @__PURE__ */ e.jsx("div", { className: "sid-l-space-left-sm", children: " " }),
/* @__PURE__ */ e.jsx(
"button",
{
id: "sid-resend-sms-code",
onClick: () => N(d.verificationId),
type: "submit",
className: "sid-btn sid-resend-sms-code-btn sid-btn--light sid-submit__cancel",
"aria-label": "re-send",
children: /* @__PURE__ */ e.jsx(o, { id: "step.smsLoop.resendButton", defaultMessage: "Re-send" })
}
)
] }),
/* @__PURE__ */ e.jsxs("div", { className: "sid-incorrect-number sid-l-horz-center", children: [
/* @__PURE__ */ e.jsx(
o,
{
id: "step.smsLoop.incorrectNumber.incorrectNumber1",
defaultMessage: "Incorrect number? Click"
}
),
" ",
/* @__PURE__ */ e.jsxs(
"button",
{
type: "button",
onClick: () => window.location.reload(),
className: "sid-incorrect-number__refresh-link sid-h-btn-link-like",
children: [
/* @__PURE__ */ e.jsx(
o,
{
id: "step.smsLoop.incorrectNumber.incorrectNumber2",
defaultMessage: "here"
}
),
" "
]
}
),
/* @__PURE__ */ e.jsx(o, { id: "companyName", defaultMessage: "{Company}", children: (a) => /* @__PURE__ */ e.jsx(
o,
{
id: "step.smsLoop.incorrectNumber.incorrectNumber3",
defaultMessage: "to return to {companyName}",
values: { companyName: a }
}
) })
] })
] });
}, A = g(v);
export {
A as default
};