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