@krak-stack/notifications-admin 0.0.0-stage → 0.1.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 +9 -0
- package/README.md +86 -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-8nawv50q.js +688 -0
- package/dist/chunk-dxjvd9tb.js +419 -0
- package/dist/chunk-nk9ge6g9.js +378 -0
- package/dist/chunk-t0qhq7pj.js +272 -0
- package/dist/chunk-tck9drx2.js +134 -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 +7 -0
- package/dist/delivery.atom.d.ts +196 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +25 -0
- package/dist/operations.atom.d.ts +244 -0
- package/dist/operations.d.ts +106 -0
- package/dist/operations.js +12 -0
- package/package.json +76 -4
- package/tailwind.css +2 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn,
|
|
3
|
+
Button,
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogHeader,
|
|
7
|
+
DialogTitle
|
|
8
|
+
} from "./chunk-tck9drx2.js";
|
|
9
|
+
|
|
10
|
+
// src/deliveries.tsx
|
|
11
|
+
import {
|
|
12
|
+
DataTable
|
|
13
|
+
} from "@krak-stack/registry/data-table";
|
|
14
|
+
|
|
15
|
+
// ../../src/components/ui/tabs.tsx
|
|
16
|
+
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
|
|
17
|
+
import { cva } from "class-variance-authority";
|
|
18
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
function Tabs({
|
|
20
|
+
className,
|
|
21
|
+
orientation = "horizontal",
|
|
22
|
+
...props
|
|
23
|
+
}) {
|
|
24
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.Root, {
|
|
25
|
+
"data-slot": "tabs",
|
|
26
|
+
"data-orientation": orientation,
|
|
27
|
+
className: cn("group/tabs flex gap-2 data-horizontal:flex-col", className),
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
var tabsListVariants = cva("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-9 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none", {
|
|
32
|
+
variants: {
|
|
33
|
+
variant: {
|
|
34
|
+
default: "bg-muted",
|
|
35
|
+
line: "gap-1 bg-transparent"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
variant: "default"
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
function TabsList({
|
|
43
|
+
className,
|
|
44
|
+
variant = "default",
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.List, {
|
|
48
|
+
"data-slot": "tabs-list",
|
|
49
|
+
"data-variant": variant,
|
|
50
|
+
className: cn(tabsListVariants({ variant }), className),
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function TabsTrigger({ className, ...props }) {
|
|
55
|
+
return /* @__PURE__ */ jsx(TabsPrimitive.Tab, {
|
|
56
|
+
"data-slot": "tabs-trigger",
|
|
57
|
+
className: cn("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent", "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground", "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100", className),
|
|
58
|
+
...props
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/deliveries.tsx
|
|
63
|
+
import { jsx as jsx2, jsxs, Fragment } from "react/jsx-runtime";
|
|
64
|
+
var metricKeys = [
|
|
65
|
+
"total",
|
|
66
|
+
"queued",
|
|
67
|
+
"processing",
|
|
68
|
+
"retrying",
|
|
69
|
+
"accepted",
|
|
70
|
+
"failed",
|
|
71
|
+
"suppressed",
|
|
72
|
+
"cancelled",
|
|
73
|
+
"feedbackCovered",
|
|
74
|
+
"feedbackUnavailable",
|
|
75
|
+
"confirmed",
|
|
76
|
+
"hardBounced",
|
|
77
|
+
"softBounced",
|
|
78
|
+
"complained"
|
|
79
|
+
];
|
|
80
|
+
var NotificationDeliveries2 = (p) => {
|
|
81
|
+
const m = p.messages;
|
|
82
|
+
const c = m.common;
|
|
83
|
+
const columns = [
|
|
84
|
+
{ field: "recipientAddress", headerName: c.email },
|
|
85
|
+
{
|
|
86
|
+
field: "source",
|
|
87
|
+
headerName: m.source,
|
|
88
|
+
filterOptions: ["contacts", "engine"].map((value) => ({
|
|
89
|
+
value,
|
|
90
|
+
label: value === "contacts" ? m.sources.contacts : m.sources.engine
|
|
91
|
+
})),
|
|
92
|
+
cellRenderer: ({ data }) => m.sources[data.source]
|
|
93
|
+
},
|
|
94
|
+
{ field: "recipientUserId", headerName: m.recipientUserId },
|
|
95
|
+
{ field: "organizationId", headerName: m.organizationId },
|
|
96
|
+
{ field: "workspaceId", headerName: m.workspaceId },
|
|
97
|
+
{ field: "eventKey", headerName: m.eventKey },
|
|
98
|
+
{ field: "template", headerName: m.template },
|
|
99
|
+
{
|
|
100
|
+
field: "purpose",
|
|
101
|
+
headerName: c.purpose,
|
|
102
|
+
filterOptions: Object.entries(m.purposes).map(([value, label]) => ({
|
|
103
|
+
value,
|
|
104
|
+
label
|
|
105
|
+
})),
|
|
106
|
+
cellRenderer: ({ data }) => m.purposes[data.purpose]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
field: "status",
|
|
110
|
+
headerName: c.status,
|
|
111
|
+
filterOptions: Object.entries(c.statuses).map(([value, label]) => ({
|
|
112
|
+
value,
|
|
113
|
+
label
|
|
114
|
+
})),
|
|
115
|
+
cellRenderer: ({ data }) => c.statuses[data.status]
|
|
116
|
+
},
|
|
117
|
+
{ field: "attempts", headerName: c.attempts, type: "number" },
|
|
118
|
+
{ field: "provider", headerName: c.provider },
|
|
119
|
+
{ field: "createdAt", headerName: c.created, type: "date" },
|
|
120
|
+
{ field: "sentAt", headerName: c.accepted, type: "date" },
|
|
121
|
+
{
|
|
122
|
+
colId: "inspect",
|
|
123
|
+
headerName: c.inspect,
|
|
124
|
+
sortable: false,
|
|
125
|
+
searchable: false,
|
|
126
|
+
filterable: false,
|
|
127
|
+
hideable: false,
|
|
128
|
+
cellRenderer: ({ data }) => /* @__PURE__ */ jsx2(Button, {
|
|
129
|
+
variant: "outline",
|
|
130
|
+
onClick: () => p.onInspect(data.id),
|
|
131
|
+
children: c.inspect
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
];
|
|
135
|
+
const delivery = p.inspection?.delivery;
|
|
136
|
+
const metrics = {
|
|
137
|
+
...c.metrics,
|
|
138
|
+
feedbackCovered: m.feedbackCovered,
|
|
139
|
+
feedbackUnavailable: m.feedbackUnavailable
|
|
140
|
+
};
|
|
141
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
142
|
+
className: "space-y-4",
|
|
143
|
+
"aria-busy": p.pending,
|
|
144
|
+
children: [
|
|
145
|
+
/* @__PURE__ */ jsxs("header", {
|
|
146
|
+
className: "flex justify-between gap-4",
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ jsxs("div", {
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ jsx2("h1", {
|
|
151
|
+
className: "text-2xl font-semibold",
|
|
152
|
+
children: m.title
|
|
153
|
+
}),
|
|
154
|
+
/* @__PURE__ */ jsx2("p", {
|
|
155
|
+
children: m.description
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
}),
|
|
159
|
+
/* @__PURE__ */ jsx2(Button, {
|
|
160
|
+
variant: "outline",
|
|
161
|
+
onClick: p.onRefresh,
|
|
162
|
+
children: c.refresh
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ jsx2(Tabs, {
|
|
167
|
+
value: p.source,
|
|
168
|
+
onValueChange: (value) => {
|
|
169
|
+
if (value === "all" || value === "contacts" || value === "engine")
|
|
170
|
+
p.onSource(value);
|
|
171
|
+
},
|
|
172
|
+
children: /* @__PURE__ */ jsx2(TabsList, {
|
|
173
|
+
"aria-label": m.source,
|
|
174
|
+
children: ["all", "contacts", "engine"].map((source) => /* @__PURE__ */ jsx2(TabsTrigger, {
|
|
175
|
+
value: source,
|
|
176
|
+
children: m.sources[source]
|
|
177
|
+
}, source))
|
|
178
|
+
})
|
|
179
|
+
}),
|
|
180
|
+
/* @__PURE__ */ jsx2(Tabs, {
|
|
181
|
+
value: p.view,
|
|
182
|
+
onValueChange: (value) => {
|
|
183
|
+
if (value === "overview" || value === "activity")
|
|
184
|
+
p.onView(value);
|
|
185
|
+
},
|
|
186
|
+
children: /* @__PURE__ */ jsx2(TabsList, {
|
|
187
|
+
"aria-label": m.title,
|
|
188
|
+
children: ["overview", "activity"].map((view) => /* @__PURE__ */ jsx2(TabsTrigger, {
|
|
189
|
+
value: view,
|
|
190
|
+
children: c.views[view]
|
|
191
|
+
}, view))
|
|
192
|
+
})
|
|
193
|
+
}),
|
|
194
|
+
p.error && /* @__PURE__ */ jsx2("p", {
|
|
195
|
+
role: "alert",
|
|
196
|
+
children: p.error
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ jsx2("p", {
|
|
199
|
+
children: m.feedbackNotice
|
|
200
|
+
}),
|
|
201
|
+
p.view === "overview" && p.overview && /* @__PURE__ */ jsx2("dl", {
|
|
202
|
+
className: "grid gap-3 sm:grid-cols-3",
|
|
203
|
+
children: metricKeys.map((key) => /* @__PURE__ */ jsxs("div", {
|
|
204
|
+
role: "group",
|
|
205
|
+
"aria-label": metrics[key],
|
|
206
|
+
className: "rounded border p-3",
|
|
207
|
+
children: [
|
|
208
|
+
/* @__PURE__ */ jsx2("dt", {
|
|
209
|
+
children: metrics[key]
|
|
210
|
+
}),
|
|
211
|
+
/* @__PURE__ */ jsx2("dd", {
|
|
212
|
+
className: "text-2xl font-semibold",
|
|
213
|
+
children: p.overview?.[key]
|
|
214
|
+
})
|
|
215
|
+
]
|
|
216
|
+
}, key))
|
|
217
|
+
}),
|
|
218
|
+
p.view === "activity" && /* @__PURE__ */ jsx2(DataTable, {
|
|
219
|
+
rowData: p.activity?.items ?? [],
|
|
220
|
+
columnDefs: columns,
|
|
221
|
+
getRowId: (row) => row.id,
|
|
222
|
+
state: p.table,
|
|
223
|
+
onStateChange: p.onTable,
|
|
224
|
+
status: { loading: p.pending, error: p.error },
|
|
225
|
+
features: {
|
|
226
|
+
pagination: { mode: "server", rowCount: p.total },
|
|
227
|
+
refresh: p.onRefresh
|
|
228
|
+
},
|
|
229
|
+
messages: {
|
|
230
|
+
en: { empty: c.empty, loading: c.loading },
|
|
231
|
+
fr: { empty: c.empty, loading: c.loading }
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ jsx2(Dialog, {
|
|
235
|
+
open: p.inspecting,
|
|
236
|
+
onOpenChange: (open) => {
|
|
237
|
+
if (!open)
|
|
238
|
+
p.onInspect(undefined);
|
|
239
|
+
},
|
|
240
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
241
|
+
className: "max-h-[90vh] overflow-auto sm:max-w-4xl",
|
|
242
|
+
children: [
|
|
243
|
+
/* @__PURE__ */ jsx2(DialogHeader, {
|
|
244
|
+
children: /* @__PURE__ */ jsx2(DialogTitle, {
|
|
245
|
+
children: c.inspect
|
|
246
|
+
})
|
|
247
|
+
}),
|
|
248
|
+
p.inspectionError && /* @__PURE__ */ jsx2("p", {
|
|
249
|
+
role: "alert",
|
|
250
|
+
children: p.inspectionError
|
|
251
|
+
}),
|
|
252
|
+
!delivery && !p.inspectionError && /* @__PURE__ */ jsx2("p", {
|
|
253
|
+
role: "status",
|
|
254
|
+
children: c.loading
|
|
255
|
+
}),
|
|
256
|
+
delivery && /* @__PURE__ */ jsxs(Fragment, {
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ jsx2("dl", {
|
|
259
|
+
className: "grid gap-2 break-all sm:grid-cols-2",
|
|
260
|
+
children: [
|
|
261
|
+
[c.id, delivery.id],
|
|
262
|
+
[m.source, m.sources[delivery.source]],
|
|
263
|
+
[c.email, delivery.recipientAddress],
|
|
264
|
+
[m.recipientUserId, delivery.recipientUserId],
|
|
265
|
+
[m.organizationId, delivery.organizationId],
|
|
266
|
+
[m.workspaceId, delivery.workspaceId],
|
|
267
|
+
[m.eventKey, delivery.eventKey],
|
|
268
|
+
[m.template, delivery.template],
|
|
269
|
+
[c.purpose, m.purposes[delivery.purpose]],
|
|
270
|
+
[c.status, c.statuses[delivery.status]],
|
|
271
|
+
[c.provider, delivery.provider],
|
|
272
|
+
[c.providerMessageId, delivery.providerMessageId],
|
|
273
|
+
[c.reason, delivery.errorMessage],
|
|
274
|
+
[
|
|
275
|
+
c.attempts,
|
|
276
|
+
`${delivery.attempts} / ${delivery.maxAttempts}`
|
|
277
|
+
]
|
|
278
|
+
].map(([label, value]) => /* @__PURE__ */ jsxs("div", {
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ jsx2("dt", {
|
|
281
|
+
className: "font-semibold",
|
|
282
|
+
children: label
|
|
283
|
+
}),
|
|
284
|
+
/* @__PURE__ */ jsx2("dd", {
|
|
285
|
+
children: value ?? "—"
|
|
286
|
+
})
|
|
287
|
+
]
|
|
288
|
+
}, label))
|
|
289
|
+
}),
|
|
290
|
+
delivery.contactId && p.onContact && /* @__PURE__ */ jsx2(Button, {
|
|
291
|
+
variant: "outline",
|
|
292
|
+
onClick: () => p.onContact?.(delivery.contactId),
|
|
293
|
+
children: c.contactId
|
|
294
|
+
}),
|
|
295
|
+
delivery.campaignId && p.onCampaign && /* @__PURE__ */ jsx2(Button, {
|
|
296
|
+
variant: "outline",
|
|
297
|
+
onClick: () => p.onCampaign?.(delivery.campaignId),
|
|
298
|
+
children: c.campaign
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ jsx2("h3", {
|
|
301
|
+
children: m.references
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ jsx2("dl", {
|
|
304
|
+
children: p.inspection?.references.map((ref) => /* @__PURE__ */ jsxs("div", {
|
|
305
|
+
children: [
|
|
306
|
+
/* @__PURE__ */ jsx2("dt", {
|
|
307
|
+
children: ref.namespace
|
|
308
|
+
}),
|
|
309
|
+
/* @__PURE__ */ jsx2("dd", {
|
|
310
|
+
children: ref.value
|
|
311
|
+
})
|
|
312
|
+
]
|
|
313
|
+
}, `${ref.namespace}:${ref.value}`))
|
|
314
|
+
}),
|
|
315
|
+
/* @__PURE__ */ jsx2("h3", {
|
|
316
|
+
children: c.attempts
|
|
317
|
+
}),
|
|
318
|
+
/* @__PURE__ */ jsx2(DataTable, {
|
|
319
|
+
rowData: p.inspection?.attempts ?? [],
|
|
320
|
+
getRowId: (row) => row.id,
|
|
321
|
+
columnDefs: [
|
|
322
|
+
{
|
|
323
|
+
field: "generation",
|
|
324
|
+
headerName: c.generation,
|
|
325
|
+
type: "number"
|
|
326
|
+
},
|
|
327
|
+
{ field: "attempt", headerName: c.attempts, type: "number" },
|
|
328
|
+
{
|
|
329
|
+
colId: "outcome",
|
|
330
|
+
headerName: c.outcome,
|
|
331
|
+
cellRenderer: ({ data }) => data.outcome ? c.outcomes[data.outcome._tag] : c.pending
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
colId: "reason",
|
|
335
|
+
headerName: c.reason,
|
|
336
|
+
cellRenderer: ({ data }) => {
|
|
337
|
+
const o = data.outcome;
|
|
338
|
+
if (!o)
|
|
339
|
+
return "—";
|
|
340
|
+
switch (o._tag) {
|
|
341
|
+
case "Sent":
|
|
342
|
+
return o.providerMessageId ?? "—";
|
|
343
|
+
case "Skipped":
|
|
344
|
+
return o.reason;
|
|
345
|
+
default:
|
|
346
|
+
return o.message;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
{ field: "startedAt", headerName: c.started, type: "date" },
|
|
351
|
+
{
|
|
352
|
+
field: "completedAt",
|
|
353
|
+
headerName: c.completed,
|
|
354
|
+
type: "date"
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
features: { pagination: { mode: "client" } }
|
|
358
|
+
})
|
|
359
|
+
]
|
|
360
|
+
}),
|
|
361
|
+
/* @__PURE__ */ jsx2(Button, {
|
|
362
|
+
variant: "outline",
|
|
363
|
+
onClick: p.onRefresh,
|
|
364
|
+
children: c.refresh
|
|
365
|
+
}),
|
|
366
|
+
/* @__PURE__ */ jsx2(Button, {
|
|
367
|
+
variant: "outline",
|
|
368
|
+
onClick: () => p.onInspect(undefined),
|
|
369
|
+
children: c.close
|
|
370
|
+
})
|
|
371
|
+
]
|
|
372
|
+
})
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
export { Tabs, TabsList, TabsTrigger, NotificationDeliveries2 };
|
|
@@ -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 };
|