UNPKG

@sheerid/jslib-nightly

Version:

SheerID JavaScript Library

486 lines (484 loc) • 16.1 kB
/** * VERSION: 2.230.0-alpha.0 * BUILD_TIMESTAMP: 1778694684677 * BUILD_DATE: Wed May 13 2026 17:51:24 GMT+0000 (Coordinated Universal Time) * BUILD_COMMIT: 7af1c105d5485ac4ed1190c56d492bb4590667a9 */ import { i as w, R as h, m as B, an as m, ao as k, M as f, V as R, j as s, P as _, g as d, o as r, ap as W, a2 as Y, n as V, F as M, k as H, Y as U, U as K, a as $, aq as G, h as D, l as J, p as Q, D as X, _ as b, e as Z, ar as c } from "../sheerid.js"; import { F as S, L as v, P as aa, a as ea, M as sa, C as ta } from "./CaptchaComponent-SmUa6m52.js"; import { C as oa } from "./CollegeNameComponent-DtKPZHb-.js"; import { E as da, P as ra } from "./PersonalInfoStepSubmitButton-j44RdZDq.js"; import { B as na } from "./militaryStepHelpers-0OUuQpBw.js"; import { C as la } from "./CountryComponentWrapper-Ceq-eink.js"; import { C as ma } from "./City-yVVnZQTP.js"; import { S as ua } from "./StateSelectComponent-CChSqKXz.js"; import { P as ia } from "./PostalCodeComponent-DrCcV90W.js"; import { A as ba } from "./AddressComponent-AiyIPiCz.js"; import { D as pa, A as ga, B as Ca } from "./ActiveDutyStartDateComponent-CF9c-0bL.js"; import { D as ha } from "./DriverLicenseNumberComponent-ziLNYB8e.js"; import { E as Ea, L as Na } from "./EBTCardNumberComponent-B1kv4R4G.js"; import { S as Ia } from "./StatusComponent-C6J1B7Tl.js"; import { F as xa } from "./FirstResponderOrganizationComponent-Bru1a0U7.js"; import { L as Ma } from "./LicensedProfessionalOrganizationComponent-CnR_qF3r.js"; import { M as Da } from "./MedicalProfessionalOrganizationComponent-DBf6V49M.js"; import { M as ja } from "./MemberIdComponent-C8mVSo9m.js"; import { M as za } from "./MembershipOrganizationComponent-CN6_d_Fk.js"; import { T as Ra } from "./TeacherSchoolComponent-BSHPjiwQ.js"; import { S as ya } from "./SSN-B_z2R4Bx.js"; const Fa = ({ intl: E, verificationService: e }) => { const t = e.viewModel, { updateViewModel: j, programTheme: y } = e, [p, F] = h.useState(void 0), l = (a) => p && p.some((i) => i.key === a), { fieldValidationErrors: o } = e, C = e.verificationResponse, L = B(C), n = (a, i) => { const g = Q( t, (A) => { A[a] = i; } ); j(g); }, O = (a) => { const i = c( t, a ); j(i); }, N = t.localeChoice.value, T = Z(), { segment: u, availableStatuses: I } = C, P = u.charAt(0).toUpperCase() + u.slice(1), z = () => I && (u === m.FIRST_RESPONDER || u === m.MEDICAL || u === m.LOW_INCOME || u === m.LICENSED_PROFESSIONAL || u === m.EMPLOYMENT || u === m.RECENT_MOVER || u === m.MILITARY), x = (a) => (async () => { try { const i = await G( C.verificationId, C.currentStep, a ), g = D(() => i.fieldsToCollect.required, []); z() && g.push({ key: "status" }), O(g), F(g); } catch (i) { J.error(`Failed to determine fields to collect: ${i}`); } })(), q = () => { switch (u) { case m.STUDENT: return /* @__PURE__ */ s.jsx( oa, { value: e.viewModel.organization, verificationService: e, isErrored: !!o.organization, isRequired: !0, disabled: d("organization")?.disabled, onChange: (a) => { b(a, e), r("organization", a, e); } } ); case m.TEACHER: return /* @__PURE__ */ s.jsx( Ra, { value: e.viewModel.organization, verificationService: e, isErrored: !!o.organization, disabled: d("organization")?.disabled, onChange: (a) => { b(a, e), r("organization", a, e); } } ); case m.MEMBER: return /* @__PURE__ */ s.jsx( za, { value: e.viewModel.organization, verificationService: e, isErrored: !!o.organization, disabled: d("organization")?.disabled, onChange: (a) => { b(a, e), r("organization", a, e); } } ); case m.MILITARY: return /* @__PURE__ */ s.jsx( Ca, { isErrored: !!o.organization, onChange: (a) => { b(a, e), r("organization", a, e); }, value: { value: D( () => e.viewModel.organization.id ), label: D( () => e.viewModel.organization.name ) }, verificationService: e, disabled: d("organization")?.disabled } ); case m.FIRST_RESPONDER: return /* @__PURE__ */ s.jsx( xa, { isErrored: !!o.organization, onChange: (a) => { b(a, e), r("organization", a, e); }, value: e.viewModel.organization, verificationService: e, disabled: d("organization")?.disabled } ); case m.MEDICAL: return /* @__PURE__ */ s.jsx( Da, { isErrored: !!o.organization, onChange: (a) => { b(a, e), r("organization", a, e); }, value: e.viewModel.organization, verificationService: e, disabled: d("organization")?.disabled } ); case m.LICENSED_PROFESSIONAL: return /* @__PURE__ */ s.jsx( Ma, { isErrored: !!o.organization, onChange: (a) => { b(a, e), r("organization", a, e); }, value: e.viewModel.organization, verificationService: e, disabled: d("organization")?.disabled } ); case m.LOW_INCOME: return /* @__PURE__ */ s.jsx( Na, { isErrored: !!o.organization, onChange: (a) => { b(a, e), r("organization", a, e); }, value: X( e.viewModel.organization ), verificationService: e, isRequired: !0, disabled: d("organization")?.disabled } ); default: return null; } }; return h.useEffect(() => { I && u === m.MILITARY ? x({ statuses: [] }) : x({}); }, []), h.useEffect(() => { !k(y).enabled && p && p.length === 0 && f(t, e, R.collectPersonalInfo); }, [p]), h.useEffect(() => { t.status && x({ statuses: [t.status] }); }, [t.status]), /* @__PURE__ */ s.jsxs( "div", { id: "sid-step-personal-info-personal-info", className: "sid-personal-info-container sid-l-container", children: [ /* @__PURE__ */ s.jsxs("div", { role: "main", children: [ /* @__PURE__ */ s.jsx( _, { verificationService: e, classNameIdentifier: "personal-info" } ), /* @__PURE__ */ s.jsx( la, { verificationService: e, disabled: d("country")?.disabled } ), z() && /* @__PURE__ */ s.jsx( Ia, { segmentId: u, value: { value: t.status, label: Y(E, t.status, null) }, isErrored: !!o.status, errorId: `invalid${P}Status`, options: W(E, I), disabled: d("status")?.disabled, onChange: (a) => { n("status", a ? a.value : ""), r( "status", a ? a.value : "", e ); } } ), l("organization") && q(), /* @__PURE__ */ s.jsxs("div", { className: "sid-names", children: [ l("firstName") && /* @__PURE__ */ s.jsx( S, { value: t.firstName, isErrored: !!o.firstName, disabled: d("firstName")?.disabled, onChange: (a) => { n("firstName", a), r("firstName", a, e); } } ), l("lastName") && /* @__PURE__ */ s.jsx( v, { value: t.lastName, isErrored: !!o.lastName, disabled: d("lastName")?.disabled, onChange: (a) => { n("lastName", a), r("lastName", a, e); } } ) ] }), l("birthDate") && /* @__PURE__ */ s.jsx( na, { value: t.birthDate, errorId: o.birthDate, locale: N, isRequired: !0, disabled: d("birthDate")?.disabled, onChange: (a) => { n("birthDate", a), r("birthDate", a, e); } } ), l("email") && /* @__PURE__ */ s.jsx( da, { value: t.email, isErrored: !!o.email, explanation: " ", onChange: (a) => { n("email", a), r("email", a, e); }, onKeyDown: (a) => V(a), disabled: d("email")?.disabled } ), l("phoneNumber") && /* @__PURE__ */ s.jsx( aa, { isRequired: !!e.programTheme.smsLoopEnabled, value: t.phoneNumber, isErrored: !!o.phoneNumber, onChange: (a) => { n("phoneNumber", a), r("phoneNumber", a, e); }, selectedCountryCode: t.countryChoice && t.countryChoice.value, disabled: d("phoneNumber")?.disabled } ), l("address1") && /* @__PURE__ */ s.jsx( ba, { value: t.address1, isRequired: !0, isErrored: !!o.address1, errorId: o.address1, disabled: d("address1")?.disabled, onChange: (a) => { n("address1", a), r("address1", a, e); } } ), l("city") && /* @__PURE__ */ s.jsx( ma, { value: t.city, isRequired: !0, isErrored: !!o.city, errorId: o.city, disabled: d("city")?.disabled, onChange: (a) => { n("city", a), r("city", a, e); } } ), l("dischargeDate") && /* @__PURE__ */ s.jsx( pa, { errorId: o.dischargeDate, locale: N, onChange: (a) => { n("dischargeDate", a), r("dischargeDate", a, e); }, value: t.dischargeDate, disabled: d("dischargeDate")?.disabled } ), l("driverLicenseNumber") && /* @__PURE__ */ s.jsx( ha, { value: t.driverLicenseNumber, isErrored: !!o.driverLicenseNumber, isRequired: !0, disabled: d("driverLicenseNumber")?.disabled, onChange: (a) => { n("driverLicenseNumber", a), r( "driverLicenseNumber", a, e ); } } ), l("ebtCardNumber") && /* @__PURE__ */ s.jsx( Ea, { value: t.ebtCardNumber, isErrored: !!o.ebtCardNumber, disabled: d("ebtCardNumber")?.disabled, onChange: (a) => { n("ebtCardNumber", a), r("ebtCardNumber", a, e); } } ), l("memberId") && /* @__PURE__ */ s.jsx( ja, { value: t.memberId, isErrored: !!o.memberId, isRequired: d("memberId")?.requireIfOptional, disabled: d("memberId")?.disabled, onChange: (a) => { n("memberId", a), r("memberId", a, e); }, label: /* @__PURE__ */ s.jsx( M, { id: "step.collectMedicalPersonalInfo.registrationNumberLabel", defaultMessage: "Registration Number" } ) } ), l("postalCode") && /* @__PURE__ */ s.jsx( ia, { isErrored: !!o.postalCode, onChange: (a) => { n("postalCode", a), r("postalCode", a, e); }, value: t.postalCode, disabled: d("postalCode")?.disabled } ), l("socialSecurityNumber") && /* @__PURE__ */ s.jsx("div", { className: "sid-ssn-wrapper", children: /* @__PURE__ */ s.jsx( ya, { value: t.socialSecurityNumber, onChange: (a) => { n("socialSecurityNumber", a), r( "socialSecurityNumber", a, e ); }, isErrored: !!o[H.socialSecurityNumber], placeholder: "000-00-0000", disabled: d("socialSecurityNumber")?.disabled } ) }), l("state") && /* @__PURE__ */ s.jsx( ua, { isRequired: !0, options: U(e.programTheme, E), value: t.state || void 0, isErrored: !!o.state, onChange: async (a) => { const i = a ? a.value : void 0; n("state", i), r("state", i, e); }, label: /* @__PURE__ */ s.jsx(M, { id: "state", defaultMessage: "State" }), disabled: d("state")?.disabled } ), l("activeDutyStartDate") && e.programTheme.strictMilitaryValidationEnabled && /* @__PURE__ */ s.jsx( ga, { errorId: o.activeDutyStartDate, locale: N, onChange: (a) => { n("activeDutyStartDate", a), r( "activeDutyStartDate", a, e ); }, value: t.activeDutyStartDate, disabled: d("activeDutyStartDate")?.disabled } ), T.customFormFields?.map((a) => /* @__PURE__ */ s.jsx(ea, { config: a, verificationService: e })), /* @__PURE__ */ s.jsx( sa, { verificationService: e, isErrored: !!o.marketConsentValue, onChange: (a) => { n("metadata", { ...e.viewModel.metadata, marketConsentValue: a }), r( "marketConsentValue", a, e ); }, viewModel: t, disabled: d("marketConsentValue")?.disabled } ), /* @__PURE__ */ s.jsx(K, { verificationService: e, suffix: "CollectAboveSubmit" }), /* @__PURE__ */ s.jsx( ta, { verificationService: e, isErrored: !!o.captchaToken } ), /* @__PURE__ */ s.jsx( ra, { step: R.collectPersonalInfo, verificationService: e, viewModel: t, failedInstantMatch: L, buttonText: /* @__PURE__ */ s.jsx( M, { id: "step.personalInfo.submitButtonText", defaultMessage: "Verify and continue" } ) } ) ] }), /* @__PURE__ */ s.jsx($, { verificationService: e }) ] } ); }, Xa = w(Fa); export { Xa as default };