UNPKG

@sheerid/jslib-nightly

Version:

SheerID JavaScript Library

148 lines (146 loc) 5.41 kB
/** * VERSION: 2.130.0-alpha.4 * BUILD_TIMESTAMP: 1759000305348 * BUILD_DATE: Sat Sep 27 2025 19:11:45 GMT+0000 (Coordinated Universal Time) * BUILD_COMMIT: be6ef87ab40e8747994d32363389cf39e36a4326 */ import { i as S, R as l, d as c, j as e, A as R, b as t, O as E, n as V, l as w, V as y, s as k } from "../sheerid.js"; const I = ({ intl: i, verificationService: s }) => { const o = s.viewModel, d = s.verificationResponse, M = !!s.fieldValidationErrors.smsCode, n = s.previousViewModel || void 0, [u, m] = l.useState(""), [p, g] = l.useState( d.errorIds && d.errorIds.includes("incorrectSMSCodeAttemptLimitExceeded") ), h = i.formatHTMLMessage({ id: "step.smsLoop.successResend", defaultMessage: "SMS message re-sent successfully" }), f = i.formatHTMLMessage({ id: "step.smsLoop.errors.codeResendLimit", defaultMessage: "Maximum number of re-tries has been reached." }), x = i.formatHTMLMessage({ id: "step.smsLoop.errors.codeResendLimit", defaultMessage: "Maximum number of re-tries has been reached." }), L = i.formatHTMLMessage({ id: "step.smsLoop.errors.resend", defaultMessage: "Error sending the SMS message" }); l.useEffect(() => { p && m(x); }, []), c(() => d.errorIds.length) && !s.fieldValidationErrors.smsCode && s.updateFieldValidationErrors({ ...s.fieldValidationErrors, smsCode: d.errorIds[0] }); const j = (r) => { const a = V(o, (b) => { b.smsCode = r, b.phoneNumber = n && n.phoneNumber; }); s.updateViewModel(a); }, C = () => { w.info("StepSMSLoop submitting form"), s.submitStep( y.smsLoop, o, s.verificationResponse ); }, N = async (r) => { const a = await k.getResendNewSmsCode(r); a ? (g(!1), m(a.status === 204 ? h : f)) : m(L); }; return /* @__PURE__ */ e.jsxs("div", { id: "sid-step-sms-loop", className: "sid-sms-loop-container sid-l-container", children: [ /* @__PURE__ */ e.jsx(R, { align: "center", children: /* @__PURE__ */ e.jsx( t, { id: "step.smsLoop.verificationCode", defaultMessage: "Verification Code", tagName: "h1" } ) }), /* @__PURE__ */ e.jsx("div", { className: "sid-header__subtitle", children: c(() => n.phoneNumber) ? /* @__PURE__ */ e.jsx( t, { id: "step.smsLoop.titleWithNumber", defaultMessage: "We've sent an SMS message to the mobile number ending in {number}. Enter your code here.", values: { number: c(() => n.phoneNumber.slice(-4), "") } } ) : /* @__PURE__ */ e.jsx( t, { 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( E, { onChange: j, value: o.smsCode, isErrored: M, errorId: s.fieldValidationErrors.smsCode } ) }), u && /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx("p", { children: u }) }), /* @__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: C, type: "button", className: "sid-btn sid-sms-loop-submit-btn sid-btn--dark sid-submit__continue", "aria-label": "submit", disabled: !!(!o.smsCode || o.smsCode.length <= 0 || p), children: /* @__PURE__ */ e.jsx(t, { 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(t, { id: "step.smsLoop.resendButton", defaultMessage: "Re-send" }) } ) ] }), /* @__PURE__ */ e.jsxs("div", { className: "sid-incorrect-number sid-l-horz-center", children: [ /* @__PURE__ */ e.jsx( t, { 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( t, { id: "step.smsLoop.incorrectNumber.incorrectNumber2", defaultMessage: "here" } ), " " ] } ), /* @__PURE__ */ e.jsx(t, { id: "companyName", defaultMessage: "{Company}", children: (r) => /* @__PURE__ */ e.jsx( t, { id: "step.smsLoop.incorrectNumber.incorrectNumber3", defaultMessage: "to return to {companyName}", values: { companyName: r } } ) }) ] }) ] }); }, A = S(I); export { A as default };