@burdenoff/microfe-eventfullymanaged 2026.1124.2 → 2026.1124.3

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.
@@ -0,0 +1,6 @@
1
+ type DeliveryScope = {
2
+ eventId: string;
3
+ certificateId: string;
4
+ };
5
+ export declare function CertificateEmailControls({ eventId, certificateId }: DeliveryScope): import('react').JSX.Element;
6
+ export {};
@@ -0,0 +1,141 @@
1
+ import { CombinedGraphQLErrors as e } from "../../../node_modules/@apollo/client/errors/CombinedGraphQLErrors.js";
2
+ import { useEventLatestCertificateEmailQuery as t, useQueueEventCertificateEmailMutation as n } from "../../../generated/wspace-operations.js";
3
+ import { useTr as r } from "../../../shared/hooks/useTr.js";
4
+ import { notify as i } from "../../lib/toast.js";
5
+ import { formatDateTime as a } from "../events/eventFormUtils.js";
6
+ import { useRef as o, useState as s } from "react";
7
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
8
+ import { Button as d, Dialog as f, DialogContent as p, DialogDescription as m, DialogHeader as h, DialogTitle as g } from "@burdenoff/fe-libs/ui";
9
+ // src/eventfullymanaged/pages/certificates/CertificateEmailControls.tsx
10
+ function _({ eventId: e, certificateId: n }) {
11
+ let a = r(), [o, c] = s(null), f = t({
12
+ variables: {
13
+ eventId: e,
14
+ certificateId: n
15
+ },
16
+ fetchPolicy: "no-cache",
17
+ notifyOnNetworkStatusChange: !0
18
+ }), p = o ?? f.data?.eventfullyManagedLatestCertificateEmailDelivery ?? null, m = async () => {
19
+ try {
20
+ let e = await f.refetch();
21
+ if (e.error || !e.data) throw Error("Email status was not confirmed.");
22
+ c(null);
23
+ } catch {
24
+ i.error(a("eventfullymanaged.certificates.emailStatusError", "Could not refresh the certificate email status."));
25
+ }
26
+ };
27
+ return /* @__PURE__ */ u("section", {
28
+ className: "space-y-2 border-t border-border-seam pt-3",
29
+ children: [
30
+ /* @__PURE__ */ l("h4", {
31
+ className: "font-medium",
32
+ children: a("eventfullymanaged.certificates.emailTitle", "Certificate email")
33
+ }),
34
+ p ? /* @__PURE__ */ l(v, { delivery: p }) : null,
35
+ f.loading ? /* @__PURE__ */ l("p", {
36
+ role: "status",
37
+ children: a("eventfullymanaged.certificates.emailStatusLoading", "Checking email status…")
38
+ }) : null,
39
+ f.error ? /* @__PURE__ */ l("p", {
40
+ role: "alert",
41
+ className: "text-status-error-text",
42
+ children: a("eventfullymanaged.certificates.emailStatusError", "Could not refresh the certificate email status.")
43
+ }) : null,
44
+ /* @__PURE__ */ u("div", {
45
+ className: "flex flex-wrap gap-2",
46
+ children: [/* @__PURE__ */ l(y, {
47
+ eventId: e,
48
+ certificateId: n,
49
+ previous: p,
50
+ disabled: f.loading || !!f.error,
51
+ onQueued: c
52
+ }), /* @__PURE__ */ l(d, {
53
+ type: "button",
54
+ variant: "outline",
55
+ disabled: f.loading,
56
+ onClick: () => void m(),
57
+ children: a("eventfullymanaged.certificates.emailRefresh", "Refresh email status")
58
+ })]
59
+ })
60
+ ]
61
+ });
62
+ }
63
+ function v({ delivery: e }) {
64
+ let t = r();
65
+ return /* @__PURE__ */ u("div", {
66
+ className: "space-y-1 text-sm",
67
+ "aria-live": "polite",
68
+ children: [
69
+ /* @__PURE__ */ l("p", { children: t("eventfullymanaged.certificates.emailStatus", "Request status: {{status}}", { status: e.status }) }),
70
+ e.channelStatus ? /* @__PURE__ */ l("p", { children: t("eventfullymanaged.certificates.emailChannelStatus", "Email provider status: {{status}}", { status: e.channelStatus }) }) : null,
71
+ /* @__PURE__ */ l("p", { children: t("eventfullymanaged.certificates.emailRequestedAt", "Requested {{date}}", { date: a(e.createdAt) }) })
72
+ ]
73
+ });
74
+ }
75
+ function y({ eventId: t, certificateId: i, previous: a, disabled: _, onQueued: v }) {
76
+ let y = r(), [b, x] = s(!1), [S, C] = s(), w = o(null), [T, { loading: E }] = n({ refetchQueries: ["EventLatestCertificateEmail"] }), D = a?.status === "pending" || a?.status === "submitting", O = a ? y("eventfullymanaged.certificates.emailResend", "Re-send certificate email") : y("eventfullymanaged.certificates.emailSend", "Email certificate"), k = () => {
77
+ w.current?.previousDeliveryId !== (a?.id ?? null) && (w.current = null, C(void 0)), x(!0);
78
+ }, A = async () => {
79
+ if (!(E || D || _)) {
80
+ C(void 0);
81
+ try {
82
+ w.current ??= {
83
+ id: crypto.randomUUID(),
84
+ previousDeliveryId: a?.id ?? null
85
+ };
86
+ let e = await T({ variables: {
87
+ eventId: t,
88
+ certificateId: i,
89
+ requestId: w.current.id
90
+ } }), n = e.data?.eventfullyManagedQueueCertificateEmail;
91
+ if (e.error) throw e.error;
92
+ if (!n?.id) throw Error("Email request was not confirmed.");
93
+ w.current = null, v(n), x(!1);
94
+ } catch (t) {
95
+ let n = e.is(t) && t.errors.some(({ extensions: e }) => e?.code === "CONFLICT");
96
+ C(n ? y("eventfullymanaged.certificates.emailBindingError", "The original attendee binding is unavailable for this receipt. Download the PDF from the receipt.") : y("eventfullymanaged.certificates.emailQueueError", "Could not confirm the email request. Retry the same request."));
97
+ }
98
+ }
99
+ };
100
+ return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(d, {
101
+ type: "button",
102
+ disabled: _ || D,
103
+ onClick: k,
104
+ children: O
105
+ }), /* @__PURE__ */ l(f, {
106
+ open: b,
107
+ onOpenChange: (e) => {
108
+ E || x(e);
109
+ },
110
+ children: /* @__PURE__ */ u(p, { children: [
111
+ /* @__PURE__ */ u(h, { children: [/* @__PURE__ */ l(g, { children: O }), /* @__PURE__ */ l(m, { children: y("eventfullymanaged.certificates.emailHelp", "Queue the issued PDF for the email address on the attendee registration.") })] }),
112
+ a?.status === "unknown" ? /* @__PURE__ */ l("p", {
113
+ className: "text-sm",
114
+ children: y("eventfullymanaged.certificates.emailUnknown", "The previous request has no confirmed outcome. A second request may send another copy.")
115
+ }) : null,
116
+ S ? /* @__PURE__ */ l("p", {
117
+ role: "alert",
118
+ className: "text-status-error-text",
119
+ children: S
120
+ }) : null,
121
+ /* @__PURE__ */ u("div", {
122
+ className: "flex flex-wrap justify-end gap-2",
123
+ children: [/* @__PURE__ */ l(d, {
124
+ type: "button",
125
+ variant: "outline",
126
+ disabled: E,
127
+ onClick: () => x(!1),
128
+ children: y("eventfullymanaged.certificates.cancel", "Cancel")
129
+ }), /* @__PURE__ */ l(d, {
130
+ type: "button",
131
+ disabled: E || _ || D,
132
+ onClick: () => void A(),
133
+ children: E ? y("eventfullymanaged.certificates.emailQueueing", "Queueing…") : y("eventfullymanaged.certificates.emailConfirm", "Queue email")
134
+ })]
135
+ })
136
+ ] })
137
+ })] });
138
+ }
139
+ export { _ as CertificateEmailControls };
140
+
141
+ //# sourceMappingURL=CertificateEmailControls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CertificateEmailControls.js","names":["_Fragment","CertificateEmailControls","tr","useTr","queued","setQueued","useState","latest","useEventLatestCertificateEmailQuery","delivery","refresh","result","CertificateEmailStatus","CertificateEmailRequest","Button","formatDateTime","open","setOpen","errorMessage","setErrorMessage","request","useRef","queue","useQueueEventCertificateEmailMutation","sending","previous","label","openConfirmation","submit","disabled","onQueued","error","missingBinding","CombinedGraphQLErrors","extensions","Fragment","Dialog","loading","next","DialogContent","DialogHeader","DialogTitle","DialogDescription"],"sources":["../../../../src/eventfullymanaged/pages/certificates/CertificateEmailControls.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { CombinedGraphQLErrors } from '@apollo/client/errors';\nimport { Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@burdenoff/fe-libs/ui';\nimport {\n useEventLatestCertificateEmailQuery,\n useQueueEventCertificateEmailMutation,\n type EventCertificateEmailFieldsFragment,\n} from '../../../generated/wspace-operations';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { notify } from '../../lib/toast';\nimport { formatDateTime } from '../events/eventFormUtils';\n\ntype Delivery = EventCertificateEmailFieldsFragment;\ntype DeliveryScope = { eventId: string; certificateId: string };\n\nexport function CertificateEmailControls({ eventId, certificateId }: DeliveryScope) {\n const tr = useTr();\n const [queued, setQueued] = useState<Delivery | null>(null);\n const latest = useEventLatestCertificateEmailQuery({\n variables: { eventId, certificateId },\n fetchPolicy: 'no-cache',\n notifyOnNetworkStatusChange: true,\n });\n const delivery: Delivery | null = queued ?? latest.data?.eventfullyManagedLatestCertificateEmailDelivery ?? null;\n\n const refresh = async () => {\n try {\n const result = await latest.refetch();\n if (result.error || !result.data) throw new Error('Email status was not confirmed.');\n setQueued(null);\n } catch {\n notify.error(\n tr('eventfullymanaged.certificates.emailStatusError', 'Could not refresh the certificate email status.')\n );\n }\n };\n\n return (\n <section className=\"space-y-2 border-t border-border-seam pt-3\">\n <h4 className=\"font-medium\">{tr('eventfullymanaged.certificates.emailTitle', 'Certificate email')}</h4>\n {delivery ? <CertificateEmailStatus delivery={delivery} /> : null}\n {latest.loading ? (\n <p role=\"status\">{tr('eventfullymanaged.certificates.emailStatusLoading', 'Checking email status…')}</p>\n ) : null}\n {latest.error ? (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr('eventfullymanaged.certificates.emailStatusError', 'Could not refresh the certificate email status.')}\n </p>\n ) : null}\n <div className=\"flex flex-wrap gap-2\">\n <CertificateEmailRequest\n eventId={eventId}\n certificateId={certificateId}\n previous={delivery}\n disabled={latest.loading || Boolean(latest.error)}\n onQueued={setQueued}\n />\n <Button type=\"button\" variant=\"outline\" disabled={latest.loading} onClick={() => void refresh()}>\n {tr('eventfullymanaged.certificates.emailRefresh', 'Refresh email status')}\n </Button>\n </div>\n </section>\n );\n}\n\nfunction CertificateEmailStatus({ delivery }: { delivery: Delivery }) {\n const tr = useTr();\n return (\n <div className=\"space-y-1 text-sm\" aria-live=\"polite\">\n <p>\n {tr('eventfullymanaged.certificates.emailStatus', 'Request status: {{status}}', { status: delivery.status })}\n </p>\n {delivery.channelStatus ? (\n <p>\n {tr('eventfullymanaged.certificates.emailChannelStatus', 'Email provider status: {{status}}', {\n status: delivery.channelStatus,\n })}\n </p>\n ) : null}\n <p>\n {tr('eventfullymanaged.certificates.emailRequestedAt', 'Requested {{date}}', {\n date: formatDateTime(delivery.createdAt),\n })}\n </p>\n </div>\n );\n}\n\nfunction CertificateEmailRequest({\n eventId,\n certificateId,\n previous,\n disabled,\n onQueued,\n}: DeliveryScope & {\n previous: Delivery | null;\n disabled: boolean;\n onQueued: (delivery: Delivery) => void;\n}) {\n const tr = useTr();\n const [open, setOpen] = useState(false);\n const [errorMessage, setErrorMessage] = useState<string>();\n const request = useRef<{ id: string; previousDeliveryId: string | null } | null>(null);\n const [queue, { loading }] = useQueueEventCertificateEmailMutation({\n refetchQueries: ['EventLatestCertificateEmail'],\n });\n const sending = previous?.status === 'pending' || previous?.status === 'submitting';\n const label = previous\n ? tr('eventfullymanaged.certificates.emailResend', 'Re-send certificate email')\n : tr('eventfullymanaged.certificates.emailSend', 'Email certificate');\n\n const openConfirmation = () => {\n if (request.current?.previousDeliveryId !== (previous?.id ?? null)) {\n request.current = null;\n setErrorMessage(undefined);\n }\n setOpen(true);\n };\n\n const submit = async () => {\n if (loading || sending || disabled) return;\n setErrorMessage(undefined);\n try {\n request.current ??= { id: crypto.randomUUID(), previousDeliveryId: previous?.id ?? null };\n const result = await queue({ variables: { eventId, certificateId, requestId: request.current.id } });\n const delivery = result.data?.eventfullyManagedQueueCertificateEmail;\n if (result.error) throw result.error;\n if (!delivery?.id) throw new Error('Email request was not confirmed.');\n request.current = null;\n onQueued(delivery);\n setOpen(false);\n } catch (error) {\n const missingBinding =\n CombinedGraphQLErrors.is(error) && error.errors.some(({ extensions }) => extensions?.code === 'CONFLICT');\n setErrorMessage(\n missingBinding\n ? tr(\n 'eventfullymanaged.certificates.emailBindingError',\n 'The original attendee binding is unavailable for this receipt. Download the PDF from the receipt.'\n )\n : tr(\n 'eventfullymanaged.certificates.emailQueueError',\n 'Could not confirm the email request. Retry the same request.'\n )\n );\n }\n };\n\n return (\n <>\n <Button type=\"button\" disabled={disabled || sending} onClick={openConfirmation}>\n {label}\n </Button>\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!loading) setOpen(next);\n }}\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{label}</DialogTitle>\n <DialogDescription>\n {tr(\n 'eventfullymanaged.certificates.emailHelp',\n 'Queue the issued PDF for the email address on the attendee registration.'\n )}\n </DialogDescription>\n </DialogHeader>\n {previous?.status === 'unknown' ? (\n <p className=\"text-sm\">\n {tr(\n 'eventfullymanaged.certificates.emailUnknown',\n 'The previous request has no confirmed outcome. A second request may send another copy.'\n )}\n </p>\n ) : null}\n {errorMessage ? (\n <p role=\"alert\" className=\"text-status-error-text\">\n {errorMessage}\n </p>\n ) : null}\n <div className=\"flex flex-wrap justify-end gap-2\">\n <Button type=\"button\" variant=\"outline\" disabled={loading} onClick={() => setOpen(false)}>\n {tr('eventfullymanaged.certificates.cancel', 'Cancel')}\n </Button>\n <Button type=\"button\" disabled={loading || disabled || sending} onClick={() => void submit()}>\n {loading\n ? tr('eventfullymanaged.certificates.emailQueueing', 'Queueing…')\n : tr('eventfullymanaged.certificates.emailConfirm', 'Queue email')}\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgBC,EAAyB,EAAE,YAAS,oBAAgC;CAClF,IAAMC,IAAKC,EAAM,GACX,CAACC,GAAQC,KAAaC,EAA0B,IAAI,GACpDC,IAASC,EAAoC;EACjD,WAAW;GAAE;GAAS;EAAc;EACpC,aAAa;EACb,6BAA6B;CAC/B,CAAC,GACKC,IAA4BL,KAAUG,EAAO,MAAM,mDAAmD,MAEtGG,IAAU,YAAY;EAC1B,IAAI;GACF,IAAMC,IAAS,MAAMJ,EAAO,QAAQ;GACpC,IAAII,EAAO,SAAS,CAACA,EAAO,MAAM,MAAU,MAAM,iCAAiC;GACnF,EAAU,IAAI;EAChB,QAAQ;GACN,EAAO,MACLT,EAAG,mDAAmD,iDAAiD,CACzG;EACF;CACF;CAEA,OACE,kBAAC,WAAD;EAAS,WAAU;EAA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pB,EAAQqB,CAAI;EAC5B;EAEA,UAAA,kBAACC,GAAD,EAAA,UAAA;GACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAcf,EAAmB,CAAA,GACjC,kBAACgB,GAAD,EAAA,UACGxC,EACC,4CACA,0EACF,EACiB,CAAA,CACP,EAAA,CAAA;GACbuB,GAAU,WAAW,YACpB,kBAAC,KAAD;IAAG,WAAU;IACV,UAAAvB,EACC,+CACA,wFACF;GACC,CAAA,IACD;GACHgB,IACC,kBAAC,KAAD;IAAG,MAAK;IAAQ,WAAU;IACvB,UAAAA;GACA,CAAA,IACD;GACJ,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAACJ,GAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,UAAUuB;KAAS,eAAepB,EAAQ,EAAK;KACpF,UAAAf,EAAG,yCAAyC,QAAQ;IAC/C,CAAA,GACR,kBAACY,GAAD;KAAQ,MAAK;KAAS,UAAUuB,KAAWR,KAAYL;KAAS,eAAe,KAAKI,EAAO;KACxF,UAAAS,IACGnC,EAAG,gDAAgD,WAAW,IAC9DA,EAAG,+CAA+C,aAAa;IAC7D,CAAA,CACL;;EACQ,EAAA,CAAA;CACT,CAAA,CACR,EAAA,CAAA;AAEN"}
@@ -5,36 +5,38 @@ import { mutationSucceeded as s } from "../../lib/mutationResult.js";
5
5
  import { notify as c } from "../../lib/toast.js";
6
6
  import { formatDateTime as l } from "../events/eventFormUtils.js";
7
7
  import { CertificatePdfDownload as u } from "./CertificatePdfDownload.js";
8
- import { useId as d, useState as f } from "react";
9
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
10
- import { Button as h, Input as g, Label as _ } from "@burdenoff/fe-libs/ui";
8
+ import { CertificateEmailControls as d } from "./CertificateEmailControls.js";
9
+ import { CertificateReceiptSearch as f } from "./CertificateReceiptSearch.js";
10
+ import { useId as p, useState as m } from "react";
11
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
12
+ import { Button as _, Input as v, Label as y } from "@burdenoff/fe-libs/ui";
11
13
  // src/eventfullymanaged/pages/certificates/CertificateIssuance.tsx
12
- var v = "min-h-10 w-full rounded-input border border-border-default bg-bg-surface px-3 py-2 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus", y = "space-y-4 rounded-card border border-border-seam bg-bg-surface p-4";
13
- function b({ eventId: t, templates: l }) {
14
- let u = i(), g = d(), b = o(), S = n({
14
+ var b = "min-h-10 w-full rounded-input border border-border-default bg-bg-surface px-3 py-2 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus", x = "space-y-4 rounded-card border border-border-seam bg-bg-surface p-4";
15
+ function S({ eventId: t, templates: l }) {
16
+ let u = i(), d = p(), v = o(), S = n({
15
17
  variables: {
16
18
  eventId: t,
17
- limit: b.limit,
18
- offset: b.offset
19
+ limit: v.limit,
20
+ offset: v.offset
19
21
  },
20
22
  fetchPolicy: "no-cache"
21
- }), w = S.data?.eventfullyManagedRegistrations, [T, E] = f(""), [D, O] = f(""), [k, A] = f(null), [j, M] = f(null), [N, { loading: P }] = e({ fetchPolicy: "no-cache" }), [F, { loading: I }] = r(), L = l.find((e) => e.id === D), R = w?.items.find((e) => e.id === T), z = JSON.stringify([
23
+ }), w = S.data?.eventfullyManagedRegistrations, [E, D] = m(""), [O, k] = m(""), [A, j] = m(null), [M, N] = m(null), [P, { loading: F }] = e({ fetchPolicy: "no-cache" }), [I, { loading: L }] = r(), R = l.find((e) => e.id === O), z = w?.items.find((e) => e.id === E), B = JSON.stringify([
24
+ z?.id,
22
25
  R?.id,
23
- L?.id,
24
- L?.revision,
25
- L?.requiredSessionIds
26
- ]), B = k?.key === z ? k.result : void 0, V = P || I, H = u("eventfullymanaged.certificates.issuanceError", "Could not confirm certificate issuance"), U = async () => {
27
- if (L && R && !V) {
28
- A(null);
26
+ R?.revision,
27
+ R?.requiredSessionIds
28
+ ]), V = A?.key === B ? A.result : void 0, H = M?.key === B ? M.value : null, U = F || L, W = u("eventfullymanaged.certificates.issuanceError", "Could not confirm certificate issuance"), G = async () => {
29
+ if (R && z && !U) {
30
+ j(null);
29
31
  try {
30
- let e = await N({ variables: {
32
+ let e = await P({ variables: {
31
33
  eventId: t,
32
- registrationId: R.id,
33
- requiredSessionIds: L.requiredSessionIds
34
+ registrationId: z.id,
35
+ requiredSessionIds: R.requiredSessionIds
34
36
  } });
35
37
  if (e.error || !e.data?.eventfullyManagedCertificateEligibility) throw Error("Eligibility not confirmed");
36
- A({
37
- key: z,
38
+ j({
39
+ key: B,
38
40
  result: e.data.eventfullyManagedCertificateEligibility
39
41
  });
40
42
  } catch {
@@ -42,70 +44,73 @@ function b({ eventId: t, templates: l }) {
42
44
  }
43
45
  }
44
46
  };
45
- return /* @__PURE__ */ p("form", {
46
- className: y,
47
+ return /* @__PURE__ */ h("form", {
48
+ className: x,
47
49
  onSubmit: async (e) => {
48
- if (e.preventDefault(), L && R && B?.eligible && !V) try {
49
- let e = await F({ variables: {
50
+ if (e.preventDefault(), R && z && V?.eligible && !U) try {
51
+ let e = await I({ variables: {
50
52
  eventId: t,
51
- registrationId: R.id,
52
- templateId: L.id
53
+ registrationId: z.id,
54
+ templateId: R.id
53
55
  } }), n = e.data?.eventfullyManagedIssueCertificate;
54
- if (!s(e, n?.id, H) || !n) return;
55
- M(n);
56
+ if (!s(e, n?.id, W) || !n) return;
57
+ N({
58
+ key: B,
59
+ value: n
60
+ });
56
61
  } catch {
57
- c.error(H);
62
+ c.error(W);
58
63
  }
59
64
  },
60
- children: /* @__PURE__ */ m("fieldset", {
61
- disabled: V,
65
+ children: /* @__PURE__ */ g("fieldset", {
66
+ disabled: U,
62
67
  className: "space-y-4",
63
68
  children: [
64
- /* @__PURE__ */ p("legend", {
69
+ /* @__PURE__ */ h("legend", {
65
70
  className: "mb-3 text-lg font-semibold",
66
71
  children: u("eventfullymanaged.certificates.manualIssue", "Issue a certificate")
67
72
  }),
68
- /* @__PURE__ */ m("div", {
73
+ /* @__PURE__ */ g("div", {
69
74
  className: "space-y-1.5",
70
- children: [/* @__PURE__ */ p(_, {
71
- id: g + "templateLabel",
72
- htmlFor: g + "template",
75
+ children: [/* @__PURE__ */ h(y, {
76
+ id: d + "templateLabel",
77
+ htmlFor: d + "template",
73
78
  children: u("eventfullymanaged.certificates.template", "Certificate template")
74
- }), /* @__PURE__ */ m("select", {
75
- id: g + "template",
76
- "aria-labelledby": g + "templateLabel",
77
- className: v,
78
- value: L?.id ?? "",
79
+ }), /* @__PURE__ */ g("select", {
80
+ id: d + "template",
81
+ "aria-labelledby": d + "templateLabel",
82
+ className: b,
83
+ value: R?.id ?? "",
79
84
  onChange: (e) => {
80
- O(e.target.value), A(null);
85
+ k(e.target.value), j(null);
81
86
  },
82
- children: [/* @__PURE__ */ p("option", {
87
+ children: [/* @__PURE__ */ h("option", {
83
88
  value: "",
84
89
  children: u("eventfullymanaged.certificates.chooseTemplate", "Choose a template")
85
- }), l.map((e) => /* @__PURE__ */ p("option", {
90
+ }), l.map((e) => /* @__PURE__ */ h("option", {
86
91
  value: e.id,
87
92
  children: e.title
88
93
  }, e.id))]
89
94
  })]
90
95
  }),
91
- /* @__PURE__ */ m("div", {
96
+ /* @__PURE__ */ g("div", {
92
97
  className: "space-y-1.5",
93
- children: [/* @__PURE__ */ p(_, {
94
- id: g + "registrationLabel",
95
- htmlFor: g + "registration",
98
+ children: [/* @__PURE__ */ h(y, {
99
+ id: d + "registrationLabel",
100
+ htmlFor: d + "registration",
96
101
  children: u("eventfullymanaged.certificates.registration", "Attendee registration")
97
- }), /* @__PURE__ */ m("select", {
98
- id: g + "registration",
99
- "aria-labelledby": g + "registrationLabel",
100
- className: v,
101
- value: R?.id ?? "",
102
+ }), /* @__PURE__ */ g("select", {
103
+ id: d + "registration",
104
+ "aria-labelledby": d + "registrationLabel",
105
+ className: b,
106
+ value: z?.id ?? "",
102
107
  onChange: (e) => {
103
- E(e.target.value), A(null);
108
+ D(e.target.value), j(null);
104
109
  },
105
- children: [/* @__PURE__ */ p("option", {
110
+ children: [/* @__PURE__ */ h("option", {
106
111
  value: "",
107
112
  children: u("eventfullymanaged.certificates.chooseRegistration", "Choose a registration")
108
- }), w?.items.map((e) => /* @__PURE__ */ m("option", {
113
+ }), w?.items.map((e) => /* @__PURE__ */ g("option", {
109
114
  value: e.id,
110
115
  children: [
111
116
  e.attendeeName || e.id,
@@ -115,13 +120,13 @@ function b({ eventId: t, templates: l }) {
115
120
  }, e.id))]
116
121
  })]
117
122
  }),
118
- S.error ? /* @__PURE__ */ m("p", {
123
+ S.error ? /* @__PURE__ */ g("p", {
119
124
  role: "alert",
120
125
  className: "text-sm text-status-error-text",
121
126
  children: [
122
127
  u("eventfullymanaged.certificates.registrationsError", "Could not load registrations."),
123
128
  " ",
124
- /* @__PURE__ */ p(h, {
129
+ /* @__PURE__ */ h(_, {
125
130
  type: "button",
126
131
  variant: "outline",
127
132
  onClick: () => void S.refetch().catch(() => void 0),
@@ -129,63 +134,73 @@ function b({ eventId: t, templates: l }) {
129
134
  })
130
135
  ]
131
136
  }) : null,
132
- w ? /* @__PURE__ */ p(a, {
133
- offset: b.offset,
134
- limit: b.limit,
137
+ w ? /* @__PURE__ */ h(a, {
138
+ offset: v.offset,
139
+ limit: v.limit,
135
140
  total: w.total,
136
141
  loadedCount: w.items.length,
137
- onPrev: b.prevPage,
138
- onNext: b.nextPage,
142
+ onPrev: v.prevPage,
143
+ onNext: v.nextPage,
139
144
  loading: S.loading,
140
145
  itemLabel: "registrations"
141
146
  }) : null,
142
- /* @__PURE__ */ m("div", {
147
+ /* @__PURE__ */ g("div", {
143
148
  className: "flex flex-wrap gap-2",
144
- children: [/* @__PURE__ */ p(h, {
149
+ children: [/* @__PURE__ */ h(_, {
145
150
  type: "button",
146
151
  variant: "outline",
147
- disabled: !L || !R,
148
- onClick: () => void U(),
149
- children: P ? u("eventfullymanaged.certificates.checking", "Checking…") : u("eventfullymanaged.certificates.checkEligibility", "Check eligibility")
150
- }), /* @__PURE__ */ p(h, {
152
+ disabled: !R || !z,
153
+ onClick: () => void G(),
154
+ children: F ? u("eventfullymanaged.certificates.checking", "Checking…") : u("eventfullymanaged.certificates.checkEligibility", "Check eligibility")
155
+ }), /* @__PURE__ */ h(_, {
151
156
  type: "submit",
152
- disabled: !B?.eligible,
153
- children: I ? u("eventfullymanaged.certificates.issuing", "Issuing…") : u("eventfullymanaged.certificates.issue", "Issue certificate")
157
+ disabled: !V?.eligible,
158
+ children: L ? u("eventfullymanaged.certificates.issuing", "Issuing…") : u("eventfullymanaged.certificates.issue", "Issue certificate")
154
159
  })]
155
160
  }),
156
- /* @__PURE__ */ p(x, { eligibility: B }),
157
- /* @__PURE__ */ p(C, {
161
+ /* @__PURE__ */ h(C, { eligibility: V }),
162
+ /* @__PURE__ */ h(f, {
163
+ eventId: t,
164
+ registrationId: z?.id,
165
+ templateId: R?.id,
166
+ disabled: U,
167
+ onFound: (e) => N(e ? {
168
+ key: B,
169
+ value: e
170
+ } : null)
171
+ }, B),
172
+ /* @__PURE__ */ h(T, {
158
173
  eventId: t,
159
- receipt: j
174
+ receipt: H
160
175
  })
161
176
  ]
162
177
  })
163
178
  });
164
179
  }
165
- function x({ eligibility: e }) {
180
+ function C({ eligibility: e }) {
166
181
  let t = i();
167
- return e ? e.eligible ? /* @__PURE__ */ p("p", {
182
+ return e ? e.eligible ? /* @__PURE__ */ h("p", {
168
183
  className: "text-sm",
169
184
  "aria-live": "polite",
170
185
  children: t("eventfullymanaged.certificates.eligible", "Eligible for this certificate.")
171
- }) : /* @__PURE__ */ p("p", {
186
+ }) : /* @__PURE__ */ h("p", {
172
187
  className: "text-sm",
173
188
  "aria-live": "polite",
174
189
  children: e.registrationEligible ? t("eventfullymanaged.certificates.sessionsIneligible", "Required sessions without completed attendance: {{count}}.", { count: e.missingSessionIds.length }) : t("eventfullymanaged.certificates.registrationIneligible", "The registration must be confirmed or checked in.")
175
190
  }) : null;
176
191
  }
177
- function S({ eventId: e }) {
178
- let n = i(), r = d(), [a, o] = f(null), [s, { loading: l }] = t({ fetchPolicy: "no-cache" });
179
- return /* @__PURE__ */ m("section", {
180
- className: y,
192
+ function w({ eventId: e }) {
193
+ let n = i(), r = p(), [a, o] = m(null), [s, { loading: l }] = t({ fetchPolicy: "no-cache" });
194
+ return /* @__PURE__ */ g("section", {
195
+ className: x,
181
196
  "aria-labelledby": r + "receiptHeading",
182
197
  children: [
183
- /* @__PURE__ */ p("h2", {
198
+ /* @__PURE__ */ h("h2", {
184
199
  id: r + "receiptHeading",
185
200
  className: "text-lg font-semibold",
186
201
  children: n("eventfullymanaged.certificates.issuedReceipt", "Issuance receipt")
187
202
  }),
188
- /* @__PURE__ */ m("form", {
203
+ /* @__PURE__ */ g("form", {
189
204
  className: "space-y-2",
190
205
  onSubmit: async (t) => {
191
206
  t.preventDefault();
@@ -204,18 +219,20 @@ function S({ eventId: e }) {
204
219
  }
205
220
  }
206
221
  },
207
- children: [/* @__PURE__ */ p(_, {
222
+ children: [/* @__PURE__ */ h(y, {
208
223
  htmlFor: r + "receipt",
209
224
  children: n("eventfullymanaged.certificates.receiptId", "Receipt ID")
210
- }), /* @__PURE__ */ m("div", {
225
+ }), /* @__PURE__ */ g("div", {
211
226
  className: "flex flex-wrap items-center gap-2",
212
- children: [/* @__PURE__ */ p(g, {
227
+ children: [/* @__PURE__ */ h(v, {
213
228
  id: r + "receipt",
214
229
  name: "receiptId",
215
230
  className: "flex-1",
216
231
  maxLength: 128,
232
+ disabled: l,
233
+ onChange: () => o(null),
217
234
  required: !0
218
- }), /* @__PURE__ */ p(h, {
235
+ }), /* @__PURE__ */ h(_, {
219
236
  type: "submit",
220
237
  variant: "outline",
221
238
  disabled: l,
@@ -223,42 +240,46 @@ function S({ eventId: e }) {
223
240
  })]
224
241
  })]
225
242
  }),
226
- /* @__PURE__ */ p(C, {
243
+ /* @__PURE__ */ h(T, {
227
244
  eventId: e,
228
245
  receipt: a
229
246
  })
230
247
  ]
231
248
  });
232
249
  }
233
- function C({ eventId: e, receipt: t }) {
250
+ function T({ eventId: e, receipt: t }) {
234
251
  let n = i();
235
- return t ? /* @__PURE__ */ m("div", {
252
+ return t ? /* @__PURE__ */ g("div", {
236
253
  "aria-live": "polite",
237
254
  className: "space-y-2 rounded-card border border-border-seam p-3 text-sm",
238
255
  children: [
239
- /* @__PURE__ */ p("h3", {
256
+ /* @__PURE__ */ h("h3", {
240
257
  className: "font-medium break-words",
241
258
  children: t.title
242
259
  }),
243
- /* @__PURE__ */ p("p", { children: n("eventfullymanaged.certificates.receiptIssuedAt", "Issued {{date}}", { date: l(t.issuedAt) }) }),
244
- /* @__PURE__ */ p("p", { children: n("eventfullymanaged.certificates.receiptTemplateRevision", "Template revision {{revision}}", { revision: t.templateRevision }) }),
245
- /* @__PURE__ */ p("p", {
260
+ /* @__PURE__ */ h("p", { children: n("eventfullymanaged.certificates.receiptIssuedAt", "Issued {{date}}", { date: l(t.issuedAt) }) }),
261
+ /* @__PURE__ */ h("p", { children: n("eventfullymanaged.certificates.receiptTemplateRevision", "Template revision {{revision}}", { revision: t.templateRevision }) }),
262
+ /* @__PURE__ */ h("p", {
246
263
  className: "break-all text-text-secondary",
247
264
  children: t.id
248
265
  }),
249
- /* @__PURE__ */ p(u, {
266
+ /* @__PURE__ */ h(u, {
250
267
  eventId: e,
251
268
  receiptId: t.id
252
- })
269
+ }),
270
+ /* @__PURE__ */ h(d, {
271
+ eventId: e,
272
+ certificateId: t.id
273
+ }, t.id)
253
274
  ]
254
275
  }) : null;
255
276
  }
256
- function w(e) {
257
- return /* @__PURE__ */ m("div", {
277
+ function E(e) {
278
+ return /* @__PURE__ */ g("div", {
258
279
  className: "grid gap-4 lg:grid-cols-2",
259
- children: [/* @__PURE__ */ p(b, { ...e }), /* @__PURE__ */ p(S, { eventId: e.eventId })]
280
+ children: [/* @__PURE__ */ h(S, { ...e }), /* @__PURE__ */ h(w, { eventId: e.eventId })]
260
281
  });
261
282
  }
262
- export { w as CertificateIssuance };
283
+ export { E as CertificateIssuance };
263
284
 
264
285
  //# sourceMappingURL=CertificateIssuance.js.map