UNPKG

@sheerid/jslib-nightly

Version:

SheerID JavaScript Library

462 lines (460 loc) • 15.7 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 da, R as N, h as na, aL as m, aM as ra, K as la, V as f, j as s, v as ua, P as ma, Q as ia, g as d, a2 as ba, aN as ga, ab as Ca, u as n, x as pa, y as ha, W as Ea, E as Na, e as Ia, D as xa, z as Ma, a0 as ja, aC as za, aO as Da, aP as Ra, X as ya, b as z, B as Fa, S as La, I as Oa, a5 as Ta, a6 as qa, aB as Pa, G as Aa, M as wa, H as Ba, f as ka, k as Wa, aQ as _a, d as D, l as Ha, aR as Va, aS as Ya, U as C, am as Ka, ad as Ua, aA as Qa, T as $a, a9 as Ga, aj as Xa, m as Ja, aT as Za } from "../sheerid.js"; import { L as ca } from "./LicensedProfessionalOrganizationComponent-CiYU-2dW.js"; const fa = ({ intl: I, verificationService: e }) => { var F, L, O, T, q, P, A, w, B, k, W, _, H, V, Y, K, U, Q, $, G; const t = e.viewModel, { updateViewModel: R, programTheme: S } = e, [p, v] = N.useState(void 0), u = (a) => p && p.some((i) => i.key === a), { fieldValidationErrors: o } = e, h = e.verificationResponse, aa = na(h), l = (a, i) => { const g = Ja( t, (E) => { E[a] = i; } ); R(g); }, ea = (a) => { const i = Za( t, a ); R(i); }, x = t.localeChoice.value, sa = ua(), { segment: b, availableStatuses: M } = h, ta = b.charAt(0).toUpperCase() + b.slice(1), y = () => M && (b === m.FIRST_RESPONDER || b === m.MEDICAL || b === m.LOW_INCOME || b === m.LICENSED_PROFESSIONAL || b === m.EMPLOYMENT || b === m.RECENT_MOVER || b === m.MILITARY), j = (a) => (async () => { try { const i = await _a( h.verificationId, h.currentStep, a ), g = D(() => i.fieldsToCollect.required, []); y() && g.push({ key: "status" }), ea(g), v(g); } catch (i) { Ha.error(`Failed to determine fields to collect: ${i}`); } })(), oa = () => { var a, i, g, E, X, J, Z, c; switch (b) { case m.STUDENT: return /* @__PURE__ */ s.jsx( Xa, { value: e.viewModel.organization, verificationService: e, isErrored: !!o.organization, isRequired: !0, disabled: (a = d("organization")) == null ? void 0 : a.disabled, onChange: (r) => { C(r, e), n("organization", r, e); } } ); case m.TEACHER: return /* @__PURE__ */ s.jsx( Ga, { value: e.viewModel.organization, verificationService: e, isErrored: !!o.organization, disabled: (i = d("organization")) == null ? void 0 : i.disabled, onChange: (r) => { C(r, e), n("organization", r, e); } } ); case m.MEMBER: return /* @__PURE__ */ s.jsx( $a, { value: e.viewModel.organization, verificationService: e, isErrored: !!o.organization, disabled: (g = d("organization")) == null ? void 0 : g.disabled, onChange: (r) => { C(r, e), n("organization", r, e); } } ); case m.MILITARY: return /* @__PURE__ */ s.jsx( Qa, { isErrored: !!o.organization, onChange: (r) => { C(r, e), n("organization", r, e); }, value: { value: D( () => e.viewModel.organization.id ), label: D( () => e.viewModel.organization.name ) }, verificationService: e, disabled: (E = d("organization")) == null ? void 0 : E.disabled } ); case m.FIRST_RESPONDER: return /* @__PURE__ */ s.jsx( Ua, { isErrored: !!o.organization, onChange: (r) => { C(r, e), n("organization", r, e); }, value: e.viewModel.organization, verificationService: e, disabled: (X = d("organization")) == null ? void 0 : X.disabled } ); case m.MEDICAL: return /* @__PURE__ */ s.jsx( Ka, { isErrored: !!o.organization, onChange: (r) => { C(r, e), n("organization", r, e); }, value: e.viewModel.organization, verificationService: e, disabled: (J = d("organization")) == null ? void 0 : J.disabled } ); case m.LICENSED_PROFESSIONAL: return /* @__PURE__ */ s.jsx( ca, { isErrored: !!o.organization, onChange: (r) => { C(r, e), n("organization", r, e); }, value: e.viewModel.organization, verificationService: e, disabled: (Z = d("organization")) == null ? void 0 : Z.disabled } ); case m.LOW_INCOME: return /* @__PURE__ */ s.jsx( Va, { isErrored: !!o.organization, onChange: (r) => { C(r, e), n("organization", r, e); }, value: Ya( e.viewModel.organization ), verificationService: e, isRequired: !0, disabled: (c = d("organization")) == null ? void 0 : c.disabled } ); default: return null; } }; return N.useEffect(() => { M && b === m.MILITARY ? j({ statuses: [] }) : j({}); }, []), N.useEffect(() => { !ra(S).enabled && p && p.length === 0 && la(t, e, f.collectPersonalInfo); }, [p]), N.useEffect(() => { t.status && j({ 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( ma, { verificationService: e, classNameIdentifier: "personal-info" } ), /* @__PURE__ */ s.jsx( ia, { verificationService: e, disabled: (F = d("country")) == null ? void 0 : F.disabled } ), y() && /* @__PURE__ */ s.jsx( ba, { segmentId: b, value: { value: t.status, label: Ca(I, t.status, null) }, isErrored: !!o.status, errorId: `invalid${ta}Status`, options: ga(I, M), disabled: (L = d("status")) == null ? void 0 : L.disabled, onChange: (a) => { l("status", a ? a.value : ""), n( "status", a ? a.value : "", e ); } } ), u("organization") && oa(), /* @__PURE__ */ s.jsxs("div", { className: "sid-names", children: [ u("firstName") && /* @__PURE__ */ s.jsx( pa, { value: t.firstName, isErrored: !!o.firstName, disabled: (O = d("firstName")) == null ? void 0 : O.disabled, onChange: (a) => { l("firstName", a), n("firstName", a, e); } } ), u("lastName") && /* @__PURE__ */ s.jsx( ha, { value: t.lastName, isErrored: !!o.lastName, disabled: (T = d("lastName")) == null ? void 0 : T.disabled, onChange: (a) => { l("lastName", a), n("lastName", a, e); } } ) ] }), u("birthDate") && /* @__PURE__ */ s.jsx( Ea, { value: t.birthDate, errorId: o.birthDate, locale: x, isRequired: !0, disabled: (q = d("birthDate")) == null ? void 0 : q.disabled, onChange: (a) => { l("birthDate", a), n("birthDate", a, e); } } ), u("email") && /* @__PURE__ */ s.jsx( Na, { value: t.email, isErrored: !!o.email, explanation: " ", onChange: (a) => { l("email", a), n("email", a, e); }, onKeyDown: (a) => Ia(a), disabled: (P = d("email")) == null ? void 0 : P.disabled } ), u("phoneNumber") && /* @__PURE__ */ s.jsx( xa, { isRequired: !!e.programTheme.smsLoopEnabled, value: t.phoneNumber, isErrored: !!o.phoneNumber, onChange: (a) => { l("phoneNumber", a), n("phoneNumber", a, e); }, selectedCountryCode: t.countryChoice && t.countryChoice.value, disabled: (A = d("phoneNumber")) == null ? void 0 : A.disabled } ), u("address1") && /* @__PURE__ */ s.jsx( Ma, { value: t.address1, isRequired: !0, isErrored: !!o.address1, errorId: o.address1, disabled: (w = d("address1")) == null ? void 0 : w.disabled, onChange: (a) => { l("address1", a), n("address1", a, e); } } ), u("city") && /* @__PURE__ */ s.jsx( ja, { value: t.city, isRequired: !0, isErrored: !!o.city, errorId: o.city, disabled: (B = d("city")) == null ? void 0 : B.disabled, onChange: (a) => { l("city", a), n("city", a, e); } } ), u("dischargeDate") && /* @__PURE__ */ s.jsx( za, { errorId: o.dischargeDate, locale: x, onChange: (a) => { l("dischargeDate", a), n("dischargeDate", a, e); }, value: t.dischargeDate, disabled: (k = d("dischargeDate")) == null ? void 0 : k.disabled } ), u("driverLicenseNumber") && /* @__PURE__ */ s.jsx( Da, { value: t.driverLicenseNumber, isErrored: !!o.driverLicenseNumber, isRequired: !0, disabled: (W = d("driverLicenseNumber")) == null ? void 0 : W.disabled, onChange: (a) => { l("driverLicenseNumber", a), n( "driverLicenseNumber", a, e ); } } ), u("ebtCardNumber") && /* @__PURE__ */ s.jsx( Ra, { value: t.ebtCardNumber, isErrored: !!o.ebtCardNumber, disabled: (_ = d("ebtCardNumber")) == null ? void 0 : _.disabled, onChange: (a) => { l("ebtCardNumber", a), n("ebtCardNumber", a, e); } } ), u("memberId") && /* @__PURE__ */ s.jsx( ya, { value: t.memberId, isErrored: !!o.memberId, isRequired: (H = d("memberId")) == null ? void 0 : H.requireIfOptional, disabled: (V = d("memberId")) == null ? void 0 : V.disabled, onChange: (a) => { l("memberId", a), n("memberId", a, e); }, label: /* @__PURE__ */ s.jsx( z, { id: "step.collectMedicalPersonalInfo.registrationNumberLabel", defaultMessage: "Registration Number" } ) } ), u("postalCode") && /* @__PURE__ */ s.jsx( Fa, { isErrored: !!o.postalCode, onChange: (a) => { l("postalCode", a), n("postalCode", a, e); }, value: t.postalCode, disabled: (Y = d("postalCode")) == null ? void 0 : Y.disabled } ), u("socialSecurityNumber") && /* @__PURE__ */ s.jsx("div", { className: "sid-ssn-wrapper", children: /* @__PURE__ */ s.jsx( La, { value: t.socialSecurityNumber, onChange: (a) => { l("socialSecurityNumber", a), n( "socialSecurityNumber", a, e ); }, isErrored: !!o[Oa.socialSecurityNumber], placeholder: "000-00-0000", disabled: (K = d("socialSecurityNumber")) == null ? void 0 : K.disabled } ) }), u("state") && /* @__PURE__ */ s.jsx( Ta, { isRequired: !0, options: qa(e.programTheme, I), value: t.state || void 0, isErrored: !!o.state, onChange: async (a) => { const i = a ? a.value : void 0; l("state", i), n("state", i, e); }, label: /* @__PURE__ */ s.jsx(z, { id: "state", defaultMessage: "State" }), disabled: (U = d("state")) == null ? void 0 : U.disabled } ), u("activeDutyStartDate") && e.programTheme.strictMilitaryValidationEnabled && /* @__PURE__ */ s.jsx( Pa, { errorId: o.activeDutyStartDate, locale: x, onChange: (a) => { l("activeDutyStartDate", a), n( "activeDutyStartDate", a, e ); }, value: t.activeDutyStartDate, disabled: (Q = d("activeDutyStartDate")) == null ? void 0 : Q.disabled } ), ($ = sa.customFormFields) == null ? void 0 : $.map((a) => /* @__PURE__ */ s.jsx(Aa, { config: a, verificationService: e })), /* @__PURE__ */ s.jsx( wa, { verificationService: e, isErrored: !!o.marketConsentValue, onChange: (a) => { l("metadata", { ...e.viewModel.metadata, marketConsentValue: a }), n( "marketConsentValue", a, e ); }, viewModel: t, disabled: (G = d("marketConsentValue")) == null ? void 0 : G.disabled } ), /* @__PURE__ */ s.jsx(Ba, { verificationService: e, suffix: "CollectAboveSubmit" }), /* @__PURE__ */ s.jsx( ka, { step: f.collectPersonalInfo, verificationService: e, viewModel: t, failedInstantMatch: aa, buttonText: /* @__PURE__ */ s.jsx( z, { id: "step.personalInfo.submitButtonText", defaultMessage: "Verify and continue" } ) } ) ] }), /* @__PURE__ */ s.jsx(Wa, { verificationService: e }) ] } ); }, ae = da(fa); export { ae as default };