UNPKG

@sheerid/jslib-nightly

Version:

SheerID JavaScript Library

301 lines (299 loc) • 10.1 kB
/** * VERSION: 2.130.0-alpha.4 * BUILD_TIMESTAMP: 1759000374473 * BUILD_DATE: Sat Sep 27 2025 19:12:54 GMT+0000 (Coordinated Universal Time) * BUILD_COMMIT: be6ef87ab40e8747994d32363389cf39e36a4326 */ import { au as B, f as o, j as e, a1 as Q, k as S, r as v, N as ee, m as ae, am as se, E as R, o as r, O as ne, x as te, a2 as oe, av as le, a4 as L, T as de, U as re, a5 as ie, n as me, Y as ue, Z as pe, _ as be, $ as ce, p as Ce, V as ge } from "./es6-N0LU_o1K.js"; import g from "react"; import { injectIntl as he, FormattedHTMLMessage as i } from "react-intl"; import { u as xe, E as Ne, a as w } from "./useEmailFirstExperiment-BlHwuf6g.js"; const Ee = ({ value: a, isErrored: n, onChange: l, intl: c, explanation: h, placeholder: p = "", isRequired: b = !1 }) => { var t; const m = B("include-cvec-field-france-student"), x = () => m === "labeled-optional" ? /* @__PURE__ */ e.jsx( i, { id: "cvecNumberExplanation", defaultMessage: "Optional - Add your CVEC number to increase your chances of being verified instantly." } ) : /* @__PURE__ */ e.jsx( i, { id: "_EXPERIMENTAL.cvecNumberExplanation", defaultMessage: "Add your CVEC number to increase your chances of being verified instantly." } ); return ((t = o("cvecNumber")) == null ? void 0 : t.hidden) ? null : /* @__PURE__ */ e.jsx( Q, { fieldId: "cvecNumber", value: a, onChange: l, placeholder: p || c.formatHTMLMessage({ id: "cvecNumberPlaceholder", defaultMessage: "CVEC certificate number" }), label: /* @__PURE__ */ e.jsx(i, { id: "cvecNumber", defaultMessage: "CVEC certificate number" }), errorMessage: n && /* @__PURE__ */ e.jsx( i, { id: "errorId.invalidCvecNumber", defaultMessage: "Invalid CVEC certificate number" } ), showPlaceholderAndHideLabel: !!p, required: b, explanation: h || x() } ); }, fe = he(Ee), je = ({ verificationService: a }) => { var f, j, F, M, y, I, O, V, D, T, k, P; const n = a.viewModel, { fieldValidationErrors: l } = a, c = a.verificationResponse, h = ne(), p = B("include-cvec-field-france-student"), b = p !== "control" && p !== "default" && ((f = n == null ? void 0 : n.countryChoice) == null ? void 0 : f.value) === "FR"; g.useEffect(() => { b ? d("fieldsToSkipValidation", []) : d("fieldsToSkipValidation", ["cvecNumber"]); }, [b]); const { isEmailUpTop: m, isEmailValidationLoading: x, showFormFields: N, emailLookupResponse: t, emailOnBlur: z, emailOnKeyDown: H, handleResendClick: q, showEmailLookupResponseMessages: _, enableFormFields: A, isValidEmail: C, getOrgByDomain: K, handleOnClickProceedHere: U } = xe( a.programId, n.email, a.verificationResponse.segment ), [W, E] = g.useState(null), [X, Y] = g.useState(null); g.useEffect(() => { C && t && (async () => { if (n.email && C && t && t.status === w.NOT_FOUND) { const u = await K(a); u && (E(u), L(u, a), r("organization", u, a)); } else E(null); })(); }, [n.email, C, t == null ? void 0 : t.status]); const Z = S(c), d = (s, u) => { const G = v( n, (J) => { J[s] = u; } ); a.updateViewModel(G); }, $ = n.localeChoice.value; return /* @__PURE__ */ e.jsxs( ee, { verificationService: a, step: c.currentStep, children: [ /* @__PURE__ */ e.jsx( ae, { verificationService: a, classNameIdentifier: "student-personal-info" } ), // #region email-first-experiment m && /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs("div", { className: "email-input-wrapper", children: [ x && /* @__PURE__ */ e.jsx("div", { className: "email-input-wrapper-frame", children: /* @__PURE__ */ e.jsx("div", { className: "sid-spinner scaled", children: /* @__PURE__ */ e.jsx(se, {}) }) }), /* @__PURE__ */ e.jsx( R, { value: n.email, isErrored: !!l.email, explanation: /* @__PURE__ */ e.jsx( i, { id: "emailExplanation", defaultMessage: "Personal or school email is fine" } ), onChange: (s) => { d("email", s), r("email", s, a); }, onKeyDown: H, onBlur: z, disabled: (j = o("email")) == null ? void 0 : j.disabled } ) ] }) }), _ && t && C && /* @__PURE__ */ e.jsx( Ne, { emailLookupResponse: t, onResendClick: q, onHandleClickLink: U } ), N && /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs("div", { className: A || !m ? "" : "sid-disable-elements", children: [ " ", /* @__PURE__ */ e.jsx(te, { verificationService: a }), /* @__PURE__ */ e.jsx( oe, { verificationService: a, disabled: (F = o("country")) == null ? void 0 : F.disabled } ), /* @__PURE__ */ e.jsx( le, { value: X || m && (t == null ? void 0 : t.status) === w.NOT_FOUND && W || a.viewModel.organization, verificationService: a, isErrored: !!l.organization, isRequired: !0, disabled: (M = o("organization")) == null ? void 0 : M.disabled, onChange: (s) => { Y(s), L(s, a), r("organization", s, a); } } ), b && /* @__PURE__ */ e.jsx( fe, { isRequired: (y = o("cvecNumber")) == null ? void 0 : y.requireIfOptional, value: n.cvecNumber, isErrored: !!l.cvecNumber, disabled: (I = o("cvecNumber")) == null ? void 0 : I.disabled, onChange: (s) => { d("cvecNumber", s), r("cvecNumber", s, a); } } ), /* @__PURE__ */ e.jsxs("div", { className: "sid-names", children: [ /* @__PURE__ */ e.jsx( de, { value: n.firstName, isErrored: !!l.firstName, disabled: (O = o("firstName")) == null ? void 0 : O.disabled, onChange: (s) => { d("firstName", s), r("firstName", s, a); } } ), /* @__PURE__ */ e.jsx( re, { value: n.lastName, isErrored: !!l.lastName, disabled: (V = o("lastName")) == null ? void 0 : V.disabled, onChange: (s) => { d("lastName", s), r("lastName", s, a); } } ) ] }), /* @__PURE__ */ e.jsx( ie, { value: n.birthDate, errorId: l.birthDate, locale: $, isRequired: !0, disabled: (D = o("birthDate")) == null ? void 0 : D.disabled, onChange: (s) => { d("birthDate", s), r("birthDate", s, a); } } ), !m && /* @__PURE__ */ e.jsx( R, { value: n.email, isErrored: !!l.email, explanation: /* @__PURE__ */ e.jsx( i, { id: "emailExplanation", defaultMessage: "Personal or school email is fine" } ), onChange: (s) => { d("email", s), r("email", s, a); }, onKeyDown: (s) => me(s), disabled: (T = o("email")) == null ? void 0 : T.disabled } ), a.programTheme.isSmsNotifierConfigured || a.programTheme.smsLoopEnabled ? /* @__PURE__ */ e.jsx( ue, { isRequired: !!a.programTheme.smsLoopEnabled, value: n.phoneNumber, isErrored: !!l.phoneNumber, disabled: (k = o("phoneNumber")) == null ? void 0 : k.disabled, onChange: (s) => { d("phoneNumber", s), r( "phoneNumber", s, a ); }, selectedCountryCode: n.countryChoice && n.countryChoice.value } ) : null, (h.customFormFields || []).map((s) => /* @__PURE__ */ e.jsx(pe, { config: s, verificationService: a })), " ", /* @__PURE__ */ e.jsx( be, { verificationService: a, isErrored: !!l.marketConsentValue, disabled: (P = o("marketConsentValue")) == null ? void 0 : P.disabled, onChange: (s) => { d("metadata", { ...a.viewModel.metadata, marketConsentValue: s }), r( "marketConsentValue", s, a ); }, viewModel: n } ), /* @__PURE__ */ e.jsx(ce, { suffix: "CollectAboveSubmit" }), /* @__PURE__ */ e.jsx( Ce, { step: ge.collectStudentPersonalInfo, verificationService: a, viewModel: n, failedInstantMatch: Z, buttonText: /* @__PURE__ */ e.jsx( i, { id: "step.personalInfo.submitButtonText", defaultMessage: "Verify My Student Status" } ) } ) ] }) }) ] } ); }, Oe = je; export { Oe as default };