@prenta/admin 2.9.3 → 2.11.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 +63 -0
- package/dist/AdminRoot.d.ts.map +1 -1
- package/dist/AdminRoot.js +5 -3
- package/dist/AdminRoot.js.map +1 -1
- package/dist/__tests__/components/attribution-rows.test.js +1 -1
- package/dist/__tests__/components/attribution-rows.test.js.map +1 -1
- package/dist/__tests__/components/date-range-picker.test.d.ts +2 -0
- package/dist/__tests__/components/date-range-picker.test.d.ts.map +1 -0
- package/dist/__tests__/components/date-range-picker.test.js +59 -0
- package/dist/__tests__/components/date-range-picker.test.js.map +1 -0
- package/dist/__tests__/components/form-build-model.test.d.ts +2 -0
- package/dist/__tests__/components/form-build-model.test.d.ts.map +1 -0
- package/dist/__tests__/components/form-build-model.test.js +162 -0
- package/dist/__tests__/components/form-build-model.test.js.map +1 -0
- package/dist/__tests__/components/form-build.test.d.ts +2 -0
- package/dist/__tests__/components/form-build.test.d.ts.map +1 -0
- package/dist/__tests__/components/form-build.test.js +120 -0
- package/dist/__tests__/components/form-build.test.js.map +1 -0
- package/dist/__tests__/components/qa-a11y.render.test.js +1 -17
- package/dist/__tests__/components/qa-a11y.render.test.js.map +1 -1
- package/dist/__tests__/lib/batch-wizard.test.js +2 -0
- package/dist/__tests__/lib/batch-wizard.test.js.map +1 -1
- package/dist/__tests__/lib/forms-settings-normalize.test.d.ts +2 -0
- package/dist/__tests__/lib/forms-settings-normalize.test.d.ts.map +1 -0
- package/dist/__tests__/lib/forms-settings-normalize.test.js +16 -0
- package/dist/__tests__/lib/forms-settings-normalize.test.js.map +1 -0
- package/dist/__tests__/lib/recaptcha.test.d.ts +2 -0
- package/dist/__tests__/lib/recaptcha.test.d.ts.map +1 -0
- package/dist/__tests__/lib/recaptcha.test.js +57 -0
- package/dist/__tests__/lib/recaptcha.test.js.map +1 -0
- package/dist/__tests__/views/dashboard.test.js +105 -30
- package/dist/__tests__/views/dashboard.test.js.map +1 -1
- package/dist/__tests__/views/form-editor.render.test.js +17 -9
- package/dist/__tests__/views/form-editor.render.test.js.map +1 -1
- package/dist/__tests__/views/form-entries.render.test.js +23 -9
- package/dist/__tests__/views/form-entries.render.test.js.map +1 -1
- package/dist/__tests__/views/form-submissions.render.test.js +13 -14
- package/dist/__tests__/views/form-submissions.render.test.js.map +1 -1
- package/dist/__tests__/views/forms-list.render.test.js +139 -16
- package/dist/__tests__/views/forms-list.render.test.js.map +1 -1
- package/dist/__tests__/views/forms-settings.fixture.d.ts +3 -0
- package/dist/__tests__/views/forms-settings.fixture.d.ts.map +1 -0
- package/dist/__tests__/views/forms-settings.fixture.js +31 -0
- package/dist/__tests__/views/forms-settings.fixture.js.map +1 -0
- package/dist/__tests__/views/forms-settings.render.test.d.ts +2 -0
- package/dist/__tests__/views/forms-settings.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/forms-settings.render.test.js +226 -0
- package/dist/__tests__/views/forms-settings.render.test.js.map +1 -0
- package/dist/__tests__/views/inbox-format.test.d.ts +2 -0
- package/dist/__tests__/views/inbox-format.test.d.ts.map +1 -0
- package/dist/__tests__/views/inbox-format.test.js +47 -0
- package/dist/__tests__/views/inbox-format.test.js.map +1 -0
- package/dist/__tests__/views/jobs-wizard.render.test.js +17 -3
- package/dist/__tests__/views/jobs-wizard.render.test.js.map +1 -1
- package/dist/__tests__/views/login-captcha.render.test.d.ts +2 -0
- package/dist/__tests__/views/login-captcha.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/login-captcha.render.test.js +80 -0
- package/dist/__tests__/views/login-captcha.render.test.js.map +1 -0
- package/dist/__tests__/views/onboarding-block.render.test.js +9 -7
- package/dist/__tests__/views/onboarding-block.render.test.js.map +1 -1
- package/dist/components/forms/BlocklistDialog.d.ts +19 -0
- package/dist/components/forms/BlocklistDialog.d.ts.map +1 -0
- package/dist/components/forms/BlocklistDialog.js +225 -0
- package/dist/components/forms/BlocklistDialog.js.map +1 -0
- package/dist/components/forms/ExportMenu.d.ts +3 -1
- package/dist/components/forms/ExportMenu.d.ts.map +1 -1
- package/dist/components/forms/ExportMenu.js +2 -2
- package/dist/components/forms/ExportMenu.js.map +1 -1
- package/dist/components/forms/FieldOptions.d.ts +11 -0
- package/dist/components/forms/FieldOptions.d.ts.map +1 -0
- package/dist/components/forms/FieldOptions.js +106 -0
- package/dist/components/forms/FieldOptions.js.map +1 -0
- package/dist/components/forms/FormBuild.d.ts +11 -0
- package/dist/components/forms/FormBuild.d.ts.map +1 -0
- package/dist/components/forms/FormBuild.js +299 -0
- package/dist/components/forms/FormBuild.js.map +1 -0
- package/dist/components/forms/FormsListTable.d.ts +14 -0
- package/dist/components/forms/FormsListTable.d.ts.map +1 -0
- package/dist/components/forms/FormsListTable.js +84 -0
- package/dist/components/forms/FormsListTable.js.map +1 -0
- package/dist/components/forms/form-build-model.d.ts +74 -0
- package/dist/components/forms/form-build-model.d.ts.map +1 -0
- package/dist/components/forms/form-build-model.js +297 -0
- package/dist/components/forms/form-build-model.js.map +1 -0
- package/dist/components/forms/form-build-ui.d.ts +35 -0
- package/dist/components/forms/form-build-ui.d.ts.map +1 -0
- package/dist/components/forms/form-build-ui.js +59 -0
- package/dist/components/forms/form-build-ui.js.map +1 -0
- package/dist/components/forms/primitives.d.ts +3 -22
- package/dist/components/forms/primitives.d.ts.map +1 -1
- package/dist/components/forms/primitives.js +4 -19
- package/dist/components/forms/primitives.js.map +1 -1
- package/dist/components/ui/Badge.d.ts +1 -1
- package/dist/components/ui/Card.d.ts +1 -1
- package/dist/components/ui/DateRangePicker.d.ts +7 -0
- package/dist/components/ui/DateRangePicker.d.ts.map +1 -0
- package/dist/components/ui/DateRangePicker.js +112 -0
- package/dist/components/ui/DateRangePicker.js.map +1 -0
- package/dist/components/ui/Input.d.ts +1 -1
- package/dist/components/ui/Segmented.d.ts +3 -1
- package/dist/components/ui/Segmented.d.ts.map +1 -1
- package/dist/components/ui/Segmented.js +3 -3
- package/dist/components/ui/Segmented.js.map +1 -1
- package/dist/components/ui/StatusBadge.d.ts +3 -2
- package/dist/components/ui/StatusBadge.d.ts.map +1 -1
- package/dist/components/ui/StatusBadge.js +9 -3
- package/dist/components/ui/StatusBadge.js.map +1 -1
- package/dist/components/ui/Toggle.d.ts +1 -1
- package/dist/components/ui/Toggle.d.ts.map +1 -1
- package/dist/components/ui/Toggle.js +3 -0
- package/dist/components/ui/Toggle.js.map +1 -1
- package/dist/components/ui/UnderlineTabs.d.ts +5 -1
- package/dist/components/ui/UnderlineTabs.d.ts.map +1 -1
- package/dist/components/ui/UnderlineTabs.js +14 -11
- package/dist/components/ui/UnderlineTabs.js.map +1 -1
- package/dist/layout/Sidebar.js +3 -1
- package/dist/layout/Sidebar.js.map +1 -1
- package/dist/lib/batch-wizard.d.ts +1 -1
- package/dist/lib/batch-wizard.d.ts.map +1 -1
- package/dist/lib/batch-wizard.js +2 -2
- package/dist/lib/batch-wizard.js.map +1 -1
- package/dist/lib/entry-attribution.d.ts +13 -0
- package/dist/lib/entry-attribution.d.ts.map +1 -0
- package/dist/lib/entry-attribution.js +81 -0
- package/dist/lib/entry-attribution.js.map +1 -0
- package/dist/lib/forms-service.d.ts +133 -0
- package/dist/lib/forms-service.d.ts.map +1 -1
- package/dist/lib/forms-service.js +119 -0
- package/dist/lib/forms-service.js.map +1 -1
- package/dist/lib/job-drawer.d.ts +1 -0
- package/dist/lib/job-drawer.d.ts.map +1 -1
- package/dist/lib/job-drawer.js +23 -1
- package/dist/lib/job-drawer.js.map +1 -1
- package/dist/lib/job-view.d.ts +6 -0
- package/dist/lib/job-view.d.ts.map +1 -1
- package/dist/lib/job-view.js +7 -0
- package/dist/lib/job-view.js.map +1 -1
- package/dist/lib/recaptcha.d.ts +8 -0
- package/dist/lib/recaptcha.d.ts.map +1 -0
- package/dist/lib/recaptcha.js +73 -0
- package/dist/lib/recaptcha.js.map +1 -0
- package/dist/prenta-admin.css +1 -1
- package/dist/router/admin-routes.d.ts.map +1 -1
- package/dist/router/admin-routes.js +1 -0
- package/dist/router/admin-routes.js.map +1 -1
- package/dist/views/Dashboard.d.ts.map +1 -1
- package/dist/views/Dashboard.js +438 -309
- package/dist/views/Dashboard.js.map +1 -1
- package/dist/views/FormEditor.d.ts.map +1 -1
- package/dist/views/FormEditor.js +68 -13
- package/dist/views/FormEditor.js.map +1 -1
- package/dist/views/FormEntries.d.ts.map +1 -1
- package/dist/views/FormEntries.js +4 -190
- package/dist/views/FormEntries.js.map +1 -1
- package/dist/views/FormSubmissions.d.ts +1 -1
- package/dist/views/FormSubmissions.d.ts.map +1 -1
- package/dist/views/FormSubmissions.js +6 -195
- package/dist/views/FormSubmissions.js.map +1 -1
- package/dist/views/Forms.d.ts +11 -1
- package/dist/views/Forms.d.ts.map +1 -1
- package/dist/views/Forms.js +141 -93
- package/dist/views/Forms.js.map +1 -1
- package/dist/views/FormsSettings.d.ts +6 -1
- package/dist/views/FormsSettings.d.ts.map +1 -1
- package/dist/views/FormsSettings.js +527 -30
- package/dist/views/FormsSettings.js.map +1 -1
- package/dist/views/Jobs/DrawerReview.d.ts.map +1 -1
- package/dist/views/Jobs/DrawerReview.js +8 -7
- package/dist/views/Jobs/DrawerReview.js.map +1 -1
- package/dist/views/Jobs/NewBatchJob.d.ts.map +1 -1
- package/dist/views/Jobs/NewBatchJob.js +2 -1
- package/dist/views/Jobs/NewBatchJob.js.map +1 -1
- package/dist/views/Login.d.ts.map +1 -1
- package/dist/views/Login.js +30 -11
- package/dist/views/Login.js.map +1 -1
- package/dist/views/SpamFolder.js +1 -1
- package/dist/views/SpamFolder.js.map +1 -1
- package/dist/views/dashboard/Delta.d.ts +7 -0
- package/dist/views/dashboard/Delta.d.ts.map +1 -0
- package/dist/views/dashboard/Delta.js +21 -0
- package/dist/views/dashboard/Delta.js.map +1 -0
- package/dist/views/dashboard/KpiCard.d.ts +22 -0
- package/dist/views/dashboard/KpiCard.d.ts.map +1 -0
- package/dist/views/dashboard/KpiCard.js +15 -0
- package/dist/views/dashboard/KpiCard.js.map +1 -0
- package/dist/views/dashboard/Sparkline.d.ts +11 -0
- package/dist/views/dashboard/Sparkline.d.ts.map +1 -0
- package/dist/views/dashboard/Sparkline.js +15 -0
- package/dist/views/dashboard/Sparkline.js.map +1 -0
- package/dist/views/dashboard/TrendChart.d.ts +8 -0
- package/dist/views/dashboard/TrendChart.d.ts.map +1 -0
- package/dist/views/dashboard/TrendChart.js +98 -0
- package/dist/views/dashboard/TrendChart.js.map +1 -0
- package/dist/views/dashboard/dashboard-date.d.ts +33 -0
- package/dist/views/dashboard/dashboard-date.d.ts.map +1 -0
- package/dist/views/dashboard/dashboard-date.js +136 -0
- package/dist/views/dashboard/dashboard-date.js.map +1 -0
- package/dist/views/entries/EntriesInbox.d.ts +8 -0
- package/dist/views/entries/EntriesInbox.d.ts.map +1 -0
- package/dist/views/entries/EntriesInbox.js +516 -0
- package/dist/views/entries/EntriesInbox.js.map +1 -0
- package/dist/views/entries/inbox-format.d.ts +27 -0
- package/dist/views/entries/inbox-format.d.ts.map +1 -0
- package/dist/views/entries/inbox-format.js +119 -0
- package/dist/views/entries/inbox-format.js.map +1 -0
- package/dist/views/settings/CaptchaStatusCard.js +2 -2
- package/dist/views/settings/CaptchaStatusCard.js.map +1 -1
- package/package.json +4 -4
- package/src/AdminRoot.tsx +7 -3
- package/src/__tests__/components/attribution-rows.test.ts +1 -1
- package/src/__tests__/components/date-range-picker.test.tsx +69 -0
- package/src/__tests__/components/form-build-model.test.ts +200 -0
- package/src/__tests__/components/form-build.test.tsx +157 -0
- package/src/__tests__/components/qa-a11y.render.test.tsx +1 -29
- package/src/__tests__/lib/batch-wizard.test.ts +2 -0
- package/src/__tests__/lib/forms-settings-normalize.test.ts +17 -0
- package/src/__tests__/lib/recaptcha.test.ts +63 -0
- package/src/__tests__/views/dashboard.test.tsx +110 -32
- package/src/__tests__/views/form-editor.render.test.tsx +18 -10
- package/src/__tests__/views/form-entries.render.test.tsx +27 -9
- package/src/__tests__/views/form-submissions.render.test.tsx +15 -14
- package/src/__tests__/views/forms-list.render.test.tsx +157 -17
- package/src/__tests__/views/forms-settings.fixture.ts +32 -0
- package/src/__tests__/views/forms-settings.render.test.tsx +274 -0
- package/src/__tests__/views/inbox-format.test.ts +72 -0
- package/src/__tests__/views/jobs-wizard.render.test.tsx +18 -3
- package/src/__tests__/views/login-captcha.render.test.tsx +94 -0
- package/src/__tests__/views/onboarding-block.render.test.tsx +9 -7
- package/src/components/forms/BlocklistDialog.tsx +552 -0
- package/src/components/forms/ExportMenu.tsx +8 -2
- package/src/components/forms/FieldOptions.tsx +629 -0
- package/src/components/forms/FormBuild.tsx +900 -0
- package/src/components/forms/FormsListTable.tsx +300 -0
- package/src/components/forms/form-build-model.ts +365 -0
- package/src/components/forms/form-build-ui.tsx +130 -0
- package/src/components/forms/primitives.tsx +6 -55
- package/src/components/ui/DateRangePicker.tsx +358 -0
- package/src/components/ui/Segmented.tsx +9 -2
- package/src/components/ui/StatusBadge.tsx +17 -4
- package/src/components/ui/Toggle.tsx +3 -0
- package/src/components/ui/UnderlineTabs.tsx +20 -9
- package/src/layout/Sidebar.tsx +4 -2
- package/src/lib/batch-wizard.ts +2 -2
- package/src/lib/entry-attribution.ts +94 -0
- package/src/lib/forms-service.ts +243 -0
- package/src/lib/job-drawer.ts +21 -1
- package/src/lib/job-view.ts +7 -0
- package/src/lib/recaptcha.ts +84 -0
- package/src/router/admin-routes.ts +1 -0
- package/src/styles/theme.css +86 -0
- package/src/views/Dashboard.tsx +1183 -772
- package/src/views/FormEditor.tsx +397 -199
- package/src/views/FormEntries.tsx +3 -422
- package/src/views/FormSubmissions.tsx +5 -411
- package/src/views/Forms.tsx +333 -321
- package/src/views/FormsSettings.tsx +1616 -73
- package/src/views/Jobs/DrawerReview.tsx +14 -8
- package/src/views/Jobs/NewBatchJob.tsx +5 -1
- package/src/views/Login.tsx +35 -11
- package/src/views/SpamFolder.tsx +2 -2
- package/src/views/dashboard/Delta.tsx +44 -0
- package/src/views/dashboard/KpiCard.tsx +98 -0
- package/src/views/dashboard/Sparkline.tsx +51 -0
- package/src/views/dashboard/TrendChart.tsx +246 -0
- package/src/views/dashboard/dashboard-date.ts +168 -0
- package/src/views/entries/EntriesInbox.tsx +1277 -0
- package/src/views/entries/inbox-format.ts +128 -0
- package/src/views/settings/CaptchaStatusCard.tsx +2 -2
- package/dist/components/forms/EntriesTable.d.ts +0 -29
- package/dist/components/forms/EntriesTable.d.ts.map +0 -1
- package/dist/components/forms/EntriesTable.js +0 -29
- package/dist/components/forms/EntriesTable.js.map +0 -1
- package/dist/components/forms/FormEntryDetailPane.d.ts +0 -23
- package/dist/components/forms/FormEntryDetailPane.d.ts.map +0 -1
- package/dist/components/forms/FormEntryDetailPane.js +0 -208
- package/dist/components/forms/FormEntryDetailPane.js.map +0 -1
- package/dist/components/ui/PanelSection.d.ts +0 -16
- package/dist/components/ui/PanelSection.d.ts.map +0 -1
- package/dist/components/ui/PanelSection.js +0 -15
- package/dist/components/ui/PanelSection.js.map +0 -1
- package/src/components/forms/EntriesTable.tsx +0 -207
- package/src/components/forms/FormEntryDetailPane.tsx +0 -402
- package/src/components/ui/PanelSection.tsx +0 -53
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Shared, token-only submissions table used by both the per-form Submissions
|
|
5
|
-
* view and the global All Entries inbox. Presentational only: selection, star,
|
|
6
|
-
* and row-open are delegated to the parent; an optional Form column links each
|
|
7
|
-
* row back to its form when entries span multiple forms.
|
|
8
|
-
*/
|
|
9
|
-
import type { ReactNode } from 'react'
|
|
10
|
-
import { Star } from 'lucide-react'
|
|
11
|
-
import type { FormSubmission } from '../../lib/forms-service.js'
|
|
12
|
-
import { btnGhostIcon } from './primitives.js'
|
|
13
|
-
|
|
14
|
-
function formatEntryDateTime(iso: string | null | undefined): string {
|
|
15
|
-
if (!iso) return '—'
|
|
16
|
-
const d = new Date(iso)
|
|
17
|
-
if (Number.isNaN(d.getTime())) return '—'
|
|
18
|
-
return d.toLocaleString(undefined, {
|
|
19
|
-
month: 'short',
|
|
20
|
-
day: 'numeric',
|
|
21
|
-
year: 'numeric',
|
|
22
|
-
hour: 'numeric',
|
|
23
|
-
minute: '2-digit',
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface EntriesTableProps {
|
|
28
|
-
entries: FormSubmission[]
|
|
29
|
-
selected: Set<string>
|
|
30
|
-
allSelected: boolean
|
|
31
|
-
onToggleSelectAll: () => void
|
|
32
|
-
onToggleSelect: (id: string) => void
|
|
33
|
-
onOpen: (id: string) => void
|
|
34
|
-
onToggleStar: (entry: FormSubmission) => void
|
|
35
|
-
/** Entry currently open in the inline detail pane (drives aria-expanded). */
|
|
36
|
-
activeId?: string | null
|
|
37
|
-
/** Show a Form column (used by the cross-form All Entries inbox). */
|
|
38
|
-
showForm?: boolean
|
|
39
|
-
/** Navigate to a form's submissions when its name is clicked (All Entries). */
|
|
40
|
-
onOpenForm?: (formId: string) => void
|
|
41
|
-
/** Accessible label for the table element. */
|
|
42
|
-
ariaLabel?: string
|
|
43
|
-
/** Footer row (e.g. pagination) rendered inside the bordered card. */
|
|
44
|
-
footer?: ReactNode
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function EntriesTable({
|
|
48
|
-
entries,
|
|
49
|
-
selected,
|
|
50
|
-
allSelected,
|
|
51
|
-
onToggleSelectAll,
|
|
52
|
-
onToggleSelect,
|
|
53
|
-
onOpen,
|
|
54
|
-
onToggleStar,
|
|
55
|
-
activeId = null,
|
|
56
|
-
showForm = false,
|
|
57
|
-
onOpenForm,
|
|
58
|
-
ariaLabel = 'Submissions',
|
|
59
|
-
footer,
|
|
60
|
-
}: EntriesTableProps) {
|
|
61
|
-
return (
|
|
62
|
-
<div className="border-border bg-card flex min-h-0 flex-col overflow-hidden rounded-lg border">
|
|
63
|
-
<div className="min-h-0 flex-1 overflow-auto">
|
|
64
|
-
<table
|
|
65
|
-
className={`w-full ${showForm ? 'min-w-[860px]' : 'min-w-[720px]'} text-sm`}
|
|
66
|
-
aria-label={ariaLabel}
|
|
67
|
-
>
|
|
68
|
-
<thead>
|
|
69
|
-
<tr className="border-border text-muted-foreground border-b text-left text-xs">
|
|
70
|
-
<th scope="col" className="w-10 px-4 py-2.5">
|
|
71
|
-
<input
|
|
72
|
-
type="checkbox"
|
|
73
|
-
checked={allSelected}
|
|
74
|
-
onChange={onToggleSelectAll}
|
|
75
|
-
aria-label="Select all submissions"
|
|
76
|
-
className="border-border text-primary focus-visible:ring-ring h-4 w-4 rounded"
|
|
77
|
-
/>
|
|
78
|
-
</th>
|
|
79
|
-
<th scope="col" className="px-4 py-2.5 font-medium">
|
|
80
|
-
Sender
|
|
81
|
-
</th>
|
|
82
|
-
{showForm && (
|
|
83
|
-
<th scope="col" className="px-4 py-2.5 font-medium whitespace-nowrap">
|
|
84
|
-
Form
|
|
85
|
-
</th>
|
|
86
|
-
)}
|
|
87
|
-
<th scope="col" className="px-4 py-2.5 font-medium">
|
|
88
|
-
Submission
|
|
89
|
-
</th>
|
|
90
|
-
<th scope="col" className="px-4 py-2.5 font-medium whitespace-nowrap">
|
|
91
|
-
Submitted
|
|
92
|
-
</th>
|
|
93
|
-
<th scope="col" className="w-10 px-4 py-2.5 text-center font-medium">
|
|
94
|
-
<span className="sr-only">Starred</span>
|
|
95
|
-
</th>
|
|
96
|
-
</tr>
|
|
97
|
-
</thead>
|
|
98
|
-
<tbody>
|
|
99
|
-
{entries.map((entry) => {
|
|
100
|
-
const isSelected = selected.has(entry.id)
|
|
101
|
-
const name = entry.senderName || 'Anonymous'
|
|
102
|
-
return (
|
|
103
|
-
<tr
|
|
104
|
-
key={entry.id}
|
|
105
|
-
className={`border-border hover:bg-accent/40 group cursor-pointer border-b transition-colors last:border-b-0 ${
|
|
106
|
-
isSelected ? 'bg-accent/30' : ''
|
|
107
|
-
}`}
|
|
108
|
-
onClick={() => onOpen(entry.id)}
|
|
109
|
-
>
|
|
110
|
-
<td className="px-4 py-3" onClick={(e) => e.stopPropagation()}>
|
|
111
|
-
<input
|
|
112
|
-
type="checkbox"
|
|
113
|
-
checked={isSelected}
|
|
114
|
-
onChange={() => onToggleSelect(entry.id)}
|
|
115
|
-
aria-label={`Select submission from ${name}`}
|
|
116
|
-
className="border-border text-primary focus-visible:ring-ring h-4 w-4 rounded"
|
|
117
|
-
/>
|
|
118
|
-
</td>
|
|
119
|
-
<td className="px-4 py-3">
|
|
120
|
-
<div className="flex items-center gap-3">
|
|
121
|
-
<span
|
|
122
|
-
className="bg-muted text-muted-foreground flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-xs font-medium"
|
|
123
|
-
aria-hidden
|
|
124
|
-
>
|
|
125
|
-
{name.charAt(0).toUpperCase()}
|
|
126
|
-
</span>
|
|
127
|
-
<div className="min-w-0">
|
|
128
|
-
<div className="flex items-center gap-2">
|
|
129
|
-
{entry.unread && (
|
|
130
|
-
<span
|
|
131
|
-
role="img"
|
|
132
|
-
className="bg-primary h-1.5 w-1.5 shrink-0 rounded-full"
|
|
133
|
-
aria-label="Unread"
|
|
134
|
-
/>
|
|
135
|
-
)}
|
|
136
|
-
<button
|
|
137
|
-
type="button"
|
|
138
|
-
onClick={(e) => {
|
|
139
|
-
e.stopPropagation()
|
|
140
|
-
onOpen(entry.id)
|
|
141
|
-
}}
|
|
142
|
-
aria-expanded={entry.id === activeId}
|
|
143
|
-
className="text-foreground focus-visible:ring-ring truncate rounded text-left font-medium hover:underline focus-visible:ring-2 focus-visible:outline-none"
|
|
144
|
-
>
|
|
145
|
-
{name}
|
|
146
|
-
</button>
|
|
147
|
-
</div>
|
|
148
|
-
{entry.senderEmail && (
|
|
149
|
-
<span className="text-muted-foreground block truncate text-xs">
|
|
150
|
-
{entry.senderEmail}
|
|
151
|
-
</span>
|
|
152
|
-
)}
|
|
153
|
-
</div>
|
|
154
|
-
</div>
|
|
155
|
-
</td>
|
|
156
|
-
{showForm && (
|
|
157
|
-
<td
|
|
158
|
-
className="px-4 py-3 whitespace-nowrap"
|
|
159
|
-
onClick={(e) => e.stopPropagation()}
|
|
160
|
-
>
|
|
161
|
-
{onOpenForm ? (
|
|
162
|
-
<button
|
|
163
|
-
type="button"
|
|
164
|
-
onClick={() => onOpenForm(entry.formId)}
|
|
165
|
-
className="text-muted-foreground hover:text-primary focus-visible:ring-ring rounded text-sm focus-visible:ring-2 focus-visible:outline-none"
|
|
166
|
-
>
|
|
167
|
-
{entry.formName || '—'}
|
|
168
|
-
</button>
|
|
169
|
-
) : (
|
|
170
|
-
<span className="text-muted-foreground text-sm">
|
|
171
|
-
{entry.formName || '—'}
|
|
172
|
-
</span>
|
|
173
|
-
)}
|
|
174
|
-
</td>
|
|
175
|
-
)}
|
|
176
|
-
<td className="px-4 py-3">
|
|
177
|
-
<span className="text-muted-foreground line-clamp-1 max-w-md">
|
|
178
|
-
{entry.preview || '—'}
|
|
179
|
-
</span>
|
|
180
|
-
</td>
|
|
181
|
-
<td className="text-muted-foreground px-4 py-3 whitespace-nowrap">
|
|
182
|
-
{formatEntryDateTime(entry.submittedAt)}
|
|
183
|
-
</td>
|
|
184
|
-
<td className="px-4 py-3 text-center" onClick={(e) => e.stopPropagation()}>
|
|
185
|
-
<button
|
|
186
|
-
type="button"
|
|
187
|
-
className={btnGhostIcon}
|
|
188
|
-
aria-pressed={entry.starred}
|
|
189
|
-
aria-label={entry.starred ? 'Unstar submission' : 'Star submission'}
|
|
190
|
-
onClick={() => onToggleStar(entry)}
|
|
191
|
-
>
|
|
192
|
-
<Star
|
|
193
|
-
className={`h-4 w-4 ${entry.starred ? 'fill-warning text-warning' : ''}`}
|
|
194
|
-
aria-hidden
|
|
195
|
-
/>
|
|
196
|
-
</button>
|
|
197
|
-
</td>
|
|
198
|
-
</tr>
|
|
199
|
-
)
|
|
200
|
-
})}
|
|
201
|
-
</tbody>
|
|
202
|
-
</table>
|
|
203
|
-
</div>
|
|
204
|
-
{footer ? <div className="shrink-0">{footer}</div> : null}
|
|
205
|
-
</div>
|
|
206
|
-
)
|
|
207
|
-
}
|
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Form entry detail pane — inline InspectorPane replacement for the old
|
|
5
|
-
* `EntryDetailDrawer` overlay. Shows a single submission rendered against the
|
|
6
|
-
* schema version it was captured with, plus sender, attribution, and
|
|
7
|
-
* per-entry actions (star, archive, mark unread, delete). Opening an unread
|
|
8
|
-
* entry marks it read. Rendered beside the entries table (400px split pane).
|
|
9
|
-
*/
|
|
10
|
-
import { useCallback, useEffect, useState } from 'react'
|
|
11
|
-
import { Archive, ArchiveRestore, Loader2, Mail, Star, Trash2 } from 'lucide-react'
|
|
12
|
-
import { toast } from 'sonner'
|
|
13
|
-
import {
|
|
14
|
-
deleteEntry,
|
|
15
|
-
fetchEntry,
|
|
16
|
-
updateEntry,
|
|
17
|
-
type EntryDetail,
|
|
18
|
-
type FormField,
|
|
19
|
-
type FormSubmission,
|
|
20
|
-
} from '../../lib/forms-service.js'
|
|
21
|
-
import { emitFormsChanged } from '../../lib/forms-events.js'
|
|
22
|
-
import { ConfirmDialog } from '../ui/ConfirmDialog.js'
|
|
23
|
-
import {
|
|
24
|
-
InspectorPaneBody,
|
|
25
|
-
InspectorPaneFooter,
|
|
26
|
-
InspectorPaneHeader,
|
|
27
|
-
InspectorPaneSection,
|
|
28
|
-
} from '../ui/InspectorPane.js'
|
|
29
|
-
import { FormsErrorState } from './primitives.js'
|
|
30
|
-
|
|
31
|
-
const iconBtn =
|
|
32
|
-
'flex h-7 w-7 shrink-0 items-center justify-center rounded-[6px] text-[var(--muted)] transition-colors duration-[var(--motion-fast)] hover:bg-[var(--bg)] hover:text-[var(--txt)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:outline-none disabled:opacity-60'
|
|
33
|
-
|
|
34
|
-
function formatDateTime(iso: string | null | undefined): string {
|
|
35
|
-
if (!iso) return '—'
|
|
36
|
-
const d = new Date(iso)
|
|
37
|
-
if (Number.isNaN(d.getTime())) return '—'
|
|
38
|
-
return d.toLocaleString(undefined, {
|
|
39
|
-
month: 'short',
|
|
40
|
-
day: 'numeric',
|
|
41
|
-
year: 'numeric',
|
|
42
|
-
hour: 'numeric',
|
|
43
|
-
minute: '2-digit',
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** Render a stored value for display, coping with arrays/objects/booleans. */
|
|
48
|
-
function displayValue(value: unknown): string {
|
|
49
|
-
if (value == null || value === '') return '—'
|
|
50
|
-
if (typeof value === 'boolean') return value ? 'Yes' : 'No'
|
|
51
|
-
if (Array.isArray(value)) return value.map((v) => String(v)).join(', ')
|
|
52
|
-
if (typeof value === 'object') return JSON.stringify(value)
|
|
53
|
-
return String(value)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface AttrRow {
|
|
57
|
-
label: string
|
|
58
|
-
value: string | null | undefined
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const CHANNEL_LABELS: Record<string, string> = {
|
|
62
|
-
paid: 'Paid',
|
|
63
|
-
search_organic: 'Organic search',
|
|
64
|
-
social: 'Social',
|
|
65
|
-
email: 'Email',
|
|
66
|
-
ai: 'AI',
|
|
67
|
-
referral: 'Referral',
|
|
68
|
-
direct: 'Direct',
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const CLICK_ID_LABELS: Record<string, string> = {
|
|
72
|
-
gclid: 'GCLID (Google Ads)',
|
|
73
|
-
fbclid: 'FBCLID (Meta)',
|
|
74
|
-
msclkid: 'MSCLKID (Microsoft)',
|
|
75
|
-
ttclid: 'TTCLID (TikTok)',
|
|
76
|
-
li_fat_id: 'LinkedIn click ID',
|
|
77
|
-
dclid: 'DCLID (Display)',
|
|
78
|
-
twclid: 'TWCLID (X Ads)',
|
|
79
|
-
rdt_cid: 'Reddit click ID',
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const DEVICE_LABELS: Record<string, string> = {
|
|
83
|
-
desktop: 'Desktop',
|
|
84
|
-
tablet: 'Tablet',
|
|
85
|
-
mobile: 'Mobile',
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function attrString(blob: Record<string, unknown>, key: string): string {
|
|
89
|
-
const v = blob[key]
|
|
90
|
-
return typeof v === 'string' ? v : ''
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Build the attribution rows for an entry. Prefers the full client-captured
|
|
95
|
-
* blob (channel, click IDs, first/last touch) and falls back to the
|
|
96
|
-
* denormalized UTM columns for entries captured before attribution shipped.
|
|
97
|
-
* Exported for tests.
|
|
98
|
-
*/
|
|
99
|
-
export function buildAttributionRows(entry: FormSubmission): AttrRow[] {
|
|
100
|
-
const blob =
|
|
101
|
-
entry.attribution && typeof entry.attribution === 'object' && !Array.isArray(entry.attribution)
|
|
102
|
-
? entry.attribution
|
|
103
|
-
: {}
|
|
104
|
-
|
|
105
|
-
const channel = attrString(blob, 'channel')
|
|
106
|
-
const referrerName = attrString(blob, 'referrerName')
|
|
107
|
-
const channelLabel = channel
|
|
108
|
-
? `${CHANNEL_LABELS[channel] ?? channel}${referrerName ? ` · ${referrerName}` : ''}`
|
|
109
|
-
: ''
|
|
110
|
-
|
|
111
|
-
const rows: AttrRow[] = [
|
|
112
|
-
{ label: 'Channel', value: channelLabel },
|
|
113
|
-
{ label: 'Source', value: attrString(blob, 'source') || entry.utmSource },
|
|
114
|
-
{ label: 'Medium', value: attrString(blob, 'medium') || entry.utmMedium },
|
|
115
|
-
{ label: 'Campaign', value: attrString(blob, 'campaign') || entry.utmCampaign },
|
|
116
|
-
{ label: 'Term', value: attrString(blob, 'term') },
|
|
117
|
-
{ label: 'Content', value: attrString(blob, 'content') },
|
|
118
|
-
{ label: 'Landing page', value: attrString(blob, 'landingPage') },
|
|
119
|
-
{ label: 'Page', value: entry.pageUrl },
|
|
120
|
-
{ label: 'Referrer', value: attrString(blob, 'referrer') || entry.referrer },
|
|
121
|
-
{
|
|
122
|
-
label: 'Device',
|
|
123
|
-
value: DEVICE_LABELS[attrString(blob, 'deviceType')] ?? '',
|
|
124
|
-
},
|
|
125
|
-
{ label: 'First touch', value: formatDateTimeOrEmpty(attrString(blob, 'firstTouchAt')) },
|
|
126
|
-
]
|
|
127
|
-
|
|
128
|
-
const clickIds = blob.clickIds
|
|
129
|
-
if (clickIds && typeof clickIds === 'object' && !Array.isArray(clickIds)) {
|
|
130
|
-
for (const [key, label] of Object.entries(CLICK_ID_LABELS)) {
|
|
131
|
-
const value = (clickIds as Record<string, unknown>)[key]
|
|
132
|
-
if (typeof value === 'string' && value) rows.push({ label, value })
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return rows.filter((r) => r.value)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function formatDateTimeOrEmpty(iso: string): string {
|
|
140
|
-
if (!iso) return ''
|
|
141
|
-
const formatted = formatDateTime(iso)
|
|
142
|
-
return formatted === '—' ? '' : formatted
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface FormEntryDetailPaneProps {
|
|
146
|
-
entryId: string
|
|
147
|
-
onClose: () => void
|
|
148
|
-
/** Called after a mutation (star/archive/read/delete) so the list refreshes. */
|
|
149
|
-
onChanged?: () => void
|
|
150
|
-
/** Called specifically after a delete so the caller can drop the row/selection. */
|
|
151
|
-
onDeleted?: (id: string) => void
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function FormEntryDetailPane({
|
|
155
|
-
entryId,
|
|
156
|
-
onClose,
|
|
157
|
-
onChanged,
|
|
158
|
-
onDeleted,
|
|
159
|
-
}: FormEntryDetailPaneProps) {
|
|
160
|
-
const [detail, setDetail] = useState<EntryDetail | null>(null)
|
|
161
|
-
const [loading, setLoading] = useState(true)
|
|
162
|
-
const [error, setError] = useState<string | null>(null)
|
|
163
|
-
const [busy, setBusy] = useState(false)
|
|
164
|
-
const [confirmDelete, setConfirmDelete] = useState(false)
|
|
165
|
-
|
|
166
|
-
const notifyChanged = useCallback(() => {
|
|
167
|
-
emitFormsChanged()
|
|
168
|
-
onChanged?.()
|
|
169
|
-
}, [onChanged])
|
|
170
|
-
|
|
171
|
-
// Load the entry (and its schema) when the pane opens, marking it read.
|
|
172
|
-
useEffect(() => {
|
|
173
|
-
let cancelled = false
|
|
174
|
-
setLoading(true)
|
|
175
|
-
setError(null)
|
|
176
|
-
setDetail(null)
|
|
177
|
-
void (async () => {
|
|
178
|
-
try {
|
|
179
|
-
const data = await fetchEntry(entryId)
|
|
180
|
-
if (cancelled) return
|
|
181
|
-
if (!data) {
|
|
182
|
-
setError('Entry not found')
|
|
183
|
-
return
|
|
184
|
-
}
|
|
185
|
-
setDetail(data)
|
|
186
|
-
// Mark read on open (fire-and-forget; refresh the list counts).
|
|
187
|
-
if (data.entry.unread) {
|
|
188
|
-
const res = await updateEntry(entryId, { unread: false })
|
|
189
|
-
if (!cancelled && !res.error) notifyChanged()
|
|
190
|
-
}
|
|
191
|
-
} catch (e) {
|
|
192
|
-
if (!cancelled) setError(e instanceof Error ? e.message : 'Failed to load entry')
|
|
193
|
-
} finally {
|
|
194
|
-
if (!cancelled) setLoading(false)
|
|
195
|
-
}
|
|
196
|
-
})()
|
|
197
|
-
return () => {
|
|
198
|
-
cancelled = true
|
|
199
|
-
}
|
|
200
|
-
}, [entryId, notifyChanged])
|
|
201
|
-
|
|
202
|
-
const mutate = useCallback(
|
|
203
|
-
async (patch: { unread?: boolean; starred?: boolean; archived?: boolean }) => {
|
|
204
|
-
setBusy(true)
|
|
205
|
-
const res = await updateEntry(entryId, patch)
|
|
206
|
-
setBusy(false)
|
|
207
|
-
if (res.error) {
|
|
208
|
-
toast.error(res.error)
|
|
209
|
-
return
|
|
210
|
-
}
|
|
211
|
-
setDetail((cur) => (cur ? { ...cur, entry: { ...cur.entry, ...patch } } : cur))
|
|
212
|
-
notifyChanged()
|
|
213
|
-
},
|
|
214
|
-
[entryId, notifyChanged],
|
|
215
|
-
)
|
|
216
|
-
|
|
217
|
-
const handleDelete = useCallback(async () => {
|
|
218
|
-
setBusy(true)
|
|
219
|
-
const res = await deleteEntry(entryId)
|
|
220
|
-
setBusy(false)
|
|
221
|
-
if (res.error) {
|
|
222
|
-
toast.error(res.error)
|
|
223
|
-
return
|
|
224
|
-
}
|
|
225
|
-
toast.success('Submission deleted')
|
|
226
|
-
notifyChanged()
|
|
227
|
-
onDeleted?.(entryId)
|
|
228
|
-
}, [entryId, notifyChanged, onDeleted])
|
|
229
|
-
|
|
230
|
-
const entry = detail?.entry
|
|
231
|
-
const senderName = entry?.senderName || 'Anonymous'
|
|
232
|
-
const attrRows = entry ? buildAttributionRows(entry) : []
|
|
233
|
-
|
|
234
|
-
return (
|
|
235
|
-
<>
|
|
236
|
-
<InspectorPaneHeader onClose={onClose} closeLabel="Close entry details">
|
|
237
|
-
<div className="flex items-start justify-between gap-2">
|
|
238
|
-
<div className="min-w-0">
|
|
239
|
-
<div className="truncate text-[13.5px] font-semibold text-[var(--txt)]">
|
|
240
|
-
{entry ? `Entry${entry.entryNumber ? ` #${entry.entryNumber}` : ''}` : 'Entry'}
|
|
241
|
-
</div>
|
|
242
|
-
{entry && (
|
|
243
|
-
<div className="mt-0.5 truncate text-[11.5px] text-[var(--muted)]">
|
|
244
|
-
{formatDateTime(entry.submittedAt)}
|
|
245
|
-
</div>
|
|
246
|
-
)}
|
|
247
|
-
</div>
|
|
248
|
-
{entry && (
|
|
249
|
-
<div className="flex shrink-0 gap-1">
|
|
250
|
-
<button
|
|
251
|
-
type="button"
|
|
252
|
-
className={iconBtn}
|
|
253
|
-
aria-pressed={entry.starred}
|
|
254
|
-
aria-label={entry.starred ? 'Unstar entry' : 'Star entry'}
|
|
255
|
-
disabled={busy}
|
|
256
|
-
onClick={() => void mutate({ starred: !entry.starred })}
|
|
257
|
-
>
|
|
258
|
-
<Star
|
|
259
|
-
size={16}
|
|
260
|
-
aria-hidden
|
|
261
|
-
className={entry.starred ? 'fill-[var(--warn)] text-[var(--warn)]' : ''}
|
|
262
|
-
/>
|
|
263
|
-
</button>
|
|
264
|
-
<button
|
|
265
|
-
type="button"
|
|
266
|
-
className={iconBtn}
|
|
267
|
-
aria-pressed={entry.archived}
|
|
268
|
-
aria-label={entry.archived ? 'Unarchive entry' : 'Archive entry'}
|
|
269
|
-
disabled={busy}
|
|
270
|
-
onClick={() => void mutate({ archived: !entry.archived })}
|
|
271
|
-
>
|
|
272
|
-
{entry.archived ? (
|
|
273
|
-
<ArchiveRestore size={16} aria-hidden />
|
|
274
|
-
) : (
|
|
275
|
-
<Archive size={16} aria-hidden />
|
|
276
|
-
)}
|
|
277
|
-
</button>
|
|
278
|
-
</div>
|
|
279
|
-
)}
|
|
280
|
-
</div>
|
|
281
|
-
</InspectorPaneHeader>
|
|
282
|
-
|
|
283
|
-
<InspectorPaneBody>
|
|
284
|
-
{loading ? (
|
|
285
|
-
<div className="flex h-40 items-center justify-center" role="status" aria-live="polite">
|
|
286
|
-
<Loader2 className="h-5 w-5 animate-spin text-[var(--muted)]" aria-hidden />
|
|
287
|
-
<span className="sr-only">Loading entry…</span>
|
|
288
|
-
</div>
|
|
289
|
-
) : error ? (
|
|
290
|
-
<div className="px-4 py-3.5">
|
|
291
|
-
<FormsErrorState message={error} />
|
|
292
|
-
</div>
|
|
293
|
-
) : entry ? (
|
|
294
|
-
<>
|
|
295
|
-
<InspectorPaneSection title="Sender">
|
|
296
|
-
<div className="text-[12.5px] font-medium text-[var(--txt)]">{senderName}</div>
|
|
297
|
-
{entry.senderEmail && (
|
|
298
|
-
<a
|
|
299
|
-
href={`mailto:${entry.senderEmail}`}
|
|
300
|
-
className="block truncate text-[12px] text-[var(--acc)] hover:underline"
|
|
301
|
-
>
|
|
302
|
-
{entry.senderEmail}
|
|
303
|
-
</a>
|
|
304
|
-
)}
|
|
305
|
-
{entry.senderPhone && (
|
|
306
|
-
<div className="text-[12px] text-[var(--sub)]">{entry.senderPhone}</div>
|
|
307
|
-
)}
|
|
308
|
-
</InspectorPaneSection>
|
|
309
|
-
|
|
310
|
-
<FieldValues entry={entry} fields={detail.fields} />
|
|
311
|
-
|
|
312
|
-
{attrRows.length > 0 && (
|
|
313
|
-
<InspectorPaneSection title="Attribution">
|
|
314
|
-
<dl>
|
|
315
|
-
{attrRows.map((row) => (
|
|
316
|
-
<div key={row.label} className="flex justify-between gap-4 py-1 text-[12px]">
|
|
317
|
-
<dt className="shrink-0 text-[var(--muted)]">{row.label}</dt>
|
|
318
|
-
<dd className="min-w-0 truncate text-right text-[var(--sub)]">{row.value}</dd>
|
|
319
|
-
</div>
|
|
320
|
-
))}
|
|
321
|
-
</dl>
|
|
322
|
-
</InspectorPaneSection>
|
|
323
|
-
)}
|
|
324
|
-
</>
|
|
325
|
-
) : null}
|
|
326
|
-
</InspectorPaneBody>
|
|
327
|
-
|
|
328
|
-
{entry && (
|
|
329
|
-
<InspectorPaneFooter>
|
|
330
|
-
<div className="flex items-center gap-2">
|
|
331
|
-
<button
|
|
332
|
-
type="button"
|
|
333
|
-
className="flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-[7px] border border-[var(--bdr)] px-3 py-2 text-[12.5px] font-medium text-[var(--txt)] transition-colors duration-[var(--motion-fast)] hover:bg-[var(--bg)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:outline-none disabled:opacity-60"
|
|
334
|
-
disabled={busy}
|
|
335
|
-
onClick={() => void mutate({ unread: !entry.unread })}
|
|
336
|
-
>
|
|
337
|
-
<Mail size={14} aria-hidden />
|
|
338
|
-
Mark {entry.unread ? 'read' : 'unread'}
|
|
339
|
-
</button>
|
|
340
|
-
<button
|
|
341
|
-
type="button"
|
|
342
|
-
className="flex shrink-0 items-center justify-center gap-1.5 rounded-[7px] border border-[var(--bdr)] px-3 py-2 text-[12.5px] font-medium text-[var(--err)] transition-colors duration-[var(--motion-fast)] hover:bg-[var(--err-l)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:outline-none disabled:opacity-60"
|
|
343
|
-
disabled={busy}
|
|
344
|
-
onClick={() => setConfirmDelete(true)}
|
|
345
|
-
>
|
|
346
|
-
<Trash2 size={14} aria-hidden />
|
|
347
|
-
Delete
|
|
348
|
-
</button>
|
|
349
|
-
</div>
|
|
350
|
-
</InspectorPaneFooter>
|
|
351
|
-
)}
|
|
352
|
-
|
|
353
|
-
<ConfirmDialog
|
|
354
|
-
open={confirmDelete}
|
|
355
|
-
onClose={() => setConfirmDelete(false)}
|
|
356
|
-
onConfirm={() => void handleDelete()}
|
|
357
|
-
title="Delete submission?"
|
|
358
|
-
description="This permanently removes the submission and any attached files. This cannot be undone."
|
|
359
|
-
confirmLabel="Delete"
|
|
360
|
-
destructive
|
|
361
|
-
/>
|
|
362
|
-
</>
|
|
363
|
-
)
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/** Render the captured field values against the entry's schema. */
|
|
367
|
-
function FieldValues({ entry, fields }: { entry: FormSubmission; fields: FormField[] }) {
|
|
368
|
-
// Prefer the schema order; fall back to whatever keys exist on the data.
|
|
369
|
-
const inputFields = fields.filter(
|
|
370
|
-
(f) =>
|
|
371
|
-
f.type !== 'divider' &&
|
|
372
|
-
f.type !== 'richtext' &&
|
|
373
|
-
f.type !== 'honeypot' &&
|
|
374
|
-
f.type !== 'heading' &&
|
|
375
|
-
f.type !== 'content' &&
|
|
376
|
-
f.type !== 'pagebreak',
|
|
377
|
-
)
|
|
378
|
-
const rows: { key: string; label: string }[] = inputFields.length
|
|
379
|
-
? inputFields.map((f) => ({ key: f.key, label: f.label }))
|
|
380
|
-
: Object.keys(entry.data ?? {}).map((k) => ({ key: k, label: k }))
|
|
381
|
-
|
|
382
|
-
return (
|
|
383
|
-
<InspectorPaneSection title="Submission">
|
|
384
|
-
{rows.length === 0 ? (
|
|
385
|
-
<p className="text-[12px] text-[var(--muted)]">No field data captured.</p>
|
|
386
|
-
) : (
|
|
387
|
-
<dl>
|
|
388
|
-
{rows.map((row) => (
|
|
389
|
-
<div key={row.key} className="mb-2.5 last:mb-0">
|
|
390
|
-
<dt className="text-[10.5px] font-semibold tracking-[0.5px] text-[var(--muted)] uppercase">
|
|
391
|
-
{row.label}
|
|
392
|
-
</dt>
|
|
393
|
-
<dd className="mt-0.5 text-[12.5px] break-words whitespace-pre-wrap text-[var(--txt)]">
|
|
394
|
-
{displayValue(entry.data?.[row.key])}
|
|
395
|
-
</dd>
|
|
396
|
-
</div>
|
|
397
|
-
))}
|
|
398
|
-
</dl>
|
|
399
|
-
)}
|
|
400
|
-
</InspectorPaneSection>
|
|
401
|
-
)
|
|
402
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import type { ReactNode } from 'react'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Bordered panel with a header divider — Dashboard, modals, and list-heavy views.
|
|
7
|
-
* Matches Settings/Section card rhythm: `px-6` gutters, `py-4` header, body flush
|
|
8
|
-
* below the divider with its own padding.
|
|
9
|
-
*/
|
|
10
|
-
export function PanelSection({
|
|
11
|
-
title,
|
|
12
|
-
description,
|
|
13
|
-
action,
|
|
14
|
-
children,
|
|
15
|
-
className = '',
|
|
16
|
-
}: {
|
|
17
|
-
title?: ReactNode
|
|
18
|
-
description?: ReactNode
|
|
19
|
-
action?: ReactNode
|
|
20
|
-
children: ReactNode
|
|
21
|
-
className?: string
|
|
22
|
-
}) {
|
|
23
|
-
return (
|
|
24
|
-
<section
|
|
25
|
-
className={`bg-card border-border overflow-hidden rounded-xl border shadow-sm ${className}`}
|
|
26
|
-
>
|
|
27
|
-
{(title || action) && (
|
|
28
|
-
<header className="border-border flex items-center justify-between gap-3 border-b px-6 py-4">
|
|
29
|
-
<div className="min-w-0">
|
|
30
|
-
{title &&
|
|
31
|
-
(typeof title === 'string' ? (
|
|
32
|
-
<h2 className="text-foreground text-sm font-medium">{title}</h2>
|
|
33
|
-
) : (
|
|
34
|
-
title
|
|
35
|
-
))}
|
|
36
|
-
{description &&
|
|
37
|
-
(typeof description === 'string' ? (
|
|
38
|
-
<p className="text-muted-foreground mt-0.5 text-xs">{description}</p>
|
|
39
|
-
) : (
|
|
40
|
-
description
|
|
41
|
-
))}
|
|
42
|
-
</div>
|
|
43
|
-
{action}
|
|
44
|
-
</header>
|
|
45
|
-
)}
|
|
46
|
-
{children}
|
|
47
|
-
</section>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Standard inset for list rows / table bodies inside a {@link PanelSection}. */
|
|
52
|
-
export const PANEL_LIST_ROW_CLASS =
|
|
53
|
-
'hover:bg-accent/50 focus-visible:bg-accent/50 w-full px-6 py-4 text-left transition-colors'
|