@burdenoff/microfe-eventfullymanaged 2026.1124.1 → 2026.1124.2

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.
@@ -4,25 +4,26 @@ import { Pagination as a, usePagination as o } from "../../components/Pagination
4
4
  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
- import { useId as u, useState as d } from "react";
8
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
9
- import { Button as m, Input as h, Label as g } from "@burdenoff/fe-libs/ui";
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";
10
11
  // src/eventfullymanaged/pages/certificates/CertificateIssuance.tsx
11
- var _ = "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", v = "space-y-4 rounded-card border border-border-seam bg-bg-surface p-4";
12
- function y({ eventId: t, templates: l }) {
13
- let h = i(), y = u(), x = o(), C = n({
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
15
  variables: {
15
16
  eventId: t,
16
- limit: x.limit,
17
- offset: x.offset
17
+ limit: b.limit,
18
+ offset: b.offset
18
19
  },
19
20
  fetchPolicy: "no-cache"
20
- }), w = C.data?.eventfullyManagedRegistrations, [T, E] = d(""), [D, O] = d(""), [k, A] = d(null), [j, M] = d(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([
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([
21
22
  R?.id,
22
23
  L?.id,
23
24
  L?.revision,
24
25
  L?.requiredSessionIds
25
- ]), B = k?.key === z ? k.result : void 0, V = P || I, H = h("eventfullymanaged.certificates.issuanceError", "Could not confirm certificate issuance"), U = async () => {
26
+ ]), B = k?.key === z ? k.result : void 0, V = P || I, H = u("eventfullymanaged.certificates.issuanceError", "Could not confirm certificate issuance"), U = async () => {
26
27
  if (L && R && !V) {
27
28
  A(null);
28
29
  try {
@@ -37,12 +38,12 @@ function y({ eventId: t, templates: l }) {
37
38
  result: e.data.eventfullyManagedCertificateEligibility
38
39
  });
39
40
  } catch {
40
- c.error(h("eventfullymanaged.certificates.eligibilityError", "Could not confirm attendance eligibility"));
41
+ c.error(u("eventfullymanaged.certificates.eligibilityError", "Could not confirm attendance eligibility"));
41
42
  }
42
43
  }
43
44
  };
44
- return /* @__PURE__ */ f("form", {
45
- className: v,
45
+ return /* @__PURE__ */ p("form", {
46
+ className: y,
46
47
  onSubmit: async (e) => {
47
48
  if (e.preventDefault(), L && R && B?.eligible && !V) try {
48
49
  let e = await F({ variables: {
@@ -56,55 +57,55 @@ function y({ eventId: t, templates: l }) {
56
57
  c.error(H);
57
58
  }
58
59
  },
59
- children: /* @__PURE__ */ p("fieldset", {
60
+ children: /* @__PURE__ */ m("fieldset", {
60
61
  disabled: V,
61
62
  className: "space-y-4",
62
63
  children: [
63
- /* @__PURE__ */ f("legend", {
64
+ /* @__PURE__ */ p("legend", {
64
65
  className: "mb-3 text-lg font-semibold",
65
- children: h("eventfullymanaged.certificates.manualIssue", "Issue a certificate")
66
+ children: u("eventfullymanaged.certificates.manualIssue", "Issue a certificate")
66
67
  }),
67
- /* @__PURE__ */ p("div", {
68
+ /* @__PURE__ */ m("div", {
68
69
  className: "space-y-1.5",
69
- children: [/* @__PURE__ */ f(g, {
70
- id: y + "templateLabel",
71
- htmlFor: y + "template",
72
- children: h("eventfullymanaged.certificates.template", "Certificate template")
73
- }), /* @__PURE__ */ p("select", {
74
- id: y + "template",
75
- "aria-labelledby": y + "templateLabel",
76
- className: _,
70
+ children: [/* @__PURE__ */ p(_, {
71
+ id: g + "templateLabel",
72
+ htmlFor: g + "template",
73
+ children: u("eventfullymanaged.certificates.template", "Certificate template")
74
+ }), /* @__PURE__ */ m("select", {
75
+ id: g + "template",
76
+ "aria-labelledby": g + "templateLabel",
77
+ className: v,
77
78
  value: L?.id ?? "",
78
79
  onChange: (e) => {
79
80
  O(e.target.value), A(null);
80
81
  },
81
- children: [/* @__PURE__ */ f("option", {
82
+ children: [/* @__PURE__ */ p("option", {
82
83
  value: "",
83
- children: h("eventfullymanaged.certificates.chooseTemplate", "Choose a template")
84
- }), l.map((e) => /* @__PURE__ */ f("option", {
84
+ children: u("eventfullymanaged.certificates.chooseTemplate", "Choose a template")
85
+ }), l.map((e) => /* @__PURE__ */ p("option", {
85
86
  value: e.id,
86
87
  children: e.title
87
88
  }, e.id))]
88
89
  })]
89
90
  }),
90
- /* @__PURE__ */ p("div", {
91
+ /* @__PURE__ */ m("div", {
91
92
  className: "space-y-1.5",
92
- children: [/* @__PURE__ */ f(g, {
93
- id: y + "registrationLabel",
94
- htmlFor: y + "registration",
95
- children: h("eventfullymanaged.certificates.registration", "Attendee registration")
96
- }), /* @__PURE__ */ p("select", {
97
- id: y + "registration",
98
- "aria-labelledby": y + "registrationLabel",
99
- className: _,
93
+ children: [/* @__PURE__ */ p(_, {
94
+ id: g + "registrationLabel",
95
+ htmlFor: g + "registration",
96
+ children: u("eventfullymanaged.certificates.registration", "Attendee registration")
97
+ }), /* @__PURE__ */ m("select", {
98
+ id: g + "registration",
99
+ "aria-labelledby": g + "registrationLabel",
100
+ className: v,
100
101
  value: R?.id ?? "",
101
102
  onChange: (e) => {
102
103
  E(e.target.value), A(null);
103
104
  },
104
- children: [/* @__PURE__ */ f("option", {
105
+ children: [/* @__PURE__ */ p("option", {
105
106
  value: "",
106
- children: h("eventfullymanaged.certificates.chooseRegistration", "Choose a registration")
107
- }), w?.items.map((e) => /* @__PURE__ */ p("option", {
107
+ children: u("eventfullymanaged.certificates.chooseRegistration", "Choose a registration")
108
+ }), w?.items.map((e) => /* @__PURE__ */ m("option", {
108
109
  value: e.id,
109
110
  children: [
110
111
  e.attendeeName || e.id,
@@ -114,74 +115,77 @@ function y({ eventId: t, templates: l }) {
114
115
  }, e.id))]
115
116
  })]
116
117
  }),
117
- C.error ? /* @__PURE__ */ p("p", {
118
+ S.error ? /* @__PURE__ */ m("p", {
118
119
  role: "alert",
119
120
  className: "text-sm text-status-error-text",
120
121
  children: [
121
- h("eventfullymanaged.certificates.registrationsError", "Could not load registrations."),
122
+ u("eventfullymanaged.certificates.registrationsError", "Could not load registrations."),
122
123
  " ",
123
- /* @__PURE__ */ f(m, {
124
+ /* @__PURE__ */ p(h, {
124
125
  type: "button",
125
126
  variant: "outline",
126
- onClick: () => void C.refetch().catch(() => void 0),
127
- children: h("eventfullymanaged.certificates.retry", "Retry")
127
+ onClick: () => void S.refetch().catch(() => void 0),
128
+ children: u("eventfullymanaged.certificates.retry", "Retry")
128
129
  })
129
130
  ]
130
131
  }) : null,
131
- w ? /* @__PURE__ */ f(a, {
132
- offset: x.offset,
133
- limit: x.limit,
132
+ w ? /* @__PURE__ */ p(a, {
133
+ offset: b.offset,
134
+ limit: b.limit,
134
135
  total: w.total,
135
136
  loadedCount: w.items.length,
136
- onPrev: x.prevPage,
137
- onNext: x.nextPage,
138
- loading: C.loading,
137
+ onPrev: b.prevPage,
138
+ onNext: b.nextPage,
139
+ loading: S.loading,
139
140
  itemLabel: "registrations"
140
141
  }) : null,
141
- /* @__PURE__ */ p("div", {
142
+ /* @__PURE__ */ m("div", {
142
143
  className: "flex flex-wrap gap-2",
143
- children: [/* @__PURE__ */ f(m, {
144
+ children: [/* @__PURE__ */ p(h, {
144
145
  type: "button",
145
146
  variant: "outline",
146
147
  disabled: !L || !R,
147
148
  onClick: () => void U(),
148
- children: P ? h("eventfullymanaged.certificates.checking", "Checking…") : h("eventfullymanaged.certificates.checkEligibility", "Check eligibility")
149
- }), /* @__PURE__ */ f(m, {
149
+ children: P ? u("eventfullymanaged.certificates.checking", "Checking…") : u("eventfullymanaged.certificates.checkEligibility", "Check eligibility")
150
+ }), /* @__PURE__ */ p(h, {
150
151
  type: "submit",
151
152
  disabled: !B?.eligible,
152
- children: I ? h("eventfullymanaged.certificates.issuing", "Issuing…") : h("eventfullymanaged.certificates.issue", "Issue certificate")
153
+ children: I ? u("eventfullymanaged.certificates.issuing", "Issuing…") : u("eventfullymanaged.certificates.issue", "Issue certificate")
153
154
  })]
154
155
  }),
155
- /* @__PURE__ */ f(b, { eligibility: B }),
156
- /* @__PURE__ */ f(S, { receipt: j })
156
+ /* @__PURE__ */ p(x, { eligibility: B }),
157
+ /* @__PURE__ */ p(C, {
158
+ eventId: t,
159
+ receipt: j
160
+ })
157
161
  ]
158
162
  })
159
163
  });
160
164
  }
161
- function b({ eligibility: e }) {
165
+ function x({ eligibility: e }) {
162
166
  let t = i();
163
- return e ? e.eligible ? /* @__PURE__ */ f("p", {
167
+ return e ? e.eligible ? /* @__PURE__ */ p("p", {
164
168
  className: "text-sm",
165
169
  "aria-live": "polite",
166
170
  children: t("eventfullymanaged.certificates.eligible", "Eligible for this certificate.")
167
- }) : /* @__PURE__ */ f("p", {
171
+ }) : /* @__PURE__ */ p("p", {
168
172
  className: "text-sm",
169
173
  "aria-live": "polite",
170
174
  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.")
171
175
  }) : null;
172
176
  }
173
- function x({ eventId: e }) {
174
- let n = i(), r = u(), [a, o] = d(null), [s, { loading: l }] = t({ fetchPolicy: "no-cache" });
175
- return /* @__PURE__ */ p("section", {
176
- className: v,
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,
177
181
  "aria-labelledby": r + "receiptHeading",
178
182
  children: [
179
- /* @__PURE__ */ f("h2", {
183
+ /* @__PURE__ */ p("h2", {
180
184
  id: r + "receiptHeading",
181
185
  className: "text-lg font-semibold",
182
186
  children: n("eventfullymanaged.certificates.issuedReceipt", "Issuance receipt")
183
187
  }),
184
- /* @__PURE__ */ p("form", {
188
+ /* @__PURE__ */ m("form", {
185
189
  className: "space-y-2",
186
190
  onSubmit: async (t) => {
187
191
  t.preventDefault();
@@ -200,18 +204,18 @@ function x({ eventId: e }) {
200
204
  }
201
205
  }
202
206
  },
203
- children: [/* @__PURE__ */ f(g, {
207
+ children: [/* @__PURE__ */ p(_, {
204
208
  htmlFor: r + "receipt",
205
209
  children: n("eventfullymanaged.certificates.receiptId", "Receipt ID")
206
- }), /* @__PURE__ */ p("div", {
210
+ }), /* @__PURE__ */ m("div", {
207
211
  className: "flex flex-wrap items-center gap-2",
208
- children: [/* @__PURE__ */ f(h, {
212
+ children: [/* @__PURE__ */ p(g, {
209
213
  id: r + "receipt",
210
214
  name: "receiptId",
211
215
  className: "flex-1",
212
216
  maxLength: 128,
213
217
  required: !0
214
- }), /* @__PURE__ */ f(m, {
218
+ }), /* @__PURE__ */ p(h, {
215
219
  type: "submit",
216
220
  variant: "outline",
217
221
  disabled: l,
@@ -219,35 +223,42 @@ function x({ eventId: e }) {
219
223
  })]
220
224
  })]
221
225
  }),
222
- /* @__PURE__ */ f(S, { receipt: a })
226
+ /* @__PURE__ */ p(C, {
227
+ eventId: e,
228
+ receipt: a
229
+ })
223
230
  ]
224
231
  });
225
232
  }
226
- function S({ receipt: e }) {
227
- let t = i();
228
- return e ? /* @__PURE__ */ p("div", {
233
+ function C({ eventId: e, receipt: t }) {
234
+ let n = i();
235
+ return t ? /* @__PURE__ */ m("div", {
229
236
  "aria-live": "polite",
230
237
  className: "space-y-2 rounded-card border border-border-seam p-3 text-sm",
231
238
  children: [
232
- /* @__PURE__ */ f("h3", {
239
+ /* @__PURE__ */ p("h3", {
233
240
  className: "font-medium break-words",
234
- children: e.title
241
+ children: t.title
235
242
  }),
236
- /* @__PURE__ */ f("p", { children: t("eventfullymanaged.certificates.receiptIssuedAt", "Issued {{date}}", { date: l(e.issuedAt) }) }),
237
- /* @__PURE__ */ f("p", { children: t("eventfullymanaged.certificates.receiptTemplateRevision", "Template revision {{revision}}", { revision: e.templateRevision }) }),
238
- /* @__PURE__ */ f("p", {
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", {
239
246
  className: "break-all text-text-secondary",
240
- children: e.id
247
+ children: t.id
248
+ }),
249
+ /* @__PURE__ */ p(u, {
250
+ eventId: e,
251
+ receiptId: t.id
241
252
  })
242
253
  ]
243
254
  }) : null;
244
255
  }
245
- function C(e) {
246
- return /* @__PURE__ */ p("div", {
256
+ function w(e) {
257
+ return /* @__PURE__ */ m("div", {
247
258
  className: "grid gap-4 lg:grid-cols-2",
248
- children: [/* @__PURE__ */ f(y, { ...e }), /* @__PURE__ */ f(x, { eventId: e.eventId })]
259
+ children: [/* @__PURE__ */ p(b, { ...e }), /* @__PURE__ */ p(S, { eventId: e.eventId })]
249
260
  });
250
261
  }
251
- export { C as CertificateIssuance };
262
+ export { w as CertificateIssuance };
252
263
 
253
264
  //# sourceMappingURL=CertificateIssuance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CertificateIssuance.js","names":["selectClass","cardClass","CertificateIssueForm","tr","useTr","id","useId","paging","usePagination","registrations","useEventCertificateRegistrationsQuery","registrationPage","registrationId","setRegistrationId","useState","templateId","setTemplateId","checked","setChecked","receipt","setReceipt","readEligibility","checking","useEventCertificateEligibilityLazyQuery","issueCertificate","issuing","useIssueEventCertificateMutation","template","templates","item","registration","checkKey","eligibility","busy","issueError","check","result","event","issued","mutationSucceeded","Label","Button","Pagination","AttendanceOutcome","CertificateReceiptDetails","CertificateReceiptLookup","findReceipt","finding","useEventCertificateReceiptLazyQuery","receiptId","Input","formatDateTime","CertificateIssuance","props"],"sources":["../../../../src/eventfullymanaged/pages/certificates/CertificateIssuance.tsx"],"sourcesContent":["import { useId, useState, type FormEvent } from 'react';\nimport { Button, Input, Label } from '@burdenoff/fe-libs/ui';\nimport {\n useEventCertificateEligibilityLazyQuery,\n useEventCertificateReceiptLazyQuery,\n useEventCertificateRegistrationsQuery,\n useIssueEventCertificateMutation,\n type EventCertificateEligibilityQuery,\n type EventCertificateReceiptFieldsFragment,\n type EventCertificateRegistrationsQuery,\n type EventCertificateTemplateFieldsFragment,\n} from '../../../generated/wspace-operations';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { Pagination, usePagination } from '../../components/Pagination';\nimport { mutationSucceeded } from '../../lib/mutationResult';\nimport { notify } from '../../lib/toast';\nimport { formatDateTime } from '../events/eventFormUtils';\n\nconst selectClass =\n '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';\nconst cardClass = 'space-y-4 rounded-card border border-border-seam bg-bg-surface p-4';\n\ntype Eligibility = EventCertificateEligibilityQuery['eventfullyManagedCertificateEligibility'];\ntype Receipt = EventCertificateReceiptFieldsFragment;\n\ntype IssuanceProps = {\n eventId: string;\n templates: EventCertificateTemplateFieldsFragment[];\n};\n\nfunction CertificateIssueForm({ eventId, templates }: IssuanceProps) {\n const tr = useTr();\n const id = useId();\n const paging = usePagination();\n const registrations = useEventCertificateRegistrationsQuery({\n variables: { eventId, limit: paging.limit, offset: paging.offset },\n fetchPolicy: 'no-cache',\n });\n const registrationPage: EventCertificateRegistrationsQuery['eventfullyManagedRegistrations'] | undefined =\n registrations.data?.eventfullyManagedRegistrations;\n const [registrationId, setRegistrationId] = useState('');\n const [templateId, setTemplateId] = useState('');\n const [checked, setChecked] = useState<{ key: string; result: Eligibility } | null>(null);\n const [receipt, setReceipt] = useState<Receipt | null>(null);\n const [readEligibility, { loading: checking }] = useEventCertificateEligibilityLazyQuery({ fetchPolicy: 'no-cache' });\n const [issueCertificate, { loading: issuing }] = useIssueEventCertificateMutation();\n const template = templates.find((item) => item.id === templateId);\n const registration = registrationPage?.items.find((item) => item.id === registrationId);\n const checkKey = JSON.stringify([registration?.id, template?.id, template?.revision, template?.requiredSessionIds]);\n const eligibility = checked?.key === checkKey ? checked.result : undefined;\n const busy = checking || issuing;\n const issueError = tr('eventfullymanaged.certificates.issuanceError', 'Could not confirm certificate issuance');\n\n const check = async () => {\n if (!template || !registration || busy) return;\n setChecked(null);\n try {\n const result = await readEligibility({\n variables: { eventId, registrationId: registration.id, requiredSessionIds: template.requiredSessionIds },\n });\n if (result.error || !result.data?.eventfullyManagedCertificateEligibility)\n throw new Error('Eligibility not confirmed');\n setChecked({ key: checkKey, result: result.data.eventfullyManagedCertificateEligibility });\n } catch {\n notify.error(tr('eventfullymanaged.certificates.eligibilityError', 'Could not confirm attendance eligibility'));\n }\n };\n\n const issue = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (!template || !registration || !eligibility?.eligible || busy) return;\n try {\n const result = await issueCertificate({\n variables: { eventId, registrationId: registration.id, templateId: template.id },\n });\n const issued = result.data?.eventfullyManagedIssueCertificate;\n if (!mutationSucceeded(result, issued?.id, issueError) || !issued) return;\n setReceipt(issued);\n } catch {\n notify.error(issueError);\n }\n };\n\n return (\n <form className={cardClass} onSubmit={issue}>\n <fieldset disabled={busy} className=\"space-y-4\">\n <legend className=\"mb-3 text-lg font-semibold\">\n {tr('eventfullymanaged.certificates.manualIssue', 'Issue a certificate')}\n </legend>\n <div className=\"space-y-1.5\">\n <Label id={id + 'templateLabel'} htmlFor={id + 'template'}>\n {tr('eventfullymanaged.certificates.template', 'Certificate template')}\n </Label>\n <select\n id={id + 'template'}\n aria-labelledby={id + 'templateLabel'}\n className={selectClass}\n value={template?.id ?? ''}\n onChange={(event) => {\n setTemplateId(event.target.value);\n setChecked(null);\n }}\n >\n <option value=\"\">{tr('eventfullymanaged.certificates.chooseTemplate', 'Choose a template')}</option>\n {templates.map((item) => (\n <option key={item.id} value={item.id}>\n {item.title}\n </option>\n ))}\n </select>\n </div>\n <div className=\"space-y-1.5\">\n <Label id={id + 'registrationLabel'} htmlFor={id + 'registration'}>\n {tr('eventfullymanaged.certificates.registration', 'Attendee registration')}\n </Label>\n <select\n id={id + 'registration'}\n aria-labelledby={id + 'registrationLabel'}\n className={selectClass}\n value={registration?.id ?? ''}\n onChange={(event) => {\n setRegistrationId(event.target.value);\n setChecked(null);\n }}\n >\n <option value=\"\">{tr('eventfullymanaged.certificates.chooseRegistration', 'Choose a registration')}</option>\n {registrationPage?.items.map((item) => (\n <option key={item.id} value={item.id}>\n {item.attendeeName || item.id} · {item.status}\n </option>\n ))}\n </select>\n </div>\n {registrations.error ? (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {tr('eventfullymanaged.certificates.registrationsError', 'Could not load registrations.')}{' '}\n <Button type=\"button\" variant=\"outline\" onClick={() => void registrations.refetch().catch(() => undefined)}>\n {tr('eventfullymanaged.certificates.retry', 'Retry')}\n </Button>\n </p>\n ) : null}\n {registrationPage ? (\n <Pagination\n offset={paging.offset}\n limit={paging.limit}\n total={registrationPage.total}\n loadedCount={registrationPage.items.length}\n onPrev={paging.prevPage}\n onNext={paging.nextPage}\n loading={registrations.loading}\n itemLabel=\"registrations\"\n />\n ) : null}\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"button\" variant=\"outline\" disabled={!template || !registration} onClick={() => void check()}>\n {checking\n ? tr('eventfullymanaged.certificates.checking', 'Checking…')\n : tr('eventfullymanaged.certificates.checkEligibility', 'Check eligibility')}\n </Button>\n <Button type=\"submit\" disabled={!eligibility?.eligible}>\n {issuing\n ? tr('eventfullymanaged.certificates.issuing', 'Issuing…')\n : tr('eventfullymanaged.certificates.issue', 'Issue certificate')}\n </Button>\n </div>\n <AttendanceOutcome eligibility={eligibility} />\n <CertificateReceiptDetails receipt={receipt} />\n </fieldset>\n </form>\n );\n}\n\nfunction AttendanceOutcome({ eligibility }: { eligibility?: Eligibility }) {\n const tr = useTr();\n if (!eligibility) return null;\n if (eligibility.eligible) {\n return (\n <p className=\"text-sm\" aria-live=\"polite\">\n {tr('eventfullymanaged.certificates.eligible', 'Eligible for this certificate.')}\n </p>\n );\n }\n return (\n <p className=\"text-sm\" aria-live=\"polite\">\n {!eligibility.registrationEligible\n ? tr(\n 'eventfullymanaged.certificates.registrationIneligible',\n 'The registration must be confirmed or checked in.'\n )\n : tr(\n 'eventfullymanaged.certificates.sessionsIneligible',\n 'Required sessions without completed attendance: {{count}}.',\n {\n count: eligibility.missingSessionIds.length,\n }\n )}\n </p>\n );\n}\n\nfunction CertificateReceiptLookup({ eventId }: { eventId: string }) {\n const tr = useTr();\n const id = useId();\n const [receipt, setReceipt] = useState<Receipt | null>(null);\n const [findReceipt, { loading: finding }] = useEventCertificateReceiptLazyQuery({ fetchPolicy: 'no-cache' });\n\n const lookup = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n const receiptId = String(new FormData(event.currentTarget).get('receiptId') ?? '').trim();\n if (!receiptId || finding) return;\n setReceipt(null);\n try {\n const result = await findReceipt({ variables: { eventId, id: receiptId } });\n if (result.error || !result.data?.eventfullyManagedCertificate) throw new Error('Receipt not confirmed');\n setReceipt(result.data.eventfullyManagedCertificate);\n } catch {\n notify.error(tr('eventfullymanaged.certificates.receiptError', 'Could not find that receipt for this event'));\n }\n };\n\n return (\n <section className={cardClass} aria-labelledby={id + 'receiptHeading'}>\n <h2 id={id + 'receiptHeading'} className=\"text-lg font-semibold\">\n {tr('eventfullymanaged.certificates.issuedReceipt', 'Issuance receipt')}\n </h2>\n <form className=\"space-y-2\" onSubmit={lookup}>\n <Label htmlFor={id + 'receipt'}>{tr('eventfullymanaged.certificates.receiptId', 'Receipt ID')}</Label>\n <div className=\"flex flex-wrap items-center gap-2\">\n <Input id={id + 'receipt'} name=\"receiptId\" className=\"flex-1\" maxLength={128} required />\n <Button type=\"submit\" variant=\"outline\" disabled={finding}>\n {finding\n ? tr('eventfullymanaged.certificates.finding', 'Looking up…')\n : tr('eventfullymanaged.certificates.find', 'Find receipt')}\n </Button>\n </div>\n </form>\n <CertificateReceiptDetails receipt={receipt} />\n </section>\n );\n}\n\nfunction CertificateReceiptDetails({ receipt }: { receipt: Receipt | null }) {\n const tr = useTr();\n if (!receipt) return null;\n return (\n <div aria-live=\"polite\" className=\"space-y-2 rounded-card border border-border-seam p-3 text-sm\">\n <h3 className=\"font-medium break-words\">{receipt.title}</h3>\n <p>\n {tr('eventfullymanaged.certificates.receiptIssuedAt', 'Issued {{date}}', {\n date: formatDateTime(receipt.issuedAt),\n })}\n </p>\n <p>\n {tr('eventfullymanaged.certificates.receiptTemplateRevision', 'Template revision {{revision}}', {\n revision: receipt.templateRevision,\n })}\n </p>\n <p className=\"break-all text-text-secondary\">{receipt.id}</p>\n </div>\n );\n}\n\nexport function CertificateIssuance(props: IssuanceProps) {\n return (\n <div className=\"grid gap-4 lg:grid-cols-2\">\n <CertificateIssueForm {...props} />\n <CertificateReceiptLookup eventId={props.eventId} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAMA,IACJ,gMACIC,IAAY;AAUlB,SAASC,EAAqB,EAAE,YAAS,gBAA4B;CACnE,IAAMC,IAAKC,EAAM,GACXC,IAA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,GAClC,kBAACR,GAAD,EAA0B,SAASQ,EAAM,QAAU,CAAA,CAChD;;AAET"}
1
+ {"version":3,"file":"CertificateIssuance.js","names":["selectClass","cardClass","CertificateIssueForm","tr","useTr","id","useId","paging","usePagination","registrations","useEventCertificateRegistrationsQuery","registrationPage","registrationId","setRegistrationId","useState","templateId","setTemplateId","checked","setChecked","receipt","setReceipt","readEligibility","checking","useEventCertificateEligibilityLazyQuery","issueCertificate","issuing","useIssueEventCertificateMutation","template","templates","item","registration","checkKey","eligibility","busy","issueError","check","result","event","issued","mutationSucceeded","Label","Button","Pagination","AttendanceOutcome","CertificateReceiptDetails","CertificateReceiptLookup","findReceipt","finding","useEventCertificateReceiptLazyQuery","receiptId","Input","formatDateTime","CertificatePdfDownload","CertificateIssuance","props"],"sources":["../../../../src/eventfullymanaged/pages/certificates/CertificateIssuance.tsx"],"sourcesContent":["import { useId, useState, type FormEvent } from 'react';\nimport { Button, Input, Label } from '@burdenoff/fe-libs/ui';\nimport {\n useEventCertificateEligibilityLazyQuery,\n useEventCertificateReceiptLazyQuery,\n useEventCertificateRegistrationsQuery,\n useIssueEventCertificateMutation,\n type EventCertificateEligibilityQuery,\n type EventCertificateReceiptFieldsFragment,\n type EventCertificateRegistrationsQuery,\n type EventCertificateTemplateFieldsFragment,\n} from '../../../generated/wspace-operations';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { Pagination, usePagination } from '../../components/Pagination';\nimport { mutationSucceeded } from '../../lib/mutationResult';\nimport { notify } from '../../lib/toast';\nimport { formatDateTime } from '../events/eventFormUtils';\nimport { CertificatePdfDownload } from './CertificatePdfDownload';\n\nconst selectClass =\n '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';\nconst cardClass = 'space-y-4 rounded-card border border-border-seam bg-bg-surface p-4';\n\ntype Eligibility = EventCertificateEligibilityQuery['eventfullyManagedCertificateEligibility'];\ntype Receipt = EventCertificateReceiptFieldsFragment;\n\ntype IssuanceProps = {\n eventId: string;\n templates: EventCertificateTemplateFieldsFragment[];\n};\n\nfunction CertificateIssueForm({ eventId, templates }: IssuanceProps) {\n const tr = useTr();\n const id = useId();\n const paging = usePagination();\n const registrations = useEventCertificateRegistrationsQuery({\n variables: { eventId, limit: paging.limit, offset: paging.offset },\n fetchPolicy: 'no-cache',\n });\n const registrationPage: EventCertificateRegistrationsQuery['eventfullyManagedRegistrations'] | undefined =\n registrations.data?.eventfullyManagedRegistrations;\n const [registrationId, setRegistrationId] = useState('');\n const [templateId, setTemplateId] = useState('');\n const [checked, setChecked] = useState<{ key: string; result: Eligibility } | null>(null);\n const [receipt, setReceipt] = useState<Receipt | null>(null);\n const [readEligibility, { loading: checking }] = useEventCertificateEligibilityLazyQuery({ fetchPolicy: 'no-cache' });\n const [issueCertificate, { loading: issuing }] = useIssueEventCertificateMutation();\n const template = templates.find((item) => item.id === templateId);\n const registration = registrationPage?.items.find((item) => item.id === registrationId);\n const checkKey = JSON.stringify([registration?.id, template?.id, template?.revision, template?.requiredSessionIds]);\n const eligibility = checked?.key === checkKey ? checked.result : undefined;\n const busy = checking || issuing;\n const issueError = tr('eventfullymanaged.certificates.issuanceError', 'Could not confirm certificate issuance');\n\n const check = async () => {\n if (!template || !registration || busy) return;\n setChecked(null);\n try {\n const result = await readEligibility({\n variables: { eventId, registrationId: registration.id, requiredSessionIds: template.requiredSessionIds },\n });\n if (result.error || !result.data?.eventfullyManagedCertificateEligibility)\n throw new Error('Eligibility not confirmed');\n setChecked({ key: checkKey, result: result.data.eventfullyManagedCertificateEligibility });\n } catch {\n notify.error(tr('eventfullymanaged.certificates.eligibilityError', 'Could not confirm attendance eligibility'));\n }\n };\n\n const issue = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (!template || !registration || !eligibility?.eligible || busy) return;\n try {\n const result = await issueCertificate({\n variables: { eventId, registrationId: registration.id, templateId: template.id },\n });\n const issued = result.data?.eventfullyManagedIssueCertificate;\n if (!mutationSucceeded(result, issued?.id, issueError) || !issued) return;\n setReceipt(issued);\n } catch {\n notify.error(issueError);\n }\n };\n\n return (\n <form className={cardClass} onSubmit={issue}>\n <fieldset disabled={busy} className=\"space-y-4\">\n <legend className=\"mb-3 text-lg font-semibold\">\n {tr('eventfullymanaged.certificates.manualIssue', 'Issue a certificate')}\n </legend>\n <div className=\"space-y-1.5\">\n <Label id={id + 'templateLabel'} htmlFor={id + 'template'}>\n {tr('eventfullymanaged.certificates.template', 'Certificate template')}\n </Label>\n <select\n id={id + 'template'}\n aria-labelledby={id + 'templateLabel'}\n className={selectClass}\n value={template?.id ?? ''}\n onChange={(event) => {\n setTemplateId(event.target.value);\n setChecked(null);\n }}\n >\n <option value=\"\">{tr('eventfullymanaged.certificates.chooseTemplate', 'Choose a template')}</option>\n {templates.map((item) => (\n <option key={item.id} value={item.id}>\n {item.title}\n </option>\n ))}\n </select>\n </div>\n <div className=\"space-y-1.5\">\n <Label id={id + 'registrationLabel'} htmlFor={id + 'registration'}>\n {tr('eventfullymanaged.certificates.registration', 'Attendee registration')}\n </Label>\n <select\n id={id + 'registration'}\n aria-labelledby={id + 'registrationLabel'}\n className={selectClass}\n value={registration?.id ?? ''}\n onChange={(event) => {\n setRegistrationId(event.target.value);\n setChecked(null);\n }}\n >\n <option value=\"\">{tr('eventfullymanaged.certificates.chooseRegistration', 'Choose a registration')}</option>\n {registrationPage?.items.map((item) => (\n <option key={item.id} value={item.id}>\n {item.attendeeName || item.id} · {item.status}\n </option>\n ))}\n </select>\n </div>\n {registrations.error ? (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {tr('eventfullymanaged.certificates.registrationsError', 'Could not load registrations.')}{' '}\n <Button type=\"button\" variant=\"outline\" onClick={() => void registrations.refetch().catch(() => undefined)}>\n {tr('eventfullymanaged.certificates.retry', 'Retry')}\n </Button>\n </p>\n ) : null}\n {registrationPage ? (\n <Pagination\n offset={paging.offset}\n limit={paging.limit}\n total={registrationPage.total}\n loadedCount={registrationPage.items.length}\n onPrev={paging.prevPage}\n onNext={paging.nextPage}\n loading={registrations.loading}\n itemLabel=\"registrations\"\n />\n ) : null}\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"button\" variant=\"outline\" disabled={!template || !registration} onClick={() => void check()}>\n {checking\n ? tr('eventfullymanaged.certificates.checking', 'Checking…')\n : tr('eventfullymanaged.certificates.checkEligibility', 'Check eligibility')}\n </Button>\n <Button type=\"submit\" disabled={!eligibility?.eligible}>\n {issuing\n ? tr('eventfullymanaged.certificates.issuing', 'Issuing…')\n : tr('eventfullymanaged.certificates.issue', 'Issue certificate')}\n </Button>\n </div>\n <AttendanceOutcome eligibility={eligibility} />\n <CertificateReceiptDetails eventId={eventId} receipt={receipt} />\n </fieldset>\n </form>\n );\n}\n\nfunction AttendanceOutcome({ eligibility }: { eligibility?: Eligibility }) {\n const tr = useTr();\n if (!eligibility) return null;\n if (eligibility.eligible) {\n return (\n <p className=\"text-sm\" aria-live=\"polite\">\n {tr('eventfullymanaged.certificates.eligible', 'Eligible for this certificate.')}\n </p>\n );\n }\n return (\n <p className=\"text-sm\" aria-live=\"polite\">\n {!eligibility.registrationEligible\n ? tr(\n 'eventfullymanaged.certificates.registrationIneligible',\n 'The registration must be confirmed or checked in.'\n )\n : tr(\n 'eventfullymanaged.certificates.sessionsIneligible',\n 'Required sessions without completed attendance: {{count}}.',\n {\n count: eligibility.missingSessionIds.length,\n }\n )}\n </p>\n );\n}\n\nfunction CertificateReceiptLookup({ eventId }: { eventId: string }) {\n const tr = useTr();\n const id = useId();\n const [receipt, setReceipt] = useState<Receipt | null>(null);\n const [findReceipt, { loading: finding }] = useEventCertificateReceiptLazyQuery({ fetchPolicy: 'no-cache' });\n\n const lookup = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n const receiptId = String(new FormData(event.currentTarget).get('receiptId') ?? '').trim();\n if (!receiptId || finding) return;\n setReceipt(null);\n try {\n const result = await findReceipt({ variables: { eventId, id: receiptId } });\n if (result.error || !result.data?.eventfullyManagedCertificate) throw new Error('Receipt not confirmed');\n setReceipt(result.data.eventfullyManagedCertificate);\n } catch {\n notify.error(tr('eventfullymanaged.certificates.receiptError', 'Could not find that receipt for this event'));\n }\n };\n\n return (\n <section className={cardClass} aria-labelledby={id + 'receiptHeading'}>\n <h2 id={id + 'receiptHeading'} className=\"text-lg font-semibold\">\n {tr('eventfullymanaged.certificates.issuedReceipt', 'Issuance receipt')}\n </h2>\n <form className=\"space-y-2\" onSubmit={lookup}>\n <Label htmlFor={id + 'receipt'}>{tr('eventfullymanaged.certificates.receiptId', 'Receipt ID')}</Label>\n <div className=\"flex flex-wrap items-center gap-2\">\n <Input id={id + 'receipt'} name=\"receiptId\" className=\"flex-1\" maxLength={128} required />\n <Button type=\"submit\" variant=\"outline\" disabled={finding}>\n {finding\n ? tr('eventfullymanaged.certificates.finding', 'Looking up…')\n : tr('eventfullymanaged.certificates.find', 'Find receipt')}\n </Button>\n </div>\n </form>\n <CertificateReceiptDetails eventId={eventId} receipt={receipt} />\n </section>\n );\n}\n\nfunction CertificateReceiptDetails({ eventId, receipt }: { eventId: string; receipt: Receipt | null }) {\n const tr = useTr();\n if (!receipt) return null;\n return (\n <div aria-live=\"polite\" className=\"space-y-2 rounded-card border border-border-seam p-3 text-sm\">\n <h3 className=\"font-medium break-words\">{receipt.title}</h3>\n <p>\n {tr('eventfullymanaged.certificates.receiptIssuedAt', 'Issued {{date}}', {\n date: formatDateTime(receipt.issuedAt),\n })}\n </p>\n <p>\n {tr('eventfullymanaged.certificates.receiptTemplateRevision', 'Template revision {{revision}}', {\n revision: receipt.templateRevision,\n })}\n </p>\n <p className=\"break-all text-text-secondary\">{receipt.id}</p>\n <CertificatePdfDownload eventId={eventId} receiptId={receipt.id} />\n </div>\n );\n}\n\nexport function CertificateIssuance(props: IssuanceProps) {\n return (\n <div className=\"grid gap-4 lg:grid-cols-2\">\n <CertificateIssueForm {...props} />\n <CertificateReceiptLookup eventId={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C,UAAAA,EAAQ;GAAM,CAAA;GAC5D,kBAACiC,GAAD;IAAiC;IAAS,WAAWjC,EAAQ;GAAK,CAAA;EAC/D;C,KAhBc;AAkBvB;AAEA,SAAgBkC,EAAoB,GAAsB;CACxD,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACnD,GAAD,EAAsB,GAAIoD,EAAQ,CAAA,GAClC,kBAACT,GAAD,EAA0B,SAASS,EAAM,QAAU,CAAA,CAChD;;AAET"}
@@ -0,0 +1,4 @@
1
+ export declare function CertificatePdfDownload({ eventId, receiptId }: {
2
+ eventId: string;
3
+ receiptId: string;
4
+ }): import('react').JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { useEventCertificatePdfLazyQuery as e } from "../../../generated/wspace-operations.js";
2
+ import { useTr as t } from "../../../shared/hooks/useTr.js";
3
+ import { downloadBase64Pdf as n } from "../../api/eventApi.js";
4
+ import { notify as r } from "../../lib/toast.js";
5
+ import { jsx as i } from "react/jsx-runtime";
6
+ import { Button as a } from "@burdenoff/fe-libs/ui";
7
+ // src/eventfullymanaged/pages/certificates/CertificatePdfDownload.tsx
8
+ function o({ eventId: o, receiptId: s }) {
9
+ let c = t(), [l, { loading: u }] = e({ fetchPolicy: "no-cache" }), d = async () => {
10
+ if (!u) try {
11
+ let e = await l({ variables: {
12
+ eventId: o,
13
+ id: s
14
+ } }), t = e.data?.eventfullyManagedCertificatePdf;
15
+ if (e.error || t?.contentType !== "application/pdf" || !t.contentBase64.startsWith("JVBERi0") || !/^certificate-[a-z0-9-]+\.pdf$/i.test(t.filename)) throw Error("Certificate PDF was not confirmed.");
16
+ n(t.contentBase64, t.filename);
17
+ } catch {
18
+ r.error(c("eventfullymanaged.certificates.pdfError", "Could not download the certificate PDF."));
19
+ }
20
+ };
21
+ return /* @__PURE__ */ i(a, {
22
+ type: "button",
23
+ variant: "outline",
24
+ disabled: u,
25
+ onClick: () => void d(),
26
+ children: u ? c("eventfullymanaged.certificates.pdfLoading", "Preparing PDF…") : c("eventfullymanaged.certificates.pdfDownload", "Download PDF")
27
+ });
28
+ }
29
+ export { o as CertificatePdfDownload };
30
+
31
+ //# sourceMappingURL=CertificatePdfDownload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CertificatePdfDownload.js","names":["CertificatePdfDownload","tr","useTr","readPdf","useEventCertificatePdfLazyQuery","download","response","receiptId","pdf","Button","loading"],"sources":["../../../../src/eventfullymanaged/pages/certificates/CertificatePdfDownload.tsx"],"sourcesContent":["import { Button } from '@burdenoff/fe-libs/ui';\nimport { useEventCertificatePdfLazyQuery } from '../../../generated/wspace-operations';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { downloadBase64Pdf } from '../../api/eventApi';\nimport { notify } from '../../lib/toast';\n\nexport function CertificatePdfDownload({ eventId, receiptId }: { eventId: string; receiptId: string }) {\n const tr = useTr();\n const [readPdf, { loading }] = useEventCertificatePdfLazyQuery({ fetchPolicy: 'no-cache' });\n const download = async () => {\n if (loading) return;\n try {\n const response = await readPdf({ variables: { eventId, id: receiptId } });\n const pdf = response.data?.eventfullyManagedCertificatePdf;\n if (\n response.error ||\n pdf?.contentType !== 'application/pdf' ||\n !pdf.contentBase64.startsWith('JVBERi0') ||\n !/^certificate-[a-z0-9-]+\\.pdf$/i.test(pdf.filename)\n ) {\n throw new Error('Certificate PDF was not confirmed.');\n }\n downloadBase64Pdf(pdf.contentBase64, pdf.filename);\n } catch {\n notify.error(tr('eventfullymanaged.certificates.pdfError', 'Could not download the certificate PDF.'));\n }\n };\n\n return (\n <Button type=\"button\" variant=\"outline\" disabled={loading} onClick={() => void download()}>\n {loading\n ? tr('eventfullymanaged.certificates.pdfLoading', 'Preparing PDF…')\n : tr('eventfullymanaged.certificates.pdfDownload', 'Download PDF')}\n </Button>\n );\n}\n"],"mappings":";;;;;;;AAMA,SAAgBA,EAAuB,EAAE,YAAS,gBAAqD;CACrG,IAAMC,IAAKC,EAAM,GACX,CAACC,GAAS,EAAE,gBAAaC,EAAgC,EAAE,aAAa,WAAW,CAAC,GACpFC,IAAW,YAAY;EAC3B,IAAI,IACJ,IAAI;GACF,IAAMC,IAAW,MAAMH,EAAQ,EAAE,WAAW;IAAE;IAAS,IAAII;GAAU,EAAE,CAAC,GAClEC,IAAMF,EAAS,MAAM;GAC3B,IACEA,EAAS,SACTE,GAAK,gBAAgB,qBACrB,CAACA,EAAI,cAAc,WAAW,SAAS,KACvC,CAAC,iCAAiC,KAAKA,EAAI,QAAQ,GAEnD,MAAU,MAAM,oCAAoC;GAEtD,EAAkBA,EAAI,eAAeA,EAAI,QAAQ;EACnD,QAAQ;GACN,EAAO,MAAMP,EAAG,2CAA2C,yCAAyC,CAAC;EACvG;CACF;CAEA,OACE,kBAACQ,GAAD;EAAQ,MAAK;EAAS,SAAQ;EAAU,UAAUC;EAAS,eAAe,KAAKL,EAAS;EACrF,UAAAK,IACGT,EAAG,6CAA6C,gBAAgB,IAChEA,EAAG,8CAA8C,cAAc;CAC7D,CAAA;AAEZ"}
@@ -0,0 +1,6 @@
1
+ import { EventCertificateTemplateFieldsFragment } from '../../../generated/wspace-operations';
2
+ export declare function CertificateScheduleDialog({ eventId, template, onClose, }: {
3
+ eventId: string;
4
+ template: EventCertificateTemplateFieldsFragment;
5
+ onClose: () => void;
6
+ }): import('react').JSX.Element;
@@ -0,0 +1,76 @@
1
+ import { useScheduleEventCertificateIssuanceMutation as e } from "../../../generated/wspace-operations.js";
2
+ import { useTr as t } from "../../../shared/hooks/useTr.js";
3
+ import { mutationSucceeded as n } from "../../lib/mutationResult.js";
4
+ import { notify as r } from "../../lib/toast.js";
5
+ import { formatDateTime as i } from "../events/eventFormUtils.js";
6
+ import { useState as a } from "react";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
+ import { Button as c, Dialog as l, DialogContent as u, DialogDescription as d, DialogHeader as f, DialogTitle as p } from "@burdenoff/fe-libs/ui";
9
+ // src/eventfullymanaged/pages/certificates/CertificateScheduleDialog.tsx
10
+ function m({ eventId: i, template: m, onClose: g }) {
11
+ let _ = t(), [v, { loading: y }] = e(), [b, x] = a(null), S = _("eventfullymanaged.certificates.scheduleError", "Could not schedule certificate issuance"), C = async () => {
12
+ if (!(y || b)) try {
13
+ let e = await v({ variables: {
14
+ eventId: i,
15
+ templateId: m.id,
16
+ templateRevision: m.revision
17
+ } }), t = e.data?.eventfullyManagedScheduleCertificateIssuance;
18
+ n(e, t?.id, S) && t && x(t);
19
+ } catch {
20
+ r.error(S);
21
+ }
22
+ };
23
+ return /* @__PURE__ */ o(l, {
24
+ open: !0,
25
+ onOpenChange: (e) => {
26
+ !e && !y && g();
27
+ },
28
+ children: /* @__PURE__ */ s(u, { children: [
29
+ /* @__PURE__ */ s(f, { children: [/* @__PURE__ */ o(p, { children: _("eventfullymanaged.certificates.schedule", "Schedule automatic issuance") }), /* @__PURE__ */ o(d, { children: _("eventfullymanaged.certificates.scheduleHelp", "Schedule this template revision to issue certificates after the last required session ends.") })] }),
30
+ /* @__PURE__ */ s("p", {
31
+ className: "break-words font-medium",
32
+ children: [
33
+ m.title,
34
+ " ·",
35
+ " ",
36
+ _("eventfullymanaged.certificates.revision", "Revision {{revision}}", { revision: m.revision })
37
+ ]
38
+ }),
39
+ b ? /* @__PURE__ */ o(h, { run: b }) : null,
40
+ /* @__PURE__ */ s("div", {
41
+ className: "flex flex-wrap justify-end gap-2",
42
+ children: [/* @__PURE__ */ o(c, {
43
+ type: "button",
44
+ variant: "outline",
45
+ disabled: y,
46
+ onClick: g,
47
+ children: b ? _("eventfullymanaged.certificates.done", "Done") : _("eventfullymanaged.certificates.cancel", "Cancel")
48
+ }), b ? null : /* @__PURE__ */ o(c, {
49
+ type: "button",
50
+ disabled: y,
51
+ onClick: () => void C(),
52
+ children: y ? _("eventfullymanaged.certificates.scheduling", "Scheduling…") : _("eventfullymanaged.certificates.scheduleConfirm", "Schedule issuance")
53
+ })]
54
+ })
55
+ ] })
56
+ });
57
+ }
58
+ function h({ run: e }) {
59
+ let n = t();
60
+ return /* @__PURE__ */ s("div", {
61
+ className: "space-y-1 rounded-card border border-border-seam p-3 text-sm",
62
+ role: "status",
63
+ children: [
64
+ /* @__PURE__ */ o("p", { children: n("eventfullymanaged.certificates.scheduleStatus", "Run status: {{status}}", { status: e.status }) }),
65
+ e.status === "pending" ? /* @__PURE__ */ o("p", { children: n("eventfullymanaged.certificates.nextAttempt", "Next attempt: {{date}}", { date: i(e.nextAttemptAt) }) }) : null,
66
+ e.completedAt ? /* @__PURE__ */ o("p", { children: n("eventfullymanaged.certificates.runFinished", "Finished: {{date}}", { date: i(e.completedAt) }) }) : null,
67
+ /* @__PURE__ */ o("p", {
68
+ className: "break-all text-text-secondary",
69
+ children: e.id
70
+ })
71
+ ]
72
+ });
73
+ }
74
+ export { m as CertificateScheduleDialog };
75
+
76
+ //# sourceMappingURL=CertificateScheduleDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CertificateScheduleDialog.js","names":["CertificateScheduleDialog","tr","useTr","schedule","useScheduleEventCertificateIssuanceMutation","run","setRun","useState","scheduleError","submit","result","template","scheduled","mutationSucceeded","Dialog","open","loading","onClose","DialogContent","DialogHeader","DialogTitle","DialogDescription","ScheduleReceipt","Button","formatDateTime"],"sources":["../../../../src/eventfullymanaged/pages/certificates/CertificateScheduleDialog.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@burdenoff/fe-libs/ui';\nimport {\n useScheduleEventCertificateIssuanceMutation,\n type EventCertificateTemplateFieldsFragment,\n type ScheduleEventCertificateIssuanceMutation,\n} from '../../../generated/wspace-operations';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { mutationSucceeded } from '../../lib/mutationResult';\nimport { notify } from '../../lib/toast';\nimport { formatDateTime } from '../events/eventFormUtils';\n\ntype ScheduleRun = ScheduleEventCertificateIssuanceMutation['eventfullyManagedScheduleCertificateIssuance'];\n\nexport function CertificateScheduleDialog({\n eventId,\n template,\n onClose,\n}: {\n eventId: string;\n template: EventCertificateTemplateFieldsFragment;\n onClose: () => void;\n}) {\n const tr = useTr();\n const [schedule, { loading }] = useScheduleEventCertificateIssuanceMutation();\n const [run, setRun] = useState<ScheduleRun | null>(null);\n const scheduleError = tr('eventfullymanaged.certificates.scheduleError', 'Could not schedule certificate issuance');\n\n const submit = async () => {\n if (loading || run) return;\n try {\n const result = await schedule({\n variables: { eventId, templateId: template.id, templateRevision: template.revision },\n });\n const scheduled = result.data?.eventfullyManagedScheduleCertificateIssuance;\n if (mutationSucceeded(result, scheduled?.id, scheduleError) && scheduled) setRun(scheduled);\n } catch {\n notify.error(scheduleError);\n }\n };\n\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open && !loading) onClose();\n }}\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{tr('eventfullymanaged.certificates.schedule', 'Schedule automatic issuance')}</DialogTitle>\n <DialogDescription>\n {tr(\n 'eventfullymanaged.certificates.scheduleHelp',\n 'Schedule this template revision to issue certificates after the last required session ends.'\n )}\n </DialogDescription>\n </DialogHeader>\n <p className=\"break-words font-medium\">\n {template.title} ·{' '}\n {tr('eventfullymanaged.certificates.revision', 'Revision {{revision}}', {\n revision: template.revision,\n })}\n </p>\n {run ? <ScheduleReceipt run={run} /> : null}\n <div className=\"flex flex-wrap justify-end gap-2\">\n <Button type=\"button\" variant=\"outline\" disabled={loading} onClick={onClose}>\n {run\n ? tr('eventfullymanaged.certificates.done', 'Done')\n : tr('eventfullymanaged.certificates.cancel', 'Cancel')}\n </Button>\n {run ? null : (\n <Button type=\"button\" disabled={loading} onClick={() => void submit()}>\n {loading\n ? tr('eventfullymanaged.certificates.scheduling', 'Scheduling…')\n : tr('eventfullymanaged.certificates.scheduleConfirm', 'Schedule issuance')}\n </Button>\n )}\n </div>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction ScheduleReceipt({ run }: { run: ScheduleRun }) {\n const tr = useTr();\n return (\n <div className=\"space-y-1 rounded-card border border-border-seam p-3 text-sm\" role=\"status\">\n <p>{tr('eventfullymanaged.certificates.scheduleStatus', 'Run status: {{status}}', { status: run.status })}</p>\n {run.status === 'pending' ? (\n <p>\n {tr('eventfullymanaged.certificates.nextAttempt', 'Next attempt: {{date}}', {\n date: formatDateTime(run.nextAttemptAt),\n })}\n </p>\n ) : null}\n {run.completedAt ? (\n <p>\n {tr('eventfullymanaged.certificates.runFinished', 'Finished: {{date}}', {\n date: formatDateTime(run.completedAt),\n })}\n </p>\n ) : null}\n <p className=\"break-all text-text-secondary\">{run.id}</p>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgBA,EAA0B,EACxC,YACA,aACA,cAKC;CACD,IAAMC,IAAKC,EAAM,GACX,CAACC,GAAU,EAAE,gBAAaC,EAA4C,GACtE,CAACC,GAAKC,KAAUC,EAA6B,IAAI,GACjDC,IAAgBP,EAAG,gDAAgD,yCAAyC,GAE5GQ,IAAS,YAAY;EACzB,IAAI,OAAWJ,IACf,IAAI;GACF,IAAMK,IAAS,MAAMP,EAAS,EAC5B,WAAW;IAAE;IAAS,YAAYQ,EAAS;IAAI,kBAAkBA,EAAS;GAAS,EACrF,CAAC,GACKC,IAAYF,EAAO,MAAM;GAC/B,AAAIG,EAAkBH,GAAQE,GAAW,IAAIJ,CAAa,KAAKI,KAAWN,EAAOM,CAAS;EAC5F,QAAQ;GACN,EAAO,MAAMJ,CAAa;EAC5B;CACF;CAEA,OACE,kBAACM,GAAD;EACE,MAAA;EACA,eAAe,MAAS;GACtB,AAAI,CAACC,KAAQ,CAACC,KAASC,EAAQ;EACjC;EAEA,UAAA,kBAACC,GAAD,EAAA,UAAA;GACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAcnB,EAAG,2CAA2C,6BAA6B,EAAe,CAAA,GACxG,kBAACoB,GAAD,EAAA,UACGpB,EACC,+CACA,6FACF,EACiB,CAAA,CACP,EAAA,CAAA;GACd,kBAAC,KAAD;IAAG,WAAU;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