@burdenoff/microfe-atheletebridge 2026.1103.2 → 2026.1108.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atheletebridge/components/registration/OnlineCheckout.d.ts +11 -0
- package/dist/atheletebridge/components/registration/OnlineCheckout.d.ts.map +1 -0
- package/dist/atheletebridge/components/registration/OnlineCheckout.js +102 -0
- package/dist/atheletebridge/components/registration/OnlineCheckout.js.map +1 -0
- package/dist/atheletebridge/components/registration/OnlinePaymentsCard.d.ts +4 -0
- package/dist/atheletebridge/components/registration/OnlinePaymentsCard.d.ts.map +1 -0
- package/dist/atheletebridge/components/registration/OnlinePaymentsCard.js +150 -0
- package/dist/atheletebridge/components/registration/OnlinePaymentsCard.js.map +1 -0
- package/dist/atheletebridge/components/registration/RegistrationEntryFields.d.ts +6 -0
- package/dist/atheletebridge/components/registration/RegistrationEntryFields.d.ts.map +1 -1
- package/dist/atheletebridge/components/registration/RegistrationEntryFields.js +23 -11
- package/dist/atheletebridge/components/registration/RegistrationEntryFields.js.map +1 -1
- package/dist/atheletebridge/components/registration/entryRules.d.ts +2 -0
- package/dist/atheletebridge/components/registration/entryRules.d.ts.map +1 -1
- package/dist/atheletebridge/components/registration/entryRules.js +2 -1
- package/dist/atheletebridge/components/registration/entryRules.js.map +1 -1
- package/dist/atheletebridge/hooks/useRegistrationApi.d.ts +19 -2
- package/dist/atheletebridge/hooks/useRegistrationApi.d.ts.map +1 -1
- package/dist/atheletebridge/hooks/useRegistrationApi.js +76 -33
- package/dist/atheletebridge/hooks/useRegistrationApi.js.map +1 -1
- package/dist/atheletebridge/pages/registrations/MyRegistrationsPage.d.ts +3 -1
- package/dist/atheletebridge/pages/registrations/MyRegistrationsPage.d.ts.map +1 -1
- package/dist/atheletebridge/pages/registrations/MyRegistrationsPage.js +71 -64
- package/dist/atheletebridge/pages/registrations/MyRegistrationsPage.js.map +1 -1
- package/dist/atheletebridge/pages/registrations/RegisterPage.d.ts.map +1 -1
- package/dist/atheletebridge/pages/registrations/RegisterPage.js +82 -77
- package/dist/atheletebridge/pages/registrations/RegisterPage.js.map +1 -1
- package/dist/atheletebridge/pages/registrations/RegistrationFormsListPage.d.ts.map +1 -1
- package/dist/atheletebridge/pages/registrations/RegistrationFormsListPage.js +49 -47
- package/dist/atheletebridge/pages/registrations/RegistrationFormsListPage.js.map +1 -1
- package/dist/atheletebridge/pages/registrations/RegistrationSubmissionPage.d.ts.map +1 -1
- package/dist/atheletebridge/pages/registrations/RegistrationSubmissionPage.js +140 -109
- package/dist/atheletebridge/pages/registrations/RegistrationSubmissionPage.js.map +1 -1
- package/dist/atheletebridge/types/registration.d.ts +49 -0
- package/dist/atheletebridge/types/registration.d.ts.map +1 -1
- package/dist/atheletebridge/utils/onlineCheckout.d.ts +69 -0
- package/dist/atheletebridge/utils/onlineCheckout.d.ts.map +1 -0
- package/dist/atheletebridge/utils/onlineCheckout.js +61 -0
- package/dist/atheletebridge/utils/onlineCheckout.js.map +1 -0
- package/dist/atheletebridge/utils/registration.d.ts +19 -0
- package/dist/atheletebridge/utils/registration.d.ts.map +1 -1
- package/dist/atheletebridge/utils/registration.js +28 -1
- package/dist/atheletebridge/utils/registration.js.map +1 -1
- package/dist/generated/global-types.d.ts +6164 -1907
- package/dist/generated/global-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.d.ts +60796 -3422
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { AthMyRegistration } from '../../types/registration';
|
|
3
|
+
|
|
4
|
+
/** Page the processor sends the family back to. */
|
|
5
|
+
export declare const MY_REGISTRATIONS_PATH = "/my-registrations";
|
|
6
|
+
export declare const PayOnlineButton: FC<{
|
|
7
|
+
registration: Pick<AthMyRegistration, 'id' | 'amountOutstanding' | 'currency'>;
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const CheckoutReturnNotice: FC;
|
|
11
|
+
//# sourceMappingURL=OnlineCheckout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnlineCheckout.d.ts","sourceRoot":"","sources":["../../../../src/atheletebridge/components/registration/OnlineCheckout.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAA+B,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAc7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAKlE,mDAAmD;AACnD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC;IAC/B,YAAY,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,GAAG,mBAAmB,GAAG,UAAU,CAAC,CAAC;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CA4CA,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,EAiFlC,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useAthleteBridge as e } from "../../context/AthleteBridgeContext.js";
|
|
2
|
+
import { useConfirmRegistrationCheckout as t, useStartRegistrationCheckout as n } from "../../hooks/useRegistrationApi.js";
|
|
3
|
+
import { formatMoney as r } from "../../utils/money.js";
|
|
4
|
+
import { appPageUrl as i, checkoutResultMessage as a, parseCheckoutReturn as o, withoutReturnParams as s } from "../../utils/onlineCheckout.js";
|
|
5
|
+
import { useEffect as c, useRef as l, useState as u } from "react";
|
|
6
|
+
import { CheckCircle2 as d, CreditCard as f, Info as p, Loader2 as m } from "lucide-react";
|
|
7
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
8
|
+
//#region src/atheletebridge/components/registration/OnlineCheckout.tsx
|
|
9
|
+
var _ = (e, t) => e instanceof Error ? e.message : t, v = "/my-registrations", y = ({ registration: t, className: a }) => {
|
|
10
|
+
let { basePath: o } = e(), s = n(), [c, l] = u(null), d = async () => {
|
|
11
|
+
l(null);
|
|
12
|
+
try {
|
|
13
|
+
let e = await s.mutateAsync({
|
|
14
|
+
submissionId: t.id,
|
|
15
|
+
returnUrl: i(window.location.origin, o ?? "/", v)
|
|
16
|
+
});
|
|
17
|
+
window.location.assign(e.url);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
l(_(e, "Could not open the online payment."));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ g("span", {
|
|
23
|
+
className: "inline-flex flex-col items-end gap-1",
|
|
24
|
+
children: [/* @__PURE__ */ g("button", {
|
|
25
|
+
type: "button",
|
|
26
|
+
"data-testid": "pay-online",
|
|
27
|
+
disabled: s.isPending,
|
|
28
|
+
onClick: () => void d(),
|
|
29
|
+
className: a ?? "inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:opacity-50",
|
|
30
|
+
children: [
|
|
31
|
+
s.isPending ? /* @__PURE__ */ h(m, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ h(f, { className: "h-4 w-4" }),
|
|
32
|
+
" ",
|
|
33
|
+
"Pay ",
|
|
34
|
+
r(t.amountOutstanding, t.currency),
|
|
35
|
+
" online"
|
|
36
|
+
]
|
|
37
|
+
}), c && /* @__PURE__ */ h("span", {
|
|
38
|
+
role: "alert",
|
|
39
|
+
className: "text-xs text-status-error-text",
|
|
40
|
+
children: c
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
}, b = () => {
|
|
44
|
+
let e = t(), n = e.mutateAsync, i = l(!1), [f, v] = u(null);
|
|
45
|
+
if (c(() => {
|
|
46
|
+
if (i.current) return;
|
|
47
|
+
let e = o(window.location.search);
|
|
48
|
+
e && (i.current = !0, window.history.replaceState(window.history.state, "", s(window.location.href)), n(e.checkoutId).then((t) => {
|
|
49
|
+
v({
|
|
50
|
+
...a(e, t),
|
|
51
|
+
registration: t
|
|
52
|
+
});
|
|
53
|
+
}).catch((e) => {
|
|
54
|
+
v({
|
|
55
|
+
tone: "error",
|
|
56
|
+
message: _(e, "We could not check the payment. Refresh to try again."),
|
|
57
|
+
registration: null
|
|
58
|
+
});
|
|
59
|
+
}));
|
|
60
|
+
}, [n]), e.isPending) return /* @__PURE__ */ g("p", {
|
|
61
|
+
role: "status",
|
|
62
|
+
className: "mb-4 flex items-center gap-2 text-sm text-text-secondary",
|
|
63
|
+
"data-testid": "checkout-return",
|
|
64
|
+
children: [/* @__PURE__ */ h(m, { className: "h-4 w-4 animate-spin" }), " Checking your payment…"]
|
|
65
|
+
});
|
|
66
|
+
if (!f) return null;
|
|
67
|
+
let y = f.tone === "success" ? "border-status-success-border bg-status-success-bg-subtle text-status-success-text" : f.tone === "error" ? "border-status-error-border bg-status-error-bg-subtle text-status-error-text" : "border-border-seam bg-bg-sunken text-text-primary", b = f.registration;
|
|
68
|
+
return /* @__PURE__ */ g("div", {
|
|
69
|
+
role: f.tone === "error" ? "alert" : "status",
|
|
70
|
+
"data-testid": "checkout-return",
|
|
71
|
+
"data-tone": f.tone,
|
|
72
|
+
className: `mb-4 space-y-1 rounded-lg border p-3 text-sm ${y}`,
|
|
73
|
+
children: [/* @__PURE__ */ g("p", {
|
|
74
|
+
className: "flex items-start gap-2",
|
|
75
|
+
children: [f.tone === "success" ? /* @__PURE__ */ h(d, {
|
|
76
|
+
className: "mt-0.5 h-4 w-4 shrink-0",
|
|
77
|
+
"aria-hidden": "true"
|
|
78
|
+
}) : /* @__PURE__ */ h(p, {
|
|
79
|
+
className: "mt-0.5 h-4 w-4 shrink-0",
|
|
80
|
+
"aria-hidden": "true"
|
|
81
|
+
}), /* @__PURE__ */ h("span", { children: f.message })]
|
|
82
|
+
}), b && /* @__PURE__ */ g("p", {
|
|
83
|
+
className: "pl-6 text-xs tabular-nums",
|
|
84
|
+
"data-testid": "checkout-return-balance",
|
|
85
|
+
children: [
|
|
86
|
+
b.participantName,
|
|
87
|
+
" · ",
|
|
88
|
+
b.formTitle,
|
|
89
|
+
": paid ",
|
|
90
|
+
r(b.amountPaid, b.currency),
|
|
91
|
+
" ",
|
|
92
|
+
"of ",
|
|
93
|
+
r(b.amountDue, b.currency),
|
|
94
|
+
b.amountOutstanding > 0 ? `, ${r(b.amountOutstanding, b.currency)} still due` : ""
|
|
95
|
+
]
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { b as CheckoutReturnNotice, y as PayOnlineButton };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=OnlineCheckout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnlineCheckout.js","names":[],"sources":["../../../../src/atheletebridge/components/registration/OnlineCheckout.tsx"],"sourcesContent":["/**\n * Family online checkout (BOFF-10902)\n * @module atheletebridge/components/registration\n *\n * `PayOnlineButton` opens the club's processor checkout for the outstanding\n * balance of one of the family's own registrations and sends the browser to\n * it. The processor returns the family to \"My registrations\" with\n * `?athCheckout=<id>&athStatus=…`; `CheckoutReturnNotice` settles that\n * checkout with the server (which re-reads it from the processor, never\n * trusting the browser) and reports the updated balance.\n */\n\nimport { useEffect, useRef, useState, type FC } from 'react';\nimport { CheckCircle2, CreditCard, Info, Loader2 } from 'lucide-react';\nimport { useAthleteBridge } from '../../context/AthleteBridgeContext';\nimport {\n useConfirmRegistrationCheckout,\n useStartRegistrationCheckout,\n} from '../../hooks/useRegistrationApi';\nimport { formatMoney } from '../../utils/money';\nimport {\n appPageUrl,\n checkoutResultMessage,\n parseCheckoutReturn,\n withoutReturnParams,\n} from '../../utils/onlineCheckout';\nimport type { AthMyRegistration } from '../../types/registration';\n\nconst errorMessage = (err: unknown, fallback: string) =>\n err instanceof Error ? err.message : fallback;\n\n/** Page the processor sends the family back to. */\nexport const MY_REGISTRATIONS_PATH = '/my-registrations';\n\nexport const PayOnlineButton: FC<{\n registration: Pick<AthMyRegistration, 'id' | 'amountOutstanding' | 'currency'>;\n className?: string;\n}> = ({ registration, className }) => {\n const { basePath } = useAthleteBridge();\n const start = useStartRegistrationCheckout();\n const [error, setError] = useState<string | null>(null);\n\n const onPay = async () => {\n setError(null);\n try {\n const session = await start.mutateAsync({\n submissionId: registration.id,\n returnUrl: appPageUrl(window.location.origin, basePath ?? '/', MY_REGISTRATIONS_PATH),\n });\n window.location.assign(session.url);\n } catch (err) {\n setError(errorMessage(err, 'Could not open the online payment.'));\n }\n };\n\n return (\n <span className=\"inline-flex flex-col items-end gap-1\">\n <button\n type=\"button\"\n data-testid=\"pay-online\"\n disabled={start.isPending}\n onClick={() => void onPay()}\n className={\n className ??\n 'inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:opacity-50'\n }\n >\n {start.isPending ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <CreditCard className=\"h-4 w-4\" />\n )}{' '}\n Pay {formatMoney(registration.amountOutstanding, registration.currency)} online\n </button>\n {error && (\n <span role=\"alert\" className=\"text-xs text-status-error-text\">\n {error}\n </span>\n )}\n </span>\n );\n};\n\nexport const CheckoutReturnNotice: FC = () => {\n const confirm = useConfirmRegistrationCheckout();\n const confirmAsync = confirm.mutateAsync;\n const handled = useRef(false);\n const [notice, setNotice] = useState<{\n tone: 'success' | 'info' | 'error';\n message: string;\n registration: AthMyRegistration | null;\n } | null>(null);\n\n useEffect(() => {\n if (handled.current) return;\n const result = parseCheckoutReturn(window.location.search);\n if (!result) return;\n handled.current = true;\n window.history.replaceState(\n window.history.state,\n '',\n withoutReturnParams(window.location.href)\n );\n // Settle even a cancelled checkout: the server expires it so it can no\n // longer be paid on top of a newer one.\n confirmAsync(result.checkoutId)\n .then((registration) => {\n setNotice({ ...checkoutResultMessage(result, registration), registration });\n })\n .catch((err: unknown) => {\n setNotice({\n tone: 'error',\n message: errorMessage(err, 'We could not check the payment. Refresh to try again.'),\n registration: null,\n });\n });\n }, [confirmAsync]);\n\n if (confirm.isPending) {\n return (\n <p\n role=\"status\"\n className=\"mb-4 flex items-center gap-2 text-sm text-text-secondary\"\n data-testid=\"checkout-return\"\n >\n <Loader2 className=\"h-4 w-4 animate-spin\" /> Checking your payment…\n </p>\n );\n }\n if (!notice) return null;\n\n const toneClass =\n notice.tone === 'success'\n ? 'border-status-success-border bg-status-success-bg-subtle text-status-success-text'\n : notice.tone === 'error'\n ? 'border-status-error-border bg-status-error-bg-subtle text-status-error-text'\n : 'border-border-seam bg-bg-sunken text-text-primary';\n const reg = notice.registration;\n return (\n <div\n role={notice.tone === 'error' ? 'alert' : 'status'}\n data-testid=\"checkout-return\"\n data-tone={notice.tone}\n className={`mb-4 space-y-1 rounded-lg border p-3 text-sm ${toneClass}`}\n >\n <p className=\"flex items-start gap-2\">\n {notice.tone === 'success' ? (\n <CheckCircle2 className=\"mt-0.5 h-4 w-4 shrink-0\" aria-hidden=\"true\" />\n ) : (\n <Info className=\"mt-0.5 h-4 w-4 shrink-0\" aria-hidden=\"true\" />\n )}\n <span>{notice.message}</span>\n </p>\n {reg && (\n <p className=\"pl-6 text-xs tabular-nums\" data-testid=\"checkout-return-balance\">\n {reg.participantName} · {reg.formTitle}: paid {formatMoney(reg.amountPaid, reg.currency)}{' '}\n of {formatMoney(reg.amountDue, reg.currency)}\n {reg.amountOutstanding > 0\n ? `, ${formatMoney(reg.amountOutstanding, reg.currency)} still due`\n : ''}\n </p>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;AA4BA,IAAM,KAAgB,GAAc,MAClC,aAAe,QAAQ,EAAI,UAAU,GAG1B,IAAwB,qBAExB,KAGP,EAAE,iBAAc,mBAAgB;CACpC,IAAM,EAAE,gBAAa,EAAiB,GAChC,IAAQ,EAA6B,GACrC,CAAC,GAAO,KAAY,EAAwB,IAAI,GAEhD,IAAQ,YAAY;EACxB,EAAS,IAAI;EACb,IAAI;GACF,IAAM,IAAU,MAAM,EAA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;YAHd,CAKE,kBAAC,GAAD,EAAS,WAAU,uBAAwB,CAAA,GAAC,yBAC3C;;CAGP,IAAI,CAAC,GAAQ,OAAO;CAEpB,IAAM,IACJ,EAAO,SAAS,YACZ,sFACA,EAAO,SAAS,UACd,gFACA,qDACF,IAAM,EAAO;CACnB,OACE,kBAAC,OAAD;EACE,MAAM,EAAO,SAAS,UAAU,UAAU;EAC1C,eAAY;EACZ,aAAW,EAAO;EAClB,WAAW,gDAAgD;YAJ7D,CAME,kBAAC,KAAD;GAAG,WAAU;aAAb,CACG,EAAO,SAAS,YACf,kBAAC,GAAD;IAAc,WAAU;IAA0B,eAAY;GAAQ,CAAA,IAEtE,kBAAC,GAAD;IAAM,WAAU;IAA0B,eAAY;GAAQ,CAAA,GAEhE,kBAAC,QAAD,EAAA,UAAO,EAAO,QAAc,CAAA,CAC3B;MACF,KACC,kBAAC,KAAD;GAAG,WAAU;GAA4B,eAAY;aAArD;IACG,EAAI;IAAgB;IAAI,EAAI;IAAU;IAAQ,EAAY,EAAI,YAAY,EAAI,QAAQ;IAAG;IAAI;IAC1F,EAAY,EAAI,WAAW,EAAI,QAAQ;IAC1C,EAAI,oBAAoB,IACrB,KAAK,EAAY,EAAI,mBAAmB,EAAI,QAAQ,EAAE,cACtD;GACH;IAEF;;AAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnlinePaymentsCard.d.ts","sourceRoot":"","sources":["../../../../src/atheletebridge/components/registration/OnlinePaymentsCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA4C,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAiD1E,eAAO,MAAM,kBAAkB,EAAE,EAwIhC,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { StatusBadge as e } from "../StatusBadge.js";
|
|
2
|
+
import { formatDate as t } from "../../utils/formatters.js";
|
|
3
|
+
import { useConnectPaymentAccount as n, useOnlinePaymentsStatus as r, useRefreshPaymentAccount as i } from "../../hooks/useRegistrationApi.js";
|
|
4
|
+
import { onlinePaymentsState as a, parseOnboardingReturn as o, providerLabel as s, withoutReturnParams as c } from "../../utils/onlineCheckout.js";
|
|
5
|
+
import { useCallback as l, useEffect as u, useRef as d, useState as f } from "react";
|
|
6
|
+
import { CreditCard as p, ExternalLink as m, Loader2 as h, RefreshCw as g } from "lucide-react";
|
|
7
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
8
|
+
//#region src/atheletebridge/components/registration/OnlinePaymentsCard.tsx
|
|
9
|
+
var y = "inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:opacity-50", b = "inline-flex items-center gap-1.5 rounded-lg border border-border-seam px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-50", x = {
|
|
10
|
+
unavailable: "Online payments are not switched on for AthleteBridge yet. Families pay you directly, and you record each payment on the registration.",
|
|
11
|
+
not_connected: "Connect your Stripe account so families can pay registration fees by card when they register. Payments go straight to your club; AthleteBridge never holds the money.",
|
|
12
|
+
onboarding: "Your Stripe account is created but the setup form is not finished. Continue the setup to start taking online payments.",
|
|
13
|
+
pending_review: "Stripe has your details but has not enabled card payments yet. This usually takes a few minutes; refresh to check again.",
|
|
14
|
+
ready: "Families see a \"Pay online\" button for any fee still due."
|
|
15
|
+
}, S = (e, t) => e instanceof Error ? e.message : t, C = () => c(window.location.href), w = ({ label: t, on: n, testId: r }) => /* @__PURE__ */ v("div", {
|
|
16
|
+
className: "flex items-center justify-between gap-3",
|
|
17
|
+
"data-testid": r,
|
|
18
|
+
children: [/* @__PURE__ */ _("dt", {
|
|
19
|
+
className: "text-text-secondary",
|
|
20
|
+
children: t
|
|
21
|
+
}), /* @__PURE__ */ _("dd", { children: /* @__PURE__ */ _(e, {
|
|
22
|
+
status: n ? "yes" : "not yet",
|
|
23
|
+
variant: n ? "success" : "warning"
|
|
24
|
+
}) })]
|
|
25
|
+
}), T = () => {
|
|
26
|
+
let c = r(), T = n(), E = i(), [D, O] = f(null), k = d(!1), A = T.mutateAsync, j = E.mutateAsync, M = l(async () => {
|
|
27
|
+
O(null);
|
|
28
|
+
try {
|
|
29
|
+
let e = await A({ returnUrl: C() });
|
|
30
|
+
window.location.assign(e.url);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
O(S(e, "Could not open the Stripe setup."));
|
|
33
|
+
}
|
|
34
|
+
}, [A]), N = l(async () => {
|
|
35
|
+
O(null);
|
|
36
|
+
try {
|
|
37
|
+
await j();
|
|
38
|
+
} catch (e) {
|
|
39
|
+
O(S(e, "Could not refresh the Stripe account."));
|
|
40
|
+
}
|
|
41
|
+
}, [j]), P = c.data?.processorConfigured ?? !1;
|
|
42
|
+
if (u(() => {
|
|
43
|
+
if (k.current || !P) return;
|
|
44
|
+
let e = o(window.location.search);
|
|
45
|
+
e && (k.current = !0, window.history.replaceState(window.history.state, "", C()), e === "refresh" ? M() : N());
|
|
46
|
+
}, [
|
|
47
|
+
P,
|
|
48
|
+
M,
|
|
49
|
+
N
|
|
50
|
+
]), c.isLoading || c.isError || !c.data) return null;
|
|
51
|
+
let F = c.data, I = a(F), L = F.account, R = T.isPending || E.isPending;
|
|
52
|
+
return /* @__PURE__ */ v("section", {
|
|
53
|
+
"aria-label": "Online payments",
|
|
54
|
+
className: "mb-6 space-y-3 rounded-lg border border-border-seam bg-bg-surface p-4",
|
|
55
|
+
"data-testid": "online-payments-card",
|
|
56
|
+
"data-state": I,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ v("div", {
|
|
59
|
+
className: "flex flex-wrap items-center justify-between gap-3",
|
|
60
|
+
children: [/* @__PURE__ */ v("h2", {
|
|
61
|
+
className: "flex items-center gap-2 text-base font-semibold text-text-primary",
|
|
62
|
+
children: [/* @__PURE__ */ _(p, {
|
|
63
|
+
className: "h-5 w-5 text-text-secondary",
|
|
64
|
+
"aria-hidden": "true"
|
|
65
|
+
}), " Online payments"]
|
|
66
|
+
}), /* @__PURE__ */ v("span", {
|
|
67
|
+
className: "flex flex-wrap items-center gap-2",
|
|
68
|
+
children: [F.processorConfigured && F.testMode && /* @__PURE__ */ _(e, {
|
|
69
|
+
status: "test mode",
|
|
70
|
+
variant: "warning"
|
|
71
|
+
}), /* @__PURE__ */ _(e, {
|
|
72
|
+
status: I === "ready" ? "active" : I === "unavailable" ? "not available" : "setup needed",
|
|
73
|
+
variant: I === "ready" ? "success" : "secondary"
|
|
74
|
+
})]
|
|
75
|
+
})]
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ _("p", {
|
|
78
|
+
className: "text-sm text-text-secondary",
|
|
79
|
+
"data-testid": "online-payments-message",
|
|
80
|
+
children: x[I]
|
|
81
|
+
}),
|
|
82
|
+
F.processorConfigured && F.testMode && /* @__PURE__ */ _("p", {
|
|
83
|
+
className: "text-xs text-text-secondary",
|
|
84
|
+
children: "Test mode: no real money moves. Use Stripe test cards (for example 4242 4242 4242 4242)."
|
|
85
|
+
}),
|
|
86
|
+
L && /* @__PURE__ */ v("dl", {
|
|
87
|
+
className: "grid grid-cols-1 gap-x-6 gap-y-2 text-sm sm:grid-cols-3",
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ _(w, {
|
|
90
|
+
label: "Setup submitted",
|
|
91
|
+
on: L.detailsSubmitted,
|
|
92
|
+
testId: "flag-details"
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ _(w, {
|
|
95
|
+
label: "Card payments",
|
|
96
|
+
on: L.chargesEnabled,
|
|
97
|
+
testId: "flag-charges"
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ _(w, {
|
|
100
|
+
label: "Payouts",
|
|
101
|
+
on: L.payoutsEnabled,
|
|
102
|
+
testId: "flag-payouts"
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
}),
|
|
106
|
+
L && /* @__PURE__ */ v("p", {
|
|
107
|
+
className: "text-xs text-text-secondary",
|
|
108
|
+
children: [
|
|
109
|
+
s(L.provider),
|
|
110
|
+
" account ",
|
|
111
|
+
L.accountId,
|
|
112
|
+
L.lastSyncedAt ? ` · checked ${t(L.lastSyncedAt)}` : ""
|
|
113
|
+
]
|
|
114
|
+
}),
|
|
115
|
+
F.processorConfigured && /* @__PURE__ */ v("div", {
|
|
116
|
+
className: "flex flex-wrap gap-2",
|
|
117
|
+
children: [I !== "ready" && /* @__PURE__ */ v("button", {
|
|
118
|
+
type: "button",
|
|
119
|
+
className: y,
|
|
120
|
+
disabled: R,
|
|
121
|
+
onClick: () => void M(),
|
|
122
|
+
children: [
|
|
123
|
+
T.isPending ? /* @__PURE__ */ _(h, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ _(m, { className: "h-4 w-4" }),
|
|
124
|
+
" ",
|
|
125
|
+
I === "not_connected" ? "Connect Stripe" : "Continue Stripe setup"
|
|
126
|
+
]
|
|
127
|
+
}), L && /* @__PURE__ */ v("button", {
|
|
128
|
+
type: "button",
|
|
129
|
+
className: b,
|
|
130
|
+
disabled: R,
|
|
131
|
+
onClick: () => void N(),
|
|
132
|
+
children: [
|
|
133
|
+
E.isPending ? /* @__PURE__ */ _(h, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ _(g, { className: "h-4 w-4" }),
|
|
134
|
+
" ",
|
|
135
|
+
"Refresh status"
|
|
136
|
+
]
|
|
137
|
+
})]
|
|
138
|
+
}),
|
|
139
|
+
D && /* @__PURE__ */ _("p", {
|
|
140
|
+
role: "alert",
|
|
141
|
+
className: "text-sm text-status-error-text",
|
|
142
|
+
children: D
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
148
|
+
export { T as OnlinePaymentsCard };
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=OnlinePaymentsCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnlinePaymentsCard.js","names":[],"sources":["../../../../src/atheletebridge/components/registration/OnlinePaymentsCard.tsx"],"sourcesContent":["/**\n * Online payments card (club staff, BOFF-10902)\n * @module atheletebridge/components/registration\n *\n * Lets a club connect its own payout account at the payment processor\n * (Stripe Connect Express, BOFF-10805) so families can pay registration fees\n * online. The club stays merchant of record: money goes straight to its\n * account and Burdenoff never holds it.\n *\n * \"Connect Stripe\" opens the processor's hosted onboarding. When the club comes\n * back (`?athOnboarding=return`) the card re-reads the account from the\n * processor; when the onboarding link expired (`?athOnboarding=refresh`) it\n * opens a fresh one. Renders nothing for staff who cannot read the payment\n * ledger (FORBIDDEN), like the reconciliation panel.\n */\n\nimport { useCallback, useEffect, useRef, useState, type FC } from 'react';\nimport { CreditCard, ExternalLink, Loader2, RefreshCw } from 'lucide-react';\nimport { StatusBadge } from '../StatusBadge';\nimport {\n useConnectPaymentAccount,\n useOnlinePaymentsStatus,\n useRefreshPaymentAccount,\n} from '../../hooks/useRegistrationApi';\nimport { formatDate } from '../../utils/formatters';\nimport {\n onlinePaymentsState,\n parseOnboardingReturn,\n providerLabel,\n withoutReturnParams,\n type OnlinePaymentsState,\n} from '../../utils/onlineCheckout';\n\nconst primaryButton =\n 'inline-flex items-center gap-1.5 rounded-lg bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:opacity-50';\nconst secondaryButton =\n 'inline-flex items-center gap-1.5 rounded-lg border border-border-seam px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-50';\n\nconst STATE_COPY: Record<OnlinePaymentsState, string> = {\n unavailable:\n 'Online payments are not switched on for AthleteBridge yet. Families pay you directly, and you record each payment on the registration.',\n not_connected:\n 'Connect your Stripe account so families can pay registration fees by card when they register. Payments go straight to your club; AthleteBridge never holds the money.',\n onboarding:\n 'Your Stripe account is created but the setup form is not finished. Continue the setup to start taking online payments.',\n pending_review:\n 'Stripe has your details but has not enabled card payments yet. This usually takes a few minutes; refresh to check again.',\n ready: 'Families see a \"Pay online\" button for any fee still due.',\n};\n\nconst errorMessage = (err: unknown, fallback: string) =>\n err instanceof Error ? err.message : fallback;\n\n/** The page the club should come back to after onboarding (this page, cleaned). */\nconst currentReturnUrl = () => withoutReturnParams(window.location.href);\n\nconst Flag: FC<{ label: string; on: boolean; testId: string }> = ({ label, on, testId }) => (\n <div className=\"flex items-center justify-between gap-3\" data-testid={testId}>\n <dt className=\"text-text-secondary\">{label}</dt>\n <dd>\n <StatusBadge status={on ? 'yes' : 'not yet'} variant={on ? 'success' : 'warning'} />\n </dd>\n </div>\n);\n\nexport const OnlinePaymentsCard: FC = () => {\n const status = useOnlinePaymentsStatus();\n const connect = useConnectPaymentAccount();\n const refresh = useRefreshPaymentAccount();\n const [error, setError] = useState<string | null>(null);\n const handledReturn = useRef(false);\n\n const connectAsync = connect.mutateAsync;\n const refreshAsync = refresh.mutateAsync;\n\n const startOnboarding = useCallback(async () => {\n setError(null);\n try {\n const link = await connectAsync({ returnUrl: currentReturnUrl() });\n window.location.assign(link.url);\n } catch (err) {\n setError(errorMessage(err, 'Could not open the Stripe setup.'));\n }\n }, [connectAsync]);\n\n const refreshAccount = useCallback(async () => {\n setError(null);\n try {\n await refreshAsync();\n } catch (err) {\n setError(errorMessage(err, 'Could not refresh the Stripe account.'));\n }\n }, [refreshAsync]);\n\n // Handle the processor's return exactly once, then clean the address bar so\n // a reload does not replay it.\n const processorConfigured = status.data?.processorConfigured ?? false;\n useEffect(() => {\n if (handledReturn.current || !processorConfigured) return;\n const kind = parseOnboardingReturn(window.location.search);\n if (!kind) return;\n handledReturn.current = true;\n window.history.replaceState(window.history.state, '', currentReturnUrl());\n void (kind === 'refresh' ? startOnboarding() : refreshAccount());\n }, [processorConfigured, startOnboarding, refreshAccount]);\n\n if (status.isLoading || status.isError || !status.data) return null;\n const data = status.data;\n const state = onlinePaymentsState(data);\n const account = data.account;\n const busy = connect.isPending || refresh.isPending;\n\n return (\n <section\n aria-label=\"Online payments\"\n className=\"mb-6 space-y-3 rounded-lg border border-border-seam bg-bg-surface p-4\"\n data-testid=\"online-payments-card\"\n data-state={state}\n >\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <h2 className=\"flex items-center gap-2 text-base font-semibold text-text-primary\">\n <CreditCard className=\"h-5 w-5 text-text-secondary\" aria-hidden=\"true\" /> Online payments\n </h2>\n <span className=\"flex flex-wrap items-center gap-2\">\n {data.processorConfigured && data.testMode && (\n <StatusBadge status=\"test mode\" variant=\"warning\" />\n )}\n <StatusBadge\n status={\n state === 'ready'\n ? 'active'\n : state === 'unavailable'\n ? 'not available'\n : 'setup needed'\n }\n variant={state === 'ready' ? 'success' : 'secondary'}\n />\n </span>\n </div>\n <p className=\"text-sm text-text-secondary\" data-testid=\"online-payments-message\">\n {STATE_COPY[state]}\n </p>\n {data.processorConfigured && data.testMode && (\n <p className=\"text-xs text-text-secondary\">\n Test mode: no real money moves. Use Stripe test cards (for example 4242 4242 4242 4242).\n </p>\n )}\n {account && (\n <dl className=\"grid grid-cols-1 gap-x-6 gap-y-2 text-sm sm:grid-cols-3\">\n <Flag label=\"Setup submitted\" on={account.detailsSubmitted} testId=\"flag-details\" />\n <Flag label=\"Card payments\" on={account.chargesEnabled} testId=\"flag-charges\" />\n <Flag label=\"Payouts\" on={account.payoutsEnabled} testId=\"flag-payouts\" />\n </dl>\n )}\n {account && (\n <p className=\"text-xs text-text-secondary\">\n {providerLabel(account.provider)} account {account.accountId}\n {account.lastSyncedAt ? ` · checked ${formatDate(account.lastSyncedAt)}` : ''}\n </p>\n )}\n {data.processorConfigured && (\n <div className=\"flex flex-wrap gap-2\">\n {state !== 'ready' && (\n <button\n type=\"button\"\n className={primaryButton}\n disabled={busy}\n onClick={() => void startOnboarding()}\n >\n {connect.isPending ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <ExternalLink className=\"h-4 w-4\" />\n )}{' '}\n {state === 'not_connected' ? 'Connect Stripe' : 'Continue Stripe setup'}\n </button>\n )}\n {account && (\n <button\n type=\"button\"\n className={secondaryButton}\n disabled={busy}\n onClick={() => void refreshAccount()}\n >\n {refresh.isPending ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <RefreshCw className=\"h-4 w-4\" />\n )}{' '}\n Refresh status\n </button>\n )}\n </div>\n )}\n {error && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n )}\n </section>\n );\n};\n"],"mappings":";;;;;;;;AAiCA,IAAM,IACJ,+LACI,IACJ,kLAEI,IAAkD;CACtD,aACE;CACF,eACE;CACF,YACE;CACF,gBACE;CACF,OAAO;AACT,GAEM,KAAgB,GAAc,MAClC,aAAe,QAAQ,EAAI,UAAU,GAGjC,UAAyB,EAAoB,OAAO,SAAS,IAAI,GAEjE,KAA4D,EAAE,UAAO,OAAI,gBAC7E,kBAAC,OAAD;CAAK,WAAU;CAA0C,eAAa;WAAtE,CACE,kBAAC,MAAD;EAAI,WAAU;YAAuB;CAAU,CAAA,GAC/C,kBAAC,MAAD,EAAA,UACE,kBAAC,GAAD;EAAa,QAAQ,IAAK,QAAQ;EAAW,SAAS,IAAK,YAAY;CAAY,CAAA,EACjF,CAAA,CACD;IAGM,UAA+B;CAC1C,IAAM,IAAS,EAAwB,GACjC,IAAU,EAAyB,GACnC,IAAU,EAAyB,GACnC,CAAC,GAAO,KAAY,EAAwB,IAAI,GAChD,IAAgB,EAAO,EAAK,GAE5B,IAAe,EAAQ,aACvB,IAAe,EAAQ,aAEvB,IAAkB,EAAY,YAAY;EAC9C,EAAS,IAAI;EACb,IAAI;GACF,IAAM,IAAO,MAAM,EAAa,EAAE,WAAW,EAAiB,EAAE,CAAC;GACjE,OAAO,SAAS,OAAO,EAAK,GAAG;EACjC,SAAS,GAAK;GACZ,EAAS,EAAa,GAAK,kCAAkC,CAAC;EAChE;CACF,GAAG,CAAC,CAAY,CAAC,GAEX,IAAiB,EAAY,YAAY;EAC7C,EA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C,GAAD;MAAM,OAAM;MAAkB,IAAI,EAAQ;MAAkB,QAAO;KAAgB,CAAA;KACnF,kBAAC,GAAD;MAAM,OAAM;MAAgB,IAAI,EAAQ;MAAgB,QAAO;KAAgB,CAAA;KAC/E,kBAAC,GAAD;MAAM,OAAM;MAAU,IAAI,EAAQ;MAAgB,QAAO;KAAgB,CAAA;IACvE;;GAEL,KACC,kBAAC,KAAD;IAAG,WAAU;cAAb;KACG,EAAc,EAAQ,QAAQ;KAAE;KAAU,EAAQ;KAClD,EAAQ,eAAe,cAAc,EAAW,EAAQ,YAAY,MAAM;IAC1E;;GAEJ,EAAK,uBACJ,kBAAC,OAAD;IAAK,WAAU;cAAf,CACG,MAAU,WACT,kBAAC,UAAD;KACE,MAAK;KACL,WAAW;KACX,UAAU;KACV,eAAe,KAAK,EAAgB;eAJtC;MAMG,EAAQ,YACP,kBAAC,GAAD,EAAS,WAAU,uBAAwB,CAAA,IAE3C,kBAAC,GAAD,EAAc,WAAU,UAAW,CAAA;MAClC;MACF,MAAU,kBAAkB,mBAAmB;KAC1C;QAET,KACC,kBAAC,UAAD;KACE,MAAK;KACL,WAAW;KACX,UAAU;KACV,eAAe,KAAK,EAAe;eAJrC;MAMG,EAAQ,YACP,kBAAC,GAAD,EAAS,WAAU,uBAAwB,CAAA,IAE3C,kBAAC,GAAD,EAAW,WAAU,UAAW,CAAA;MAC/B;MAAI;KAED;MAEP;;GAEN,KACC,kBAAC,KAAD;IAAG,MAAK;IAAQ,WAAU;cACvB;GACA,CAAA;EAEE;;AAEb"}
|
|
@@ -9,6 +9,12 @@ interface RegistrationEntryFieldsProps {
|
|
|
9
9
|
waiverText: string | null;
|
|
10
10
|
state: RegistrationEntryState;
|
|
11
11
|
onChange: (next: RegistrationEntryState) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Offer the "I am the athlete" choice. Only the family share-link flow sets
|
|
14
|
+
* it: there the signed-in registrant can be the athlete, and saying so lets
|
|
15
|
+
* the club add them to the team roster on acceptance (BOFF-10806).
|
|
16
|
+
*/
|
|
17
|
+
offerSelfRegistration?: boolean;
|
|
12
18
|
}
|
|
13
19
|
export declare const RegistrationEntryFields: FC<RegistrationEntryFieldsProps>;
|
|
14
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegistrationEntryFields.d.ts","sourceRoot":"","sources":["../../../../src/atheletebridge/components/registration/RegistrationEntryFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAEV,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,sBAAsB,EAAqB,MAAM,cAAc,CAAC;AAyF9E,UAAU,4BAA4B;IACpC,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"RegistrationEntryFields.d.ts","sourceRoot":"","sources":["../../../../src/atheletebridge/components/registration/RegistrationEntryFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAEV,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,sBAAsB,EAAqB,MAAM,cAAc,CAAC;AAyF9E,UAAU,4BAA4B;IACpC,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACjD;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CA0KpE,CAAC"}
|
|
@@ -63,11 +63,11 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
63
63
|
hint: n.helpText ?? void 0,
|
|
64
64
|
children: l
|
|
65
65
|
});
|
|
66
|
-
}, s = ({ fields: s, fees: c, currency: l, waiverText: u, state: d, onChange: f }) => {
|
|
67
|
-
let
|
|
66
|
+
}, s = ({ fields: s, fees: c, currency: l, waiverText: u, state: d, onChange: f, offerSelfRegistration: p = !1 }) => {
|
|
67
|
+
let m = (e, t) => f({
|
|
68
68
|
...d,
|
|
69
69
|
[e]: t
|
|
70
|
-
}),
|
|
70
|
+
}), h = r(c, d.optionalFeeIds);
|
|
71
71
|
return /* @__PURE__ */ a("div", {
|
|
72
72
|
className: "space-y-6",
|
|
73
73
|
children: [
|
|
@@ -88,10 +88,22 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
88
88
|
id: "participantName",
|
|
89
89
|
className: t,
|
|
90
90
|
value: d.participantName,
|
|
91
|
-
onChange: (e) =>
|
|
91
|
+
onChange: (e) => m("participantName", e.target.value),
|
|
92
92
|
placeholder: "Athlete's full name"
|
|
93
93
|
})
|
|
94
94
|
}),
|
|
95
|
+
p && /* @__PURE__ */ a("label", {
|
|
96
|
+
className: "flex items-start gap-2.5 text-sm text-text-primary",
|
|
97
|
+
children: [/* @__PURE__ */ i("input", {
|
|
98
|
+
type: "checkbox",
|
|
99
|
+
checked: d.participantIsRegistrant,
|
|
100
|
+
onChange: (e) => m("participantIsRegistrant", e.target.checked),
|
|
101
|
+
className: "mt-0.5 h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)]"
|
|
102
|
+
}), /* @__PURE__ */ a("span", { children: ["I am the athlete", /* @__PURE__ */ i("span", {
|
|
103
|
+
className: "block text-xs text-text-secondary",
|
|
104
|
+
children: "Tick this if you are registering yourself, so the club can add you to the team roster when they accept. Leave it clear when registering a child."
|
|
105
|
+
})] })]
|
|
106
|
+
}),
|
|
95
107
|
/* @__PURE__ */ a("div", {
|
|
96
108
|
className: "grid grid-cols-1 gap-4 sm:grid-cols-3",
|
|
97
109
|
children: [
|
|
@@ -103,7 +115,7 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
103
115
|
id: "contactName",
|
|
104
116
|
className: t,
|
|
105
117
|
value: d.contactName,
|
|
106
|
-
onChange: (e) =>
|
|
118
|
+
onChange: (e) => m("contactName", e.target.value)
|
|
107
119
|
})
|
|
108
120
|
}),
|
|
109
121
|
/* @__PURE__ */ i(e, {
|
|
@@ -114,7 +126,7 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
114
126
|
type: "email",
|
|
115
127
|
className: t,
|
|
116
128
|
value: d.contactEmail,
|
|
117
|
-
onChange: (e) =>
|
|
129
|
+
onChange: (e) => m("contactEmail", e.target.value)
|
|
118
130
|
})
|
|
119
131
|
}),
|
|
120
132
|
/* @__PURE__ */ i(e, {
|
|
@@ -125,7 +137,7 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
125
137
|
type: "tel",
|
|
126
138
|
className: t,
|
|
127
139
|
value: d.contactPhone,
|
|
128
|
-
onChange: (e) =>
|
|
140
|
+
onChange: (e) => m("contactPhone", e.target.value)
|
|
129
141
|
})
|
|
130
142
|
})
|
|
131
143
|
]
|
|
@@ -142,7 +154,7 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
142
154
|
}), s.map((e) => /* @__PURE__ */ i(o, {
|
|
143
155
|
field: e,
|
|
144
156
|
value: d.answers[e.key],
|
|
145
|
-
onChange: (t) =>
|
|
157
|
+
onChange: (t) => m("answers", {
|
|
146
158
|
...d.answers,
|
|
147
159
|
[e.key]: t
|
|
148
160
|
})
|
|
@@ -168,7 +180,7 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
168
180
|
checked: !t || d.optionalFeeIds.includes(e.id),
|
|
169
181
|
disabled: !t,
|
|
170
182
|
"aria-label": `${e.name}${t ? " (optional)" : " (required)"}`,
|
|
171
|
-
onChange: (t) =>
|
|
183
|
+
onChange: (t) => m("optionalFeeIds", t.target.checked ? [...d.optionalFeeIds, e.id] : d.optionalFeeIds.filter((t) => t !== e.id)),
|
|
172
184
|
className: "mt-0.5 h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)] disabled:opacity-60"
|
|
173
185
|
}), /* @__PURE__ */ a("span", { children: [
|
|
174
186
|
e.name,
|
|
@@ -191,7 +203,7 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
191
203
|
children: [/* @__PURE__ */ i("span", { children: "Total due" }), /* @__PURE__ */ i("span", {
|
|
192
204
|
className: "tabular-nums",
|
|
193
205
|
"data-testid": "registration-total",
|
|
194
|
-
children: n(
|
|
206
|
+
children: n(h, l)
|
|
195
207
|
})]
|
|
196
208
|
})]
|
|
197
209
|
})]
|
|
@@ -215,7 +227,7 @@ var o = ({ field: n, value: r, onChange: o }) => {
|
|
|
215
227
|
/* @__PURE__ */ i("input", {
|
|
216
228
|
type: "checkbox",
|
|
217
229
|
checked: d.waiverAccepted,
|
|
218
|
-
onChange: (e) =>
|
|
230
|
+
onChange: (e) => m("waiverAccepted", e.target.checked),
|
|
219
231
|
className: "h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)]"
|
|
220
232
|
}),
|
|
221
233
|
"I have read and accept the waiver",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegistrationEntryFields.js","names":[],"sources":["../../../../src/atheletebridge/components/registration/RegistrationEntryFields.tsx"],"sourcesContent":["/**\n * Registration entry fields (BOFF-4135)\n * @module atheletebridge/components/registration\n *\n * Renders a registration form's participant/contact block, its questions, its\n * fees (REQUIRED always included, OPTIONAL opt-in) and its waiver. Shared by\n * the family-facing share-link page and the staff \"record a registration\"\n * page so both collect exactly what the server validates.\n */\n\nimport type { FC } from 'react';\nimport { FormField, fieldInputClass } from '../form';\nimport { formatMoney } from '../../utils/money';\nimport type {\n AthRegistrationAnswerValue,\n AthRegistrationFee,\n AthRegistrationField,\n} from '../../types/registration';\nimport { type RegistrationEntryState, registrationTotal } from './entryRules';\n\ninterface QuestionInputProps {\n field: AthRegistrationField;\n value: AthRegistrationAnswerValue | undefined;\n onChange: (value: AthRegistrationAnswerValue) => void;\n}\n\nconst QuestionInput: FC<QuestionInputProps> = ({ field, value, onChange }) => {\n const id = `q-${field.key}`;\n if (field.fieldType === 'CHECKBOX') {\n return (\n <label className=\"flex items-start gap-2.5 text-sm text-text-primary\" htmlFor={id}>\n <input\n id={id}\n type=\"checkbox\"\n checked={value === true}\n onChange={(e) => onChange(e.target.checked)}\n className=\"mt-0.5 h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)]\"\n />\n <span>\n {field.label}\n {field.required && <span className=\"ml-0.5 text-status-error-text\">*</span>}\n {field.helpText && (\n <span className=\"block text-xs text-text-secondary\">{field.helpText}</span>\n )}\n </span>\n </label>\n );\n }\n\n const text = value === undefined ? '' : String(value);\n let control;\n if (field.fieldType === 'LONG_TEXT') {\n control = (\n <textarea\n id={id}\n rows={3}\n className={fieldInputClass}\n value={text}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n } else if (field.fieldType === 'SELECT') {\n control = (\n <select\n id={id}\n className={fieldInputClass}\n value={text}\n onChange={(e) => onChange(e.target.value)}\n >\n <option value=\"\">Select…</option>\n {field.options.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </select>\n );\n } else {\n const inputType: Record<string, string> = {\n EMAIL: 'email',\n PHONE: 'tel',\n NUMBER: 'number',\n DATE: 'date',\n };\n control = (\n <input\n id={id}\n type={inputType[field.fieldType] ?? 'text'}\n className={fieldInputClass}\n value={text}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n }\n\n return (\n <FormField\n label={field.label}\n htmlFor={id}\n required={field.required}\n hint={field.helpText ?? undefined}\n >\n {control}\n </FormField>\n );\n};\n\ninterface RegistrationEntryFieldsProps {\n fields: AthRegistrationField[];\n fees: AthRegistrationFee[];\n currency: string;\n waiverText: string | null;\n state: RegistrationEntryState;\n onChange: (next: RegistrationEntryState) => void;\n}\n\nexport const RegistrationEntryFields: FC<RegistrationEntryFieldsProps> = ({\n fields,\n fees,\n currency,\n waiverText,\n state,\n onChange,\n}) => {\n const set = <K extends keyof RegistrationEntryState>(key: K, value: RegistrationEntryState[K]) =>\n onChange({ ...state, [key]: value });\n const total = registrationTotal(fees, state.optionalFeeIds);\n\n return (\n <div className=\"space-y-6\">\n <section className=\"space-y-4\" aria-labelledby=\"reg-participant\">\n <h2 id=\"reg-participant\" className=\"text-base font-semibold text-text-primary\">\n Participant\n </h2>\n <FormField label=\"Participant name\" htmlFor=\"participantName\" required>\n <input\n id=\"participantName\"\n className={fieldInputClass}\n value={state.participantName}\n onChange={(e) => set('participantName', e.target.value)}\n placeholder=\"Athlete's full name\"\n />\n </FormField>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <FormField\n label=\"Contact name\"\n htmlFor=\"contactName\"\n hint=\"Parent or guardian, if applicable.\"\n >\n <input\n id=\"contactName\"\n className={fieldInputClass}\n value={state.contactName}\n onChange={(e) => set('contactName', e.target.value)}\n />\n </FormField>\n <FormField label=\"Contact email\" htmlFor=\"contactEmail\">\n <input\n id=\"contactEmail\"\n type=\"email\"\n className={fieldInputClass}\n value={state.contactEmail}\n onChange={(e) => set('contactEmail', e.target.value)}\n />\n </FormField>\n <FormField label=\"Contact phone\" htmlFor=\"contactPhone\">\n <input\n id=\"contactPhone\"\n type=\"tel\"\n className={fieldInputClass}\n value={state.contactPhone}\n onChange={(e) => set('contactPhone', e.target.value)}\n />\n </FormField>\n </div>\n </section>\n\n {fields.length > 0 && (\n <section className=\"space-y-4\" aria-labelledby=\"reg-questions\">\n <h2 id=\"reg-questions\" className=\"text-base font-semibold text-text-primary\">\n Questions\n </h2>\n {fields.map((field) => (\n <QuestionInput\n key={field.id}\n field={field}\n value={state.answers[field.key]}\n onChange={(value) => set('answers', { ...state.answers, [field.key]: value })}\n />\n ))}\n </section>\n )}\n\n {fees.length > 0 && (\n <section className=\"space-y-3\" aria-labelledby=\"reg-fees\">\n <h2 id=\"reg-fees\" className=\"text-base font-semibold text-text-primary\">\n Fees\n </h2>\n <ul className=\"divide-y divide-border-seam rounded-lg border border-border-seam\">\n {fees.map((fee) => {\n const optional = fee.feeType === 'OPTIONAL';\n const checked = !optional || state.optionalFeeIds.includes(fee.id);\n return (\n <li key={fee.id} className=\"flex items-center justify-between gap-3 px-4 py-3\">\n <label className=\"flex items-start gap-2.5 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={checked}\n disabled={!optional}\n aria-label={`${fee.name}${optional ? ' (optional)' : ' (required)'}`}\n onChange={(e) =>\n set(\n 'optionalFeeIds',\n e.target.checked\n ? [...state.optionalFeeIds, fee.id]\n : state.optionalFeeIds.filter((feeId) => feeId !== fee.id)\n )\n }\n className=\"mt-0.5 h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)] disabled:opacity-60\"\n />\n <span>\n {fee.name}\n <span className=\"ml-1.5 text-xs text-text-secondary\">\n {optional ? 'Optional' : 'Required'}\n </span>\n {fee.description && (\n <span className=\"block text-xs text-text-secondary\">{fee.description}</span>\n )}\n </span>\n </label>\n <span className=\"text-sm font-medium tabular-nums text-text-primary\">\n {formatMoney(fee.amount, currency)}\n </span>\n </li>\n );\n })}\n <li className=\"flex items-center justify-between px-4 py-3 text-sm font-semibold text-text-primary\">\n <span>Total due</span>\n <span className=\"tabular-nums\" data-testid=\"registration-total\">\n {formatMoney(total, currency)}\n </span>\n </li>\n </ul>\n </section>\n )}\n\n {waiverText && (\n <section className=\"space-y-3\" aria-labelledby=\"reg-waiver\">\n <h2 id=\"reg-waiver\" className=\"text-base font-semibold text-text-primary\">\n Waiver\n </h2>\n <p className=\"whitespace-pre-line rounded-lg border border-border-seam bg-bg-sunken p-4 text-sm text-text-secondary\">\n {waiverText}\n </p>\n <label className=\"flex items-center gap-2.5 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={state.waiverAccepted}\n onChange={(e) => set('waiverAccepted', e.target.checked)}\n className=\"h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)]\"\n />\n I have read and accept the waiver\n <span className=\"text-status-error-text\">*</span>\n </label>\n </section>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;AA0BA,IAAM,KAAyC,EAAE,UAAO,UAAO,kBAAe;CAC5E,IAAM,IAAK,KAAK,EAAM;CACtB,IAAI,EAAM,cAAc,YACtB,OACE,kBAAC,SAAD;EAAO,WAAU;EAAqD,SAAS;YAA/E,CACE,kBAAC,SAAD;GACM;GACJ,MAAK;GACL,SAAS,MAAU;GACnB,WAAW,MAAM,EAAS,EAAE,OAAO,OAAO;GAC1C,WAAU;EACX,CAAA,GACD,kBAAC,QAAD,EAAA,UAAA;GACG,EAAM;GACN,EAAM,YAAY,kBAAC,QAAD;IAAM,WAAU;cAAgC;GAAO,CAAA;GACzE,EAAM,YACL,kBAAC,QAAD;IAAM,WAAU;cAAqC,EAAM;GAAe,CAAA;EAExE,EAAA,CAAA,CACD;;CAIX,IAAM,IAAO,MAAU,KAAA,IAAY,KAAK,OAAO,CAAK,GAChD;CA6CJ,OA5CA,AAiCE,IAjCE,EAAM,cAAc,cAEpB,kBAAC,YAAD;EACM;EACJ,MAAM;EACN,WAAW;EACX,OAAO;EACP,WAAW,MAAM,EAAS,EAAE,OAAO,KAAK;CACzC,CAAA,IAEM,EAAM,cAAc,WAE3B,kBAAC,UAAD;EACM;EACJ,WAAW;EACX,OAAO;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gB,EAAI,EAAE,IAChC,EAAM,eAAe,QAAQ,MAAU,MAAU,EAAI,EAAE,CAC7D;SAEF,WAAU;QACX,CAAA,GACD,kBAAC,QAAD,EAAA,UAAA;SACG,EAAI;SACL,kBAAC,QAAD;UAAM,WAAU;oBACb,IAAW,aAAa;SACrB,CAAA;SACL,EAAI,eACH,kBAAC,QAAD;UAAM,WAAU;oBAAqC,EAAI;SAAkB,CAAA;QAEzE,EAAA,CAAA,CACD;WACP,kBAAC,QAAD;QAAM,WAAU;kBACb,EAAY,EAAI,QAAQ,CAAQ;OAC7B,CAAA,CACJ;SA9BK,EAAI,EA8BT;KAER,CAAC,GACD,kBAAC,MAAD;MAAI,WAAU;gBAAd,CACE,kBAAC,QAAD,EAAA,UAAM,YAAe,CAAA,GACrB,kBAAC,QAAD;OAAM,WAAU;OAAe,eAAY;iBACxC,EAAY,GAAO,CAAQ;MACxB,CAAA,CACJ;OACF;MACG;;GAGV,KACC,kBAAC,WAAD;IAAS,WAAU;IAAY,mBAAgB;cAA/C;KACE,kBAAC,MAAD;MAAI,IAAG;MAAa,WAAU;gBAA4C;KAEtE,CAAA;KACJ,kBAAC,KAAD;MAAG,WAAU;gBACV;KACA,CAAA;KACH,kBAAC,SAAD;MAAO,WAAU;gBAAjB;OACE,kBAAC,SAAD;QACE,MAAK;QACL,SAAS,EAAM;QACf,WAAW,MAAM,EAAI,kBAAkB,EAAE,OAAO,OAAO;QACvD,WAAU;OACX,CAAA;OAAC;OAEF,kBAAC,QAAD;QAAM,WAAU;kBAAyB;OAAO,CAAA;MAC3C;;IACA;;EAER;;AAET"}
|
|
1
|
+
{"version":3,"file":"RegistrationEntryFields.js","names":[],"sources":["../../../../src/atheletebridge/components/registration/RegistrationEntryFields.tsx"],"sourcesContent":["/**\n * Registration entry fields (BOFF-4135)\n * @module atheletebridge/components/registration\n *\n * Renders a registration form's participant/contact block, its questions, its\n * fees (REQUIRED always included, OPTIONAL opt-in) and its waiver. Shared by\n * the family-facing share-link page and the staff \"record a registration\"\n * page so both collect exactly what the server validates.\n */\n\nimport type { FC } from 'react';\nimport { FormField, fieldInputClass } from '../form';\nimport { formatMoney } from '../../utils/money';\nimport type {\n AthRegistrationAnswerValue,\n AthRegistrationFee,\n AthRegistrationField,\n} from '../../types/registration';\nimport { type RegistrationEntryState, registrationTotal } from './entryRules';\n\ninterface QuestionInputProps {\n field: AthRegistrationField;\n value: AthRegistrationAnswerValue | undefined;\n onChange: (value: AthRegistrationAnswerValue) => void;\n}\n\nconst QuestionInput: FC<QuestionInputProps> = ({ field, value, onChange }) => {\n const id = `q-${field.key}`;\n if (field.fieldType === 'CHECKBOX') {\n return (\n <label className=\"flex items-start gap-2.5 text-sm text-text-primary\" htmlFor={id}>\n <input\n id={id}\n type=\"checkbox\"\n checked={value === true}\n onChange={(e) => onChange(e.target.checked)}\n className=\"mt-0.5 h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)]\"\n />\n <span>\n {field.label}\n {field.required && <span className=\"ml-0.5 text-status-error-text\">*</span>}\n {field.helpText && (\n <span className=\"block text-xs text-text-secondary\">{field.helpText}</span>\n )}\n </span>\n </label>\n );\n }\n\n const text = value === undefined ? '' : String(value);\n let control;\n if (field.fieldType === 'LONG_TEXT') {\n control = (\n <textarea\n id={id}\n rows={3}\n className={fieldInputClass}\n value={text}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n } else if (field.fieldType === 'SELECT') {\n control = (\n <select\n id={id}\n className={fieldInputClass}\n value={text}\n onChange={(e) => onChange(e.target.value)}\n >\n <option value=\"\">Select…</option>\n {field.options.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </select>\n );\n } else {\n const inputType: Record<string, string> = {\n EMAIL: 'email',\n PHONE: 'tel',\n NUMBER: 'number',\n DATE: 'date',\n };\n control = (\n <input\n id={id}\n type={inputType[field.fieldType] ?? 'text'}\n className={fieldInputClass}\n value={text}\n onChange={(e) => onChange(e.target.value)}\n />\n );\n }\n\n return (\n <FormField\n label={field.label}\n htmlFor={id}\n required={field.required}\n hint={field.helpText ?? undefined}\n >\n {control}\n </FormField>\n );\n};\n\ninterface RegistrationEntryFieldsProps {\n fields: AthRegistrationField[];\n fees: AthRegistrationFee[];\n currency: string;\n waiverText: string | null;\n state: RegistrationEntryState;\n onChange: (next: RegistrationEntryState) => void;\n /**\n * Offer the \"I am the athlete\" choice. Only the family share-link flow sets\n * it: there the signed-in registrant can be the athlete, and saying so lets\n * the club add them to the team roster on acceptance (BOFF-10806).\n */\n offerSelfRegistration?: boolean;\n}\n\nexport const RegistrationEntryFields: FC<RegistrationEntryFieldsProps> = ({\n fields,\n fees,\n currency,\n waiverText,\n state,\n onChange,\n offerSelfRegistration = false,\n}) => {\n const set = <K extends keyof RegistrationEntryState>(key: K, value: RegistrationEntryState[K]) =>\n onChange({ ...state, [key]: value });\n const total = registrationTotal(fees, state.optionalFeeIds);\n\n return (\n <div className=\"space-y-6\">\n <section className=\"space-y-4\" aria-labelledby=\"reg-participant\">\n <h2 id=\"reg-participant\" className=\"text-base font-semibold text-text-primary\">\n Participant\n </h2>\n <FormField label=\"Participant name\" htmlFor=\"participantName\" required>\n <input\n id=\"participantName\"\n className={fieldInputClass}\n value={state.participantName}\n onChange={(e) => set('participantName', e.target.value)}\n placeholder=\"Athlete's full name\"\n />\n </FormField>\n {offerSelfRegistration && (\n <label className=\"flex items-start gap-2.5 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={state.participantIsRegistrant}\n onChange={(e) => set('participantIsRegistrant', e.target.checked)}\n className=\"mt-0.5 h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)]\"\n />\n <span>\n I am the athlete\n <span className=\"block text-xs text-text-secondary\">\n Tick this if you are registering yourself, so the club can add you to the team\n roster when they accept. Leave it clear when registering a child.\n </span>\n </span>\n </label>\n )}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <FormField\n label=\"Contact name\"\n htmlFor=\"contactName\"\n hint=\"Parent or guardian, if applicable.\"\n >\n <input\n id=\"contactName\"\n className={fieldInputClass}\n value={state.contactName}\n onChange={(e) => set('contactName', e.target.value)}\n />\n </FormField>\n <FormField label=\"Contact email\" htmlFor=\"contactEmail\">\n <input\n id=\"contactEmail\"\n type=\"email\"\n className={fieldInputClass}\n value={state.contactEmail}\n onChange={(e) => set('contactEmail', e.target.value)}\n />\n </FormField>\n <FormField label=\"Contact phone\" htmlFor=\"contactPhone\">\n <input\n id=\"contactPhone\"\n type=\"tel\"\n className={fieldInputClass}\n value={state.contactPhone}\n onChange={(e) => set('contactPhone', e.target.value)}\n />\n </FormField>\n </div>\n </section>\n\n {fields.length > 0 && (\n <section className=\"space-y-4\" aria-labelledby=\"reg-questions\">\n <h2 id=\"reg-questions\" className=\"text-base font-semibold text-text-primary\">\n Questions\n </h2>\n {fields.map((field) => (\n <QuestionInput\n key={field.id}\n field={field}\n value={state.answers[field.key]}\n onChange={(value) => set('answers', { ...state.answers, [field.key]: value })}\n />\n ))}\n </section>\n )}\n\n {fees.length > 0 && (\n <section className=\"space-y-3\" aria-labelledby=\"reg-fees\">\n <h2 id=\"reg-fees\" className=\"text-base font-semibold text-text-primary\">\n Fees\n </h2>\n <ul className=\"divide-y divide-border-seam rounded-lg border border-border-seam\">\n {fees.map((fee) => {\n const optional = fee.feeType === 'OPTIONAL';\n const checked = !optional || state.optionalFeeIds.includes(fee.id);\n return (\n <li key={fee.id} className=\"flex items-center justify-between gap-3 px-4 py-3\">\n <label className=\"flex items-start gap-2.5 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={checked}\n disabled={!optional}\n aria-label={`${fee.name}${optional ? ' (optional)' : ' (required)'}`}\n onChange={(e) =>\n set(\n 'optionalFeeIds',\n e.target.checked\n ? [...state.optionalFeeIds, fee.id]\n : state.optionalFeeIds.filter((feeId) => feeId !== fee.id)\n )\n }\n className=\"mt-0.5 h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)] disabled:opacity-60\"\n />\n <span>\n {fee.name}\n <span className=\"ml-1.5 text-xs text-text-secondary\">\n {optional ? 'Optional' : 'Required'}\n </span>\n {fee.description && (\n <span className=\"block text-xs text-text-secondary\">{fee.description}</span>\n )}\n </span>\n </label>\n <span className=\"text-sm font-medium tabular-nums text-text-primary\">\n {formatMoney(fee.amount, currency)}\n </span>\n </li>\n );\n })}\n <li className=\"flex items-center justify-between px-4 py-3 text-sm font-semibold text-text-primary\">\n <span>Total due</span>\n <span className=\"tabular-nums\" data-testid=\"registration-total\">\n {formatMoney(total, currency)}\n </span>\n </li>\n </ul>\n </section>\n )}\n\n {waiverText && (\n <section className=\"space-y-3\" aria-labelledby=\"reg-waiver\">\n <h2 id=\"reg-waiver\" className=\"text-base font-semibold text-text-primary\">\n Waiver\n </h2>\n <p className=\"whitespace-pre-line rounded-lg border border-border-seam bg-bg-sunken p-4 text-sm text-text-secondary\">\n {waiverText}\n </p>\n <label className=\"flex items-center gap-2.5 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={state.waiverAccepted}\n onChange={(e) => set('waiverAccepted', e.target.checked)}\n className=\"h-4 w-4 rounded border-border-seam text-action-primary-bg focus:ring-[var(--color-focus-ring)]\"\n />\n I have read and accept the waiver\n <span className=\"text-status-error-text\">*</span>\n </label>\n </section>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;AA0BA,IAAM,KAAyC,EAAE,UAAO,UAAO,kBAAe;CAC5E,IAAM,IAAK,KAAK,EAAM;CACtB,IAAI,EAAM,cAAc,YACtB,OACE,kBAAC,SAAD;EAAO,WAAU;EAAqD,SAAS;YAA/E,CACE,kBAAC,SAAD;GACM;GACJ,MAAK;GACL,SAAS,MAAU;GACnB,WAAW,MAAM,EAAS,EAAE,OAAO,OAAO;GAC1C,WAAU;EACX,CAAA,GACD,kBAAC,QAAD,EAAA,UAAA;GACG,EAAM;GACN,EAAM,YAAY,kBAAC,QAAD;IAAM,WAAU;cAAgC;GAAO,CAAA;GACzE,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G;;GAGV,KACC,kBAAC,WAAD;IAAS,WAAU;IAAY,mBAAgB;cAA/C;KACE,kBAAC,MAAD;MAAI,IAAG;MAAa,WAAU;gBAA4C;KAEtE,CAAA;KACJ,kBAAC,KAAD;MAAG,WAAU;gBACV;KACA,CAAA;KACH,kBAAC,SAAD;MAAO,WAAU;gBAAjB;OACE,kBAAC,SAAD;QACE,MAAK;QACL,SAAS,EAAM;QACf,WAAW,MAAM,EAAI,kBAAkB,EAAE,OAAO,OAAO;QACvD,WAAU;OACX,CAAA;OAAC;OAEF,kBAAC,QAAD;QAAM,WAAU;kBAAyB;OAAO,CAAA;MAC3C;;IACA;;EAER;;AAET"}
|
|
@@ -8,6 +8,8 @@ export interface RegistrationEntryState {
|
|
|
8
8
|
answers: Record<string, AthRegistrationAnswerValue>;
|
|
9
9
|
optionalFeeIds: string[];
|
|
10
10
|
waiverAccepted: boolean;
|
|
11
|
+
/** Self-service only: the signed-in registrant is the athlete (BOFF-10806). */
|
|
12
|
+
participantIsRegistrant: boolean;
|
|
11
13
|
}
|
|
12
14
|
export declare const EMPTY_REGISTRATION_ENTRY: RegistrationEntryState;
|
|
13
15
|
/** Total due for the current fee selection, in minor units. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entryRules.d.ts","sourceRoot":"","sources":["../../../../src/atheletebridge/components/registration/entryRules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IACpD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"entryRules.d.ts","sourceRoot":"","sources":["../../../../src/atheletebridge/components/registration/entryRules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IACpD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,+EAA+E;IAC/E,uBAAuB,EAAE,OAAO,CAAC;CAClC;AAED,eAAO,MAAM,wBAAwB,EAAE,sBAStC,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,CAI9F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,EAAE,EAC9B,KAAK,EAAE,sBAAsB,GAC5B,MAAM,GAAG,IAAI,CAcf;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,GAClD,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAM5C"}
|
|
@@ -6,7 +6,8 @@ var e = {
|
|
|
6
6
|
contactPhone: "",
|
|
7
7
|
answers: {},
|
|
8
8
|
optionalFeeIds: [],
|
|
9
|
-
waiverAccepted: !1
|
|
9
|
+
waiverAccepted: !1,
|
|
10
|
+
participantIsRegistrant: !1
|
|
10
11
|
};
|
|
11
12
|
function t(e, t) {
|
|
12
13
|
return e.filter((e) => e.feeType === "REQUIRED" || t.includes(e.id)).reduce((e, t) => e + t.amount, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entryRules.js","names":[],"sources":["../../../../src/atheletebridge/components/registration/entryRules.ts"],"sourcesContent":["/**\n * Pure rules for the registration entry form (BOFF-4135).\n * @module atheletebridge/components/registration\n */\n\nimport type {\n AthRegistrationAnswerValue,\n AthRegistrationFee,\n AthRegistrationField,\n} from '../../types/registration';\n\nexport interface RegistrationEntryState {\n participantName: string;\n contactName: string;\n contactEmail: string;\n contactPhone: string;\n answers: Record<string, AthRegistrationAnswerValue>;\n optionalFeeIds: string[];\n waiverAccepted: boolean;\n}\n\nexport const EMPTY_REGISTRATION_ENTRY: RegistrationEntryState = {\n participantName: '',\n contactName: '',\n contactEmail: '',\n contactPhone: '',\n answers: {},\n optionalFeeIds: [],\n waiverAccepted: false,\n};\n\n/** Total due for the current fee selection, in minor units. */\nexport function registrationTotal(fees: AthRegistrationFee[], optionalFeeIds: string[]): number {\n return fees\n .filter((fee) => fee.feeType === 'REQUIRED' || optionalFeeIds.includes(fee.id))\n .reduce((total, fee) => total + fee.amount, 0);\n}\n\n/**\n * Client-side pre-check mirroring the server's required-answer rule, so the\n * family sees what is missing before a round trip. The server stays the\n * authority on every rule.\n */\nexport function missingRequiredAnswer(\n fields: AthRegistrationField[],\n state: RegistrationEntryState\n): string | null {\n if (!state.participantName.trim()) return 'Participant name';\n for (const field of fields) {\n if (!field.required) continue;\n const value = state.answers[field.key];\n if (\n field.fieldType === 'CHECKBOX'\n ? value !== true\n : value === undefined || String(value).trim() === ''\n ) {\n return field.label;\n }\n }\n return null;\n}\n\n/** Strip blank answers so optional unanswered questions are simply omitted. */\nexport function cleanAnswers(\n answers: Record<string, AthRegistrationAnswerValue>\n): Record<string, AthRegistrationAnswerValue> {\n return Object.fromEntries(\n Object.entries(answers).filter(\n ([, value]) => !(typeof value === 'string' && value.trim() === '')\n )\n );\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"entryRules.js","names":[],"sources":["../../../../src/atheletebridge/components/registration/entryRules.ts"],"sourcesContent":["/**\n * Pure rules for the registration entry form (BOFF-4135).\n * @module atheletebridge/components/registration\n */\n\nimport type {\n AthRegistrationAnswerValue,\n AthRegistrationFee,\n AthRegistrationField,\n} from '../../types/registration';\n\nexport interface RegistrationEntryState {\n participantName: string;\n contactName: string;\n contactEmail: string;\n contactPhone: string;\n answers: Record<string, AthRegistrationAnswerValue>;\n optionalFeeIds: string[];\n waiverAccepted: boolean;\n /** Self-service only: the signed-in registrant is the athlete (BOFF-10806). */\n participantIsRegistrant: boolean;\n}\n\nexport const EMPTY_REGISTRATION_ENTRY: RegistrationEntryState = {\n participantName: '',\n contactName: '',\n contactEmail: '',\n contactPhone: '',\n answers: {},\n optionalFeeIds: [],\n waiverAccepted: false,\n participantIsRegistrant: false,\n};\n\n/** Total due for the current fee selection, in minor units. */\nexport function registrationTotal(fees: AthRegistrationFee[], optionalFeeIds: string[]): number {\n return fees\n .filter((fee) => fee.feeType === 'REQUIRED' || optionalFeeIds.includes(fee.id))\n .reduce((total, fee) => total + fee.amount, 0);\n}\n\n/**\n * Client-side pre-check mirroring the server's required-answer rule, so the\n * family sees what is missing before a round trip. The server stays the\n * authority on every rule.\n */\nexport function missingRequiredAnswer(\n fields: AthRegistrationField[],\n state: RegistrationEntryState\n): string | null {\n if (!state.participantName.trim()) return 'Participant name';\n for (const field of fields) {\n if (!field.required) continue;\n const value = state.answers[field.key];\n if (\n field.fieldType === 'CHECKBOX'\n ? value !== true\n : value === undefined || String(value).trim() === ''\n ) {\n return field.label;\n }\n }\n return null;\n}\n\n/** Strip blank answers so optional unanswered questions are simply omitted. */\nexport function cleanAnswers(\n answers: Record<string, AthRegistrationAnswerValue>\n): Record<string, AthRegistrationAnswerValue> {\n return Object.fromEntries(\n Object.entries(answers).filter(\n ([, value]) => !(typeof value === 'string' && value.trim() === '')\n )\n );\n}\n"],"mappings":";AAuBA,IAAa,IAAmD;CAC9D,iBAAiB;CACjB,aAAa;CACb,cAAc;CACd,cAAc;CACd,SAAS,CAAC;CACV,gBAAgB,CAAC;CACjB,gBAAgB;CAChB,yBAAyB;AAC3B;AAGA,SAAgB,EAAkB,GAA4B,GAAkC;CAC9F,OAAO,EACJ,QAAQ,MAAQ,EAAI,YAAY,cAAc,EAAe,SAAS,EAAI,EAAE,CAAC,EAC7E,QAAQ,GAAO,MAAQ,IAAQ,EAAI,QAAQ,CAAC;AACjD;AAOA,SAAgB,EACd,GACA,GACe;CACf,IAAI,CAAC,EAAM,gBAAgB,KAAK,GAAG,OAAO;CAC1C,KAAK,IAAM,KAAS,GAAQ;EAC1B,IAAI,CAAC,EAAM,UAAU;EACrB,IAAM,IAAQ,EAAM,QAAQ,EAAM;EAClC,IACE,EAAM,cAAc,aAChB,MAAU,KACV,MAAU,KAAA,KAAa,OAAO,CAAK,EAAE,KAAK,MAAM,IAEpD,OAAO,EAAM;CAEjB;CACA,OAAO;AACT;AAGA,SAAgB,EACd,GAC4C;CAC5C,OAAO,OAAO,YACZ,OAAO,QAAQ,CAAO,EAAE,QACrB,GAAG,OAAW,EAAE,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,GACjE,CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PaginationInput } from '../types';
|
|
2
|
-
import { AthCreateRegistrationFormInput, AthMyRegistration, AthMyRegistrationConnection, AthPublicRegistrationForm, AthRecordRegistrationInput, AthRecordRegistrationPaymentInput,
|
|
2
|
+
import { AthCreateRegistrationFormInput, AthMyRegistration, AthMyRegistrationConnection, AthOnlinePaymentsStatus, AthPaymentAccount, AthPaymentAccountLink, AthPublicRegistrationForm, AthRecordRegistrationInput, AthRecordRegistrationPaymentInput, AthRegistrationCheckoutSession, AthRegistrationDecision, AthRegistrationForm, AthRegistrationFormConnection, AthRegistrationFormStatus, AthRegistrationPayment, AthRegistrationPaymentStatus, AthRegistrationPaymentSummary, AthRegistrationSubmission, AthRegistrationSubmissionConnection, AthRegistrationSubmissionStatus, AthSubmitRegistrationInput, AthUpdateRegistrationFormInput } from '../types/registration';
|
|
3
3
|
|
|
4
4
|
export interface RegistrationFormFilters {
|
|
5
5
|
status?: AthRegistrationFormStatus;
|
|
@@ -44,11 +44,28 @@ export declare const useRefundRegistrationPayment: () => import('@tanstack/react
|
|
|
44
44
|
amount: number;
|
|
45
45
|
reason: string;
|
|
46
46
|
}, unknown>;
|
|
47
|
+
export declare const useOnlinePaymentsStatus: () => import('@tanstack/react-query').UseQueryResult<NoInfer<AthOnlinePaymentsStatus>, Error>;
|
|
48
|
+
/**
|
|
49
|
+
* Create (first call) or resume the club's processor onboarding. Resolves to
|
|
50
|
+
* the hosted onboarding link; the caller redirects the browser to it.
|
|
51
|
+
*/
|
|
52
|
+
export declare const useConnectPaymentAccount: () => import('@tanstack/react-query').UseMutationResult<AthPaymentAccountLink, Error, {
|
|
53
|
+
returnUrl: string;
|
|
54
|
+
email?: string;
|
|
55
|
+
}, unknown>;
|
|
56
|
+
export declare const useRefreshPaymentAccount: () => import('@tanstack/react-query').UseMutationResult<AthPaymentAccount, Error, void, unknown>;
|
|
47
57
|
export declare const usePublicRegistrationForm: (slug: string | undefined) => import('@tanstack/react-query').UseQueryResult<NoInfer<AthPublicRegistrationForm | null>, Error>;
|
|
48
58
|
export declare const useSubmitRegistration: () => import('@tanstack/react-query').UseMutationResult<AthMyRegistration, Error, {
|
|
49
59
|
slug: string;
|
|
50
|
-
input:
|
|
60
|
+
input: AthSubmitRegistrationInput;
|
|
51
61
|
}, unknown>;
|
|
52
62
|
export declare const useMyRegistrations: (pagination?: PaginationInput) => import('@tanstack/react-query').UseQueryResult<NoInfer<AthMyRegistrationConnection>, Error>;
|
|
53
63
|
export declare const useWithdrawMyRegistration: () => import('@tanstack/react-query').UseMutationResult<AthMyRegistration, Error, string, unknown>;
|
|
64
|
+
/** Open a processor checkout for the outstanding balance of one of your registrations. */
|
|
65
|
+
export declare const useStartRegistrationCheckout: () => import('@tanstack/react-query').UseMutationResult<AthRegistrationCheckoutSession, Error, {
|
|
66
|
+
submissionId: string;
|
|
67
|
+
returnUrl: string;
|
|
68
|
+
}, unknown>;
|
|
69
|
+
/** Settle a checkout after the processor sends the family back (the server re-reads it). */
|
|
70
|
+
export declare const useConfirmRegistrationCheckout: () => import('@tanstack/react-query').UseMutationResult<AthMyRegistration, Error, string, unknown>;
|
|
54
71
|
//# sourceMappingURL=useRegistrationApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRegistrationApi.d.ts","sourceRoot":"","sources":["../../../src/atheletebridge/hooks/useRegistrationApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EACV,8BAA8B,EAC9B,iBAAiB,EACjB,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,iCAAiC,EACjC,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"useRegistrationApi.d.ts","sourceRoot":"","sources":["../../../src/atheletebridge/hooks/useRegistrationApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EACV,8BAA8B,EAC9B,iBAAiB,EACjB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,iCAAiC,EACjC,8BAA8B,EAC9B,uBAAuB,EACvB,mBAAmB,EACnB,6BAA6B,EAC7B,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,EAC7B,yBAAyB,EACzB,mCAAmC,EACnC,+BAA+B,EAC/B,0BAA0B,EAC1B,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAkE/B,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,yBAAyB,CAAC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