@krak-stack/notifications-admin 0.0.0-stage → 0.2.0
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/CHANGELOG.md +15 -0
- package/README.md +94 -2
- package/dist/atoms.d.ts +10 -0
- package/dist/atoms.js +328 -0
- package/dist/campaign.atom.d.ts +281 -0
- package/dist/campaigns.d.ts +51 -0
- package/dist/campaigns.js +8 -0
- package/dist/chunk-28xppc9m.js +404 -0
- package/dist/chunk-aqmv7g24.js +29 -0
- package/dist/chunk-dxjvd9tb.js +419 -0
- package/dist/chunk-t0qhq7pj.js +272 -0
- package/dist/chunk-tck9drx2.js +134 -0
- package/dist/chunk-wkxc1y7w.js +704 -0
- package/dist/contact.atom.d.ts +96 -0
- package/dist/contacts.d.ts +67 -0
- package/dist/contacts.js +11 -0
- package/dist/deliveries.d.ts +42 -0
- package/dist/deliveries.js +8 -0
- package/dist/delivery.atom.d.ts +196 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +29 -0
- package/dist/operations.atom.d.ts +244 -0
- package/dist/operations.d.ts +106 -0
- package/dist/operations.js +13 -0
- package/dist/presentation.d.ts +15 -0
- package/dist/presentation.js +10 -0
- package/package.json +80 -4
- package/tailwind.css +2 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogContent,
|
|
5
|
+
DialogHeader,
|
|
6
|
+
DialogTitle
|
|
7
|
+
} from "./chunk-tck9drx2.js";
|
|
8
|
+
|
|
9
|
+
// src/campaigns.tsx
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { Effect, Schema } from "effect";
|
|
12
|
+
import {
|
|
13
|
+
CampaignForm,
|
|
14
|
+
CampaignScheduleForm
|
|
15
|
+
} from "@krak-stack/notifications/admin/schema";
|
|
16
|
+
import {
|
|
17
|
+
DataTable
|
|
18
|
+
} from "@krak-stack/registry/data-table";
|
|
19
|
+
import { useAppForm } from "@krak-stack/registry/form";
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
var metricKeys = [
|
|
22
|
+
"audience",
|
|
23
|
+
"pending",
|
|
24
|
+
"published",
|
|
25
|
+
"skipped",
|
|
26
|
+
"accepted",
|
|
27
|
+
"failed",
|
|
28
|
+
"suppressed",
|
|
29
|
+
"confirmed",
|
|
30
|
+
"hardBounced",
|
|
31
|
+
"complained"
|
|
32
|
+
];
|
|
33
|
+
var SendCampaignAdmin2 = ({
|
|
34
|
+
page,
|
|
35
|
+
selected,
|
|
36
|
+
report,
|
|
37
|
+
pending,
|
|
38
|
+
error,
|
|
39
|
+
messages: m,
|
|
40
|
+
onSelect,
|
|
41
|
+
onClose,
|
|
42
|
+
onRecipients,
|
|
43
|
+
table,
|
|
44
|
+
onCreate,
|
|
45
|
+
onSchedule,
|
|
46
|
+
onTransition
|
|
47
|
+
}) => {
|
|
48
|
+
const [creating, setCreating] = useState(false);
|
|
49
|
+
const [requestId, setRequestId] = useState("");
|
|
50
|
+
const [confirming, setConfirming] = useState(false);
|
|
51
|
+
const [busy, setBusy] = useState(false);
|
|
52
|
+
const [failure, setFailure] = useState();
|
|
53
|
+
const [initialSchedule] = useState(() => new Date().toISOString());
|
|
54
|
+
const createForm = useAppForm({
|
|
55
|
+
defaultValues: {
|
|
56
|
+
name: "",
|
|
57
|
+
from: "",
|
|
58
|
+
enSubject: "",
|
|
59
|
+
enText: "",
|
|
60
|
+
frSubject: "",
|
|
61
|
+
frText: ""
|
|
62
|
+
},
|
|
63
|
+
validators: { onSubmit: Schema.toStandardSchemaV1(CampaignForm) },
|
|
64
|
+
onSubmit: async ({ value }) => {
|
|
65
|
+
setFailure(undefined);
|
|
66
|
+
try {
|
|
67
|
+
await onCreate({
|
|
68
|
+
requestId,
|
|
69
|
+
name: value.name,
|
|
70
|
+
from: value.from,
|
|
71
|
+
audience: { _tag: "AllSubscribed" },
|
|
72
|
+
content: {
|
|
73
|
+
en: {
|
|
74
|
+
subject: value.enSubject,
|
|
75
|
+
text: value.enText,
|
|
76
|
+
unsubscribeText: m.enUnsubscribe
|
|
77
|
+
},
|
|
78
|
+
fr: {
|
|
79
|
+
subject: value.frSubject,
|
|
80
|
+
text: value.frText,
|
|
81
|
+
unsubscribeText: m.frUnsubscribe
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
setCreating(false);
|
|
86
|
+
createForm.reset();
|
|
87
|
+
} catch {
|
|
88
|
+
setFailure(m.failed);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const scheduleForm = useAppForm({
|
|
93
|
+
defaultValues: { scheduledFor: initialSchedule },
|
|
94
|
+
validators: { onSubmit: Schema.toStandardSchemaV1(CampaignScheduleForm) },
|
|
95
|
+
onSubmit: async ({ value }) => {
|
|
96
|
+
if (!selected)
|
|
97
|
+
return;
|
|
98
|
+
setFailure(undefined);
|
|
99
|
+
try {
|
|
100
|
+
const decoded = await Effect.runPromise(Schema.decodeEffect(CampaignScheduleForm)(value));
|
|
101
|
+
await onSchedule({
|
|
102
|
+
id: selected.id,
|
|
103
|
+
scheduledFor: decoded.scheduledFor
|
|
104
|
+
});
|
|
105
|
+
} catch {
|
|
106
|
+
setFailure(m.failed);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const transition = async (action) => {
|
|
111
|
+
if (!selected)
|
|
112
|
+
return;
|
|
113
|
+
setBusy(true);
|
|
114
|
+
setFailure(undefined);
|
|
115
|
+
try {
|
|
116
|
+
await onTransition({ id: selected.id, action });
|
|
117
|
+
setConfirming(false);
|
|
118
|
+
} catch {
|
|
119
|
+
setFailure(m.failed);
|
|
120
|
+
} finally {
|
|
121
|
+
setBusy(false);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const columns = [
|
|
125
|
+
{ field: "name", headerName: m.name },
|
|
126
|
+
{ field: "from", headerName: m.from },
|
|
127
|
+
{ field: "scheduledFor", headerName: m.scheduledFor, type: "date" },
|
|
128
|
+
{
|
|
129
|
+
field: "status",
|
|
130
|
+
headerName: m.status,
|
|
131
|
+
filterOptions: Object.entries(m.statuses).map(([value, label]) => ({
|
|
132
|
+
value,
|
|
133
|
+
label
|
|
134
|
+
})),
|
|
135
|
+
cellRenderer: ({ data }) => m.statuses[data.status]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
colId: "manage",
|
|
139
|
+
sortable: false,
|
|
140
|
+
filterable: false,
|
|
141
|
+
searchable: false,
|
|
142
|
+
hideable: false,
|
|
143
|
+
headerName: m.manage,
|
|
144
|
+
cellRenderer: ({ data }) => /* @__PURE__ */ jsx(Button, {
|
|
145
|
+
variant: "outline",
|
|
146
|
+
onClick: () => {
|
|
147
|
+
setFailure(undefined);
|
|
148
|
+
onSelect(data);
|
|
149
|
+
},
|
|
150
|
+
children: m.manage
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
155
|
+
className: "space-y-4",
|
|
156
|
+
"aria-busy": pending || busy,
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsxs("header", {
|
|
159
|
+
className: "flex items-start justify-between gap-4",
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ jsxs("div", {
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsx("h1", {
|
|
164
|
+
className: "text-2xl font-semibold",
|
|
165
|
+
children: m.title
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsx("p", {
|
|
168
|
+
children: m.description
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ jsx(Button, {
|
|
173
|
+
onClick: () => {
|
|
174
|
+
setRequestId(crypto.randomUUID());
|
|
175
|
+
setFailure(undefined);
|
|
176
|
+
setCreating(true);
|
|
177
|
+
},
|
|
178
|
+
children: m.create
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
}),
|
|
182
|
+
(error || failure && !creating) && /* @__PURE__ */ jsx("p", {
|
|
183
|
+
role: "alert",
|
|
184
|
+
children: error || failure
|
|
185
|
+
}),
|
|
186
|
+
/* @__PURE__ */ jsx(DataTable, {
|
|
187
|
+
columnDefs: columns,
|
|
188
|
+
rowData: page?.items ?? [],
|
|
189
|
+
getRowId: (campaign) => campaign.id,
|
|
190
|
+
features: { pagination: { mode: "client" } },
|
|
191
|
+
status: { loading: pending, error },
|
|
192
|
+
...table
|
|
193
|
+
}),
|
|
194
|
+
selected && /* @__PURE__ */ jsxs("section", {
|
|
195
|
+
"aria-label": selected.name,
|
|
196
|
+
className: "space-y-4 rounded border p-4",
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ jsx("h2", {
|
|
199
|
+
children: selected.name
|
|
200
|
+
}),
|
|
201
|
+
/* @__PURE__ */ jsx("p", {
|
|
202
|
+
children: m.statuses[selected.status]
|
|
203
|
+
}),
|
|
204
|
+
/* @__PURE__ */ jsxs("dl", {
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ jsx("dt", {
|
|
207
|
+
children: m.from
|
|
208
|
+
}),
|
|
209
|
+
/* @__PURE__ */ jsx("dd", {
|
|
210
|
+
children: selected.from
|
|
211
|
+
}),
|
|
212
|
+
/* @__PURE__ */ jsx("dt", {
|
|
213
|
+
children: m.scheduledFor
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ jsx("dd", {
|
|
216
|
+
children: selected.scheduledFor?.toISOString() ?? "—"
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
}),
|
|
220
|
+
["en", "fr"].map((locale) => /* @__PURE__ */ jsxs("details", {
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ jsx("summary", {
|
|
223
|
+
children: locale === "en" ? m.english : m.french
|
|
224
|
+
}),
|
|
225
|
+
/* @__PURE__ */ jsx("h3", {
|
|
226
|
+
children: selected.content[locale].subject
|
|
227
|
+
}),
|
|
228
|
+
/* @__PURE__ */ jsx("p", {
|
|
229
|
+
className: "whitespace-pre-wrap",
|
|
230
|
+
children: selected.content[locale].text
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
}, locale)),
|
|
234
|
+
onRecipients && /* @__PURE__ */ jsx(Button, {
|
|
235
|
+
variant: "outline",
|
|
236
|
+
onClick: () => onRecipients(selected.id),
|
|
237
|
+
children: m.metrics.audience
|
|
238
|
+
}),
|
|
239
|
+
selected.status === "draft" && /* @__PURE__ */ jsx(scheduleForm.AppForm, {
|
|
240
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
241
|
+
onSubmit: (event) => {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
scheduleForm.handleSubmit();
|
|
244
|
+
},
|
|
245
|
+
className: "space-y-2",
|
|
246
|
+
children: [
|
|
247
|
+
/* @__PURE__ */ jsx(scheduleForm.AppField, {
|
|
248
|
+
name: "scheduledFor",
|
|
249
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextField, {
|
|
250
|
+
label: m.scheduledFor
|
|
251
|
+
})
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ jsx(scheduleForm.SubmitButton, {
|
|
254
|
+
children: m.schedule
|
|
255
|
+
})
|
|
256
|
+
]
|
|
257
|
+
})
|
|
258
|
+
}),
|
|
259
|
+
/* @__PURE__ */ jsxs("div", {
|
|
260
|
+
className: "flex gap-2",
|
|
261
|
+
children: [
|
|
262
|
+
["scheduled", "running", "completed"].includes(selected.status) && /* @__PURE__ */ jsx(Button, {
|
|
263
|
+
disabled: pending || busy,
|
|
264
|
+
onClick: () => void transition("pause"),
|
|
265
|
+
children: m.pause
|
|
266
|
+
}),
|
|
267
|
+
selected.status === "paused" && /* @__PURE__ */ jsx(Button, {
|
|
268
|
+
disabled: pending || busy,
|
|
269
|
+
onClick: () => void transition("resume"),
|
|
270
|
+
children: m.resume
|
|
271
|
+
}),
|
|
272
|
+
selected.status !== "cancelled" && /* @__PURE__ */ jsx(Button, {
|
|
273
|
+
variant: "destructive",
|
|
274
|
+
disabled: pending || busy,
|
|
275
|
+
onClick: () => setConfirming(true),
|
|
276
|
+
children: m.cancel
|
|
277
|
+
}),
|
|
278
|
+
/* @__PURE__ */ jsx(Button, {
|
|
279
|
+
variant: "outline",
|
|
280
|
+
onClick: onClose,
|
|
281
|
+
children: m.close
|
|
282
|
+
})
|
|
283
|
+
]
|
|
284
|
+
}),
|
|
285
|
+
report && /* @__PURE__ */ jsxs("div", {
|
|
286
|
+
children: [
|
|
287
|
+
/* @__PURE__ */ jsx("h3", {
|
|
288
|
+
children: m.reporting
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ jsx("dl", {
|
|
291
|
+
children: metricKeys.map((key) => /* @__PURE__ */ jsxs("div", {
|
|
292
|
+
className: "flex justify-between gap-4",
|
|
293
|
+
children: [
|
|
294
|
+
/* @__PURE__ */ jsx("dt", {
|
|
295
|
+
children: m.metrics[key]
|
|
296
|
+
}),
|
|
297
|
+
/* @__PURE__ */ jsx("dd", {
|
|
298
|
+
children: report[key]
|
|
299
|
+
})
|
|
300
|
+
]
|
|
301
|
+
}, key))
|
|
302
|
+
})
|
|
303
|
+
]
|
|
304
|
+
})
|
|
305
|
+
]
|
|
306
|
+
}),
|
|
307
|
+
/* @__PURE__ */ jsx(Dialog, {
|
|
308
|
+
open: creating,
|
|
309
|
+
onOpenChange: setCreating,
|
|
310
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
311
|
+
children: [
|
|
312
|
+
/* @__PURE__ */ jsx(DialogHeader, {
|
|
313
|
+
children: /* @__PURE__ */ jsx(DialogTitle, {
|
|
314
|
+
children: m.create
|
|
315
|
+
})
|
|
316
|
+
}),
|
|
317
|
+
/* @__PURE__ */ jsx(createForm.AppForm, {
|
|
318
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
319
|
+
className: "space-y-3",
|
|
320
|
+
onSubmit: (event) => {
|
|
321
|
+
event.preventDefault();
|
|
322
|
+
createForm.handleSubmit();
|
|
323
|
+
},
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx(createForm.AppField, {
|
|
326
|
+
name: "name",
|
|
327
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextField, {
|
|
328
|
+
label: m.name
|
|
329
|
+
})
|
|
330
|
+
}),
|
|
331
|
+
/* @__PURE__ */ jsx(createForm.AppField, {
|
|
332
|
+
name: "from",
|
|
333
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextField, {
|
|
334
|
+
label: m.from,
|
|
335
|
+
type: "email"
|
|
336
|
+
})
|
|
337
|
+
}),
|
|
338
|
+
/* @__PURE__ */ jsxs("fieldset", {
|
|
339
|
+
children: [
|
|
340
|
+
/* @__PURE__ */ jsx("legend", {
|
|
341
|
+
children: m.english
|
|
342
|
+
}),
|
|
343
|
+
/* @__PURE__ */ jsx(createForm.AppField, {
|
|
344
|
+
name: "enSubject",
|
|
345
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextField, {
|
|
346
|
+
label: m.subject
|
|
347
|
+
})
|
|
348
|
+
}),
|
|
349
|
+
/* @__PURE__ */ jsx(createForm.AppField, {
|
|
350
|
+
name: "enText",
|
|
351
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextAreaField, {
|
|
352
|
+
label: m.text
|
|
353
|
+
})
|
|
354
|
+
})
|
|
355
|
+
]
|
|
356
|
+
}),
|
|
357
|
+
/* @__PURE__ */ jsxs("fieldset", {
|
|
358
|
+
children: [
|
|
359
|
+
/* @__PURE__ */ jsx("legend", {
|
|
360
|
+
children: m.french
|
|
361
|
+
}),
|
|
362
|
+
/* @__PURE__ */ jsx(createForm.AppField, {
|
|
363
|
+
name: "frSubject",
|
|
364
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextField, {
|
|
365
|
+
label: m.subject
|
|
366
|
+
})
|
|
367
|
+
}),
|
|
368
|
+
/* @__PURE__ */ jsx(createForm.AppField, {
|
|
369
|
+
name: "frText",
|
|
370
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextAreaField, {
|
|
371
|
+
label: m.text
|
|
372
|
+
})
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
}),
|
|
376
|
+
failure && /* @__PURE__ */ jsx("p", {
|
|
377
|
+
role: "alert",
|
|
378
|
+
children: failure
|
|
379
|
+
}),
|
|
380
|
+
/* @__PURE__ */ jsx(createForm.SubmitButton, {
|
|
381
|
+
children: m.save
|
|
382
|
+
})
|
|
383
|
+
]
|
|
384
|
+
})
|
|
385
|
+
})
|
|
386
|
+
]
|
|
387
|
+
})
|
|
388
|
+
}),
|
|
389
|
+
/* @__PURE__ */ jsx(Dialog, {
|
|
390
|
+
open: confirming,
|
|
391
|
+
onOpenChange: setConfirming,
|
|
392
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
393
|
+
children: [
|
|
394
|
+
/* @__PURE__ */ jsx(DialogHeader, {
|
|
395
|
+
children: /* @__PURE__ */ jsx(DialogTitle, {
|
|
396
|
+
children: m.confirmCancel
|
|
397
|
+
})
|
|
398
|
+
}),
|
|
399
|
+
/* @__PURE__ */ jsx("p", {
|
|
400
|
+
children: m.cancelDescription
|
|
401
|
+
}),
|
|
402
|
+
failure && /* @__PURE__ */ jsx("p", {
|
|
403
|
+
role: "alert",
|
|
404
|
+
children: failure
|
|
405
|
+
}),
|
|
406
|
+
/* @__PURE__ */ jsx(Button, {
|
|
407
|
+
variant: "destructive",
|
|
408
|
+
disabled: busy,
|
|
409
|
+
onClick: () => void transition("cancel"),
|
|
410
|
+
children: m.confirmCancel
|
|
411
|
+
})
|
|
412
|
+
]
|
|
413
|
+
})
|
|
414
|
+
})
|
|
415
|
+
]
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
export { SendCampaignAdmin2 };
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogContent,
|
|
5
|
+
DialogHeader,
|
|
6
|
+
DialogTitle
|
|
7
|
+
} from "./chunk-tck9drx2.js";
|
|
8
|
+
|
|
9
|
+
// src/contacts.tsx
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { Schema } from "effect";
|
|
12
|
+
import {
|
|
13
|
+
CreateContact
|
|
14
|
+
} from "@krak-stack/notifications/admin/schema";
|
|
15
|
+
import {
|
|
16
|
+
DataTable
|
|
17
|
+
} from "@krak-stack/registry/data-table";
|
|
18
|
+
import { useAppForm } from "@krak-stack/registry/form";
|
|
19
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
20
|
+
var SendContacts2 = ({
|
|
21
|
+
page,
|
|
22
|
+
pending,
|
|
23
|
+
error,
|
|
24
|
+
messages,
|
|
25
|
+
defaultContactLocale,
|
|
26
|
+
onCreate,
|
|
27
|
+
onWithdraw,
|
|
28
|
+
inspection,
|
|
29
|
+
table
|
|
30
|
+
}) => {
|
|
31
|
+
const [creating, setCreating] = useState(false);
|
|
32
|
+
const [withdrawing, setWithdrawing] = useState();
|
|
33
|
+
const [failure, setFailure] = useState();
|
|
34
|
+
const defaultValues = {
|
|
35
|
+
name: "",
|
|
36
|
+
email: "",
|
|
37
|
+
locale: defaultContactLocale
|
|
38
|
+
};
|
|
39
|
+
const form = useAppForm({
|
|
40
|
+
defaultValues,
|
|
41
|
+
validators: { onSubmit: Schema.toStandardSchemaV1(CreateContact) },
|
|
42
|
+
onSubmit: async ({ value }) => {
|
|
43
|
+
setFailure(undefined);
|
|
44
|
+
try {
|
|
45
|
+
await onCreate(value);
|
|
46
|
+
setCreating(false);
|
|
47
|
+
form.reset();
|
|
48
|
+
} catch {
|
|
49
|
+
setFailure(messages.savingFailed);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const columns = [
|
|
54
|
+
{ field: "name", headerName: messages.name },
|
|
55
|
+
{ field: "email", headerName: messages.email },
|
|
56
|
+
{
|
|
57
|
+
field: "emailConsent",
|
|
58
|
+
headerName: messages.consent,
|
|
59
|
+
filterOptions: ["unknown", "subscribed", "unsubscribed"].map((value) => ({ value, label: messages[value] })),
|
|
60
|
+
cellRenderer: ({ data }) => messages[data.emailConsent]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
colId: "withdraw",
|
|
64
|
+
sortable: false,
|
|
65
|
+
filterable: false,
|
|
66
|
+
searchable: false,
|
|
67
|
+
hideable: false,
|
|
68
|
+
headerName: messages.withdraw,
|
|
69
|
+
cellRenderer: ({ data }) => /* @__PURE__ */ jsx(Button, {
|
|
70
|
+
variant: "outline",
|
|
71
|
+
size: "sm",
|
|
72
|
+
disabled: Boolean(withdrawing) || pending || data.emailConsent === "unsubscribed",
|
|
73
|
+
onClick: async () => {
|
|
74
|
+
setFailure(undefined);
|
|
75
|
+
setWithdrawing(data.id);
|
|
76
|
+
try {
|
|
77
|
+
await onWithdraw(data);
|
|
78
|
+
} catch {
|
|
79
|
+
setFailure(messages.savingFailed);
|
|
80
|
+
} finally {
|
|
81
|
+
setWithdrawing(undefined);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
children: messages.withdraw
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
if (inspection)
|
|
89
|
+
columns.push({
|
|
90
|
+
colId: "inspect",
|
|
91
|
+
sortable: false,
|
|
92
|
+
filterable: false,
|
|
93
|
+
searchable: false,
|
|
94
|
+
hideable: false,
|
|
95
|
+
headerName: inspection.label,
|
|
96
|
+
cellRenderer: ({ data }) => /* @__PURE__ */ jsx(Button, {
|
|
97
|
+
variant: "outline",
|
|
98
|
+
onClick: () => inspection.onSelect(data),
|
|
99
|
+
children: inspection.label
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
103
|
+
className: "space-y-4",
|
|
104
|
+
"aria-busy": pending,
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ jsxs("div", {
|
|
107
|
+
className: "flex items-start justify-between gap-4",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsxs("div", {
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx("h1", {
|
|
112
|
+
className: "text-2xl font-semibold",
|
|
113
|
+
children: messages.title
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsx("p", {
|
|
116
|
+
className: "text-muted-foreground",
|
|
117
|
+
children: messages.description
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx(Button, {
|
|
122
|
+
onClick: () => {
|
|
123
|
+
setFailure(undefined);
|
|
124
|
+
setCreating(true);
|
|
125
|
+
},
|
|
126
|
+
children: messages.create
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
}),
|
|
130
|
+
(error || failure) && /* @__PURE__ */ jsx("p", {
|
|
131
|
+
role: "alert",
|
|
132
|
+
children: error || failure
|
|
133
|
+
}),
|
|
134
|
+
/* @__PURE__ */ jsx(DataTable, {
|
|
135
|
+
columnDefs: columns,
|
|
136
|
+
rowData: page?.items ?? [],
|
|
137
|
+
getRowId: (contact) => contact.id,
|
|
138
|
+
features: { pagination: { mode: "client" } },
|
|
139
|
+
status: { loading: pending, error },
|
|
140
|
+
...table
|
|
141
|
+
}),
|
|
142
|
+
/* @__PURE__ */ jsx(Dialog, {
|
|
143
|
+
open: creating,
|
|
144
|
+
onOpenChange: setCreating,
|
|
145
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ jsx(DialogHeader, {
|
|
148
|
+
children: /* @__PURE__ */ jsx(DialogTitle, {
|
|
149
|
+
children: messages.create
|
|
150
|
+
})
|
|
151
|
+
}),
|
|
152
|
+
/* @__PURE__ */ jsx(form.AppForm, {
|
|
153
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
154
|
+
className: "space-y-4",
|
|
155
|
+
onSubmit: (event) => {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
form.handleSubmit();
|
|
158
|
+
},
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ jsx(form.AppField, {
|
|
161
|
+
name: "email",
|
|
162
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextField, {
|
|
163
|
+
label: messages.email,
|
|
164
|
+
type: "email"
|
|
165
|
+
})
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsx(form.AppField, {
|
|
168
|
+
name: "name",
|
|
169
|
+
children: (field) => /* @__PURE__ */ jsx(field.TextField, {
|
|
170
|
+
label: messages.name
|
|
171
|
+
})
|
|
172
|
+
}),
|
|
173
|
+
failure && /* @__PURE__ */ jsx("p", {
|
|
174
|
+
role: "alert",
|
|
175
|
+
children: failure
|
|
176
|
+
}),
|
|
177
|
+
/* @__PURE__ */ jsx(form.SubmitButton, {
|
|
178
|
+
children: messages.save
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
]
|
|
184
|
+
})
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
var SendContactDetails2 = ({
|
|
190
|
+
contact,
|
|
191
|
+
history,
|
|
192
|
+
messages: m,
|
|
193
|
+
error,
|
|
194
|
+
onClose,
|
|
195
|
+
onActivity,
|
|
196
|
+
table
|
|
197
|
+
}) => /* @__PURE__ */ jsxs("section", {
|
|
198
|
+
className: "space-y-4",
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ jsx("h2", {
|
|
201
|
+
className: "text-xl font-semibold",
|
|
202
|
+
children: m.title
|
|
203
|
+
}),
|
|
204
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
205
|
+
role: "alert",
|
|
206
|
+
children: error
|
|
207
|
+
}),
|
|
208
|
+
contact && /* @__PURE__ */ jsxs(Fragment, {
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx("dl", {
|
|
211
|
+
className: "grid gap-2 sm:grid-cols-2",
|
|
212
|
+
children: [
|
|
213
|
+
[m.id, contact.id],
|
|
214
|
+
[m.email, contact.email],
|
|
215
|
+
[m.name, contact.name],
|
|
216
|
+
[m.locale, contact.locale],
|
|
217
|
+
[m.consent, m.states[contact.emailConsent]],
|
|
218
|
+
[m.created, contact.createdAt.toLocaleString()],
|
|
219
|
+
[m.updated, contact.updatedAt.toLocaleString()]
|
|
220
|
+
].map(([label, value]) => /* @__PURE__ */ jsxs("div", {
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ jsx("dt", {
|
|
223
|
+
children: label
|
|
224
|
+
}),
|
|
225
|
+
/* @__PURE__ */ jsx("dd", {
|
|
226
|
+
children: value
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
}, label))
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ jsx(Button, {
|
|
232
|
+
variant: "outline",
|
|
233
|
+
onClick: () => onActivity(contact.id),
|
|
234
|
+
children: m.activity
|
|
235
|
+
})
|
|
236
|
+
]
|
|
237
|
+
}),
|
|
238
|
+
/* @__PURE__ */ jsx(DataTable, {
|
|
239
|
+
rowData: history?.items ?? [],
|
|
240
|
+
getRowId: (event) => event.requestId,
|
|
241
|
+
features: { pagination: { mode: "client" } },
|
|
242
|
+
...table,
|
|
243
|
+
columnDefs: [
|
|
244
|
+
{ field: "requestId", headerName: m.requestId },
|
|
245
|
+
{
|
|
246
|
+
field: "status",
|
|
247
|
+
headerName: m.status,
|
|
248
|
+
cellRenderer: ({ data }) => m.states[data.status]
|
|
249
|
+
},
|
|
250
|
+
{ field: "source", headerName: m.source },
|
|
251
|
+
{ field: "actor", headerName: m.actor },
|
|
252
|
+
{ field: "noticeVersion", headerName: m.noticeVersion },
|
|
253
|
+
{
|
|
254
|
+
field: "occurredAt",
|
|
255
|
+
type: "date",
|
|
256
|
+
headerName: m.occurred,
|
|
257
|
+
cellRenderer: ({ data }) => data.occurredAt.toLocaleString()
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
}),
|
|
261
|
+
/* @__PURE__ */ jsx("div", {
|
|
262
|
+
className: "flex gap-2",
|
|
263
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
264
|
+
variant: "outline",
|
|
265
|
+
onClick: onClose,
|
|
266
|
+
children: m.close
|
|
267
|
+
})
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
export { SendContacts2, SendContactDetails2 };
|