UNPKG

@sheerid/jslib-nightly

Version:

SheerID JavaScript Library

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