@prenta/admin 2.12.1 → 2.14.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 +19 -0
- package/dist/AdminRoot.d.ts.map +1 -1
- package/dist/AdminRoot.js +3 -3
- package/dist/AdminRoot.js.map +1 -1
- package/dist/__tests__/components/attribution-rows.test.js +17 -5
- package/dist/__tests__/components/attribution-rows.test.js.map +1 -1
- package/dist/__tests__/layout/shell-nav.render.test.js +3 -1
- package/dist/__tests__/layout/shell-nav.render.test.js.map +1 -1
- package/dist/__tests__/views/form-entries.render.test.js +5 -5
- package/dist/__tests__/views/form-entries.render.test.js.map +1 -1
- package/dist/__tests__/views/form-submissions.render.test.js +3 -3
- package/dist/__tests__/views/form-submissions.render.test.js.map +1 -1
- package/dist/__tests__/views/media-browser.render.test.js +7 -7
- package/dist/__tests__/views/media-browser.render.test.js.map +1 -1
- package/dist/components/FolderTree.d.ts +4 -2
- package/dist/components/FolderTree.d.ts.map +1 -1
- package/dist/components/FolderTree.js +4 -2
- package/dist/components/FolderTree.js.map +1 -1
- package/dist/components/forms/ExportMenu.d.ts +7 -1
- package/dist/components/forms/ExportMenu.d.ts.map +1 -1
- package/dist/components/forms/ExportMenu.js +17 -5
- package/dist/components/forms/ExportMenu.js.map +1 -1
- package/dist/layout/nav-config.d.ts.map +1 -1
- package/dist/layout/nav-config.js +8 -1
- package/dist/layout/nav-config.js.map +1 -1
- package/dist/lib/entry-attribution.d.ts +33 -0
- package/dist/lib/entry-attribution.d.ts.map +1 -1
- package/dist/lib/entry-attribution.js +115 -30
- package/dist/lib/entry-attribution.js.map +1 -1
- package/dist/lib/forms-service.d.ts +38 -0
- package/dist/lib/forms-service.d.ts.map +1 -1
- package/dist/lib/forms-service.js +10 -0
- package/dist/lib/forms-service.js.map +1 -1
- package/dist/lib/page-editor-service.d.ts.map +1 -1
- package/dist/lib/page-editor-service.js +3 -0
- package/dist/lib/page-editor-service.js.map +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/views/FormEntries.d.ts +4 -1
- package/dist/views/FormEntries.d.ts.map +1 -1
- package/dist/views/FormEntries.js +2 -2
- package/dist/views/FormEntries.js.map +1 -1
- package/dist/views/FormSubmissions.d.ts +3 -1
- package/dist/views/FormSubmissions.d.ts.map +1 -1
- package/dist/views/FormSubmissions.js +2 -2
- package/dist/views/FormSubmissions.js.map +1 -1
- package/dist/views/MediaBrowser.d.ts.map +1 -1
- package/dist/views/MediaBrowser.js +83 -18
- package/dist/views/MediaBrowser.js.map +1 -1
- package/dist/views/SpamFolder.d.ts +6 -1
- package/dist/views/SpamFolder.d.ts.map +1 -1
- package/dist/views/SpamFolder.js +4 -11
- package/dist/views/SpamFolder.js.map +1 -1
- package/dist/views/entries/EntriesInbox.d.ts +12 -2
- package/dist/views/entries/EntriesInbox.d.ts.map +1 -1
- package/dist/views/entries/EntriesInbox.js +820 -81
- package/dist/views/entries/EntriesInbox.js.map +1 -1
- package/dist/views/entries/inbox-format.d.ts +0 -1
- package/dist/views/entries/inbox-format.d.ts.map +1 -1
- package/dist/views/entries/inbox-format.js +0 -4
- package/dist/views/entries/inbox-format.js.map +1 -1
- package/package.json +3 -3
- package/src/AdminRoot.tsx +23 -3
- package/src/__tests__/components/attribution-rows.test.ts +19 -5
- package/src/__tests__/layout/shell-nav.render.test.tsx +3 -1
- package/src/__tests__/views/form-entries.render.test.tsx +5 -5
- package/src/__tests__/views/form-submissions.render.test.tsx +3 -3
- package/src/__tests__/views/media-browser.render.test.tsx +7 -7
- package/src/components/FolderTree.tsx +20 -1
- package/src/components/forms/ExportMenu.tsx +37 -13
- package/src/layout/nav-config.tsx +8 -0
- package/src/lib/entry-attribution.ts +155 -29
- package/src/lib/forms-service.ts +44 -0
- package/src/lib/page-editor-service.ts +3 -0
- package/src/views/FormEntries.tsx +17 -2
- package/src/views/FormSubmissions.tsx +16 -2
- package/src/views/MediaBrowser.tsx +106 -24
- package/src/views/SpamFolder.tsx +14 -26
- package/src/views/entries/EntriesInbox.tsx +2119 -337
- package/src/views/entries/inbox-format.ts +0 -6
|
@@ -28,7 +28,7 @@ export interface FolderNode {
|
|
|
28
28
|
children: FolderNode[]
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export type SmartFolder = 'all' | 'recent' | 'uncategorized'
|
|
31
|
+
export type SmartFolder = 'all' | 'recent' | 'uncategorized' | 'trash'
|
|
32
32
|
|
|
33
33
|
export type FolderSelection =
|
|
34
34
|
| { type: 'smart'; smart: SmartFolder }
|
|
@@ -42,6 +42,8 @@ export interface FolderTreeProps {
|
|
|
42
42
|
totalCount?: number
|
|
43
43
|
recentCount?: number
|
|
44
44
|
uncategorizedCount?: number
|
|
45
|
+
/** When set, a Trash row is shown. Pages omit this. */
|
|
46
|
+
trashCount?: number
|
|
45
47
|
onDropItem?: (itemId: string, folderId: string | null) => void
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -53,6 +55,7 @@ export function FolderTree({
|
|
|
53
55
|
totalCount,
|
|
54
56
|
recentCount,
|
|
55
57
|
uncategorizedCount,
|
|
58
|
+
trashCount,
|
|
56
59
|
onDropItem,
|
|
57
60
|
}: FolderTreeProps) {
|
|
58
61
|
const [folders, setFolders] = useState<FolderNode[]>([])
|
|
@@ -355,6 +358,22 @@ export function FolderTree({
|
|
|
355
358
|
<span className="text-muted-foreground text-xs tabular-nums">{uncategorizedCount}</span>
|
|
356
359
|
)}
|
|
357
360
|
</button>
|
|
361
|
+
|
|
362
|
+
{trashCount !== undefined && (
|
|
363
|
+
<button
|
|
364
|
+
type="button"
|
|
365
|
+
className={`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors ${
|
|
366
|
+
isSelected({ type: 'smart', smart: 'trash' })
|
|
367
|
+
? 'bg-primary/10 text-primary font-medium'
|
|
368
|
+
: 'text-foreground hover:bg-muted'
|
|
369
|
+
}`}
|
|
370
|
+
onClick={() => onSelect({ type: 'smart', smart: 'trash' })}
|
|
371
|
+
>
|
|
372
|
+
<Trash2 className="h-4 w-4 shrink-0" />
|
|
373
|
+
<span className="flex-1 text-left">Trash</span>
|
|
374
|
+
<span className="text-muted-foreground text-xs tabular-nums">{trashCount}</span>
|
|
375
|
+
</button>
|
|
376
|
+
)}
|
|
358
377
|
</div>
|
|
359
378
|
|
|
360
379
|
<div className="border-border my-1 border-t" />
|
|
@@ -17,6 +17,12 @@ import { btnSecondary } from './primitives.js'
|
|
|
17
17
|
export interface ExportMenuProps {
|
|
18
18
|
/** Scope the export to one form; omit to export entries across all forms. */
|
|
19
19
|
formId?: string
|
|
20
|
+
/** Active folder/view filter for "Current view" exports. */
|
|
21
|
+
folder?: string
|
|
22
|
+
/** Active search query for "Current view" exports. */
|
|
23
|
+
search?: string
|
|
24
|
+
/** Active assignee ID when exporting the Mine view. */
|
|
25
|
+
assigneeId?: string
|
|
20
26
|
/** Disable the trigger (e.g. no entries to export). */
|
|
21
27
|
disabled?: boolean
|
|
22
28
|
/** Replaces the default trigger classes so it can match a sibling control. */
|
|
@@ -24,15 +30,31 @@ export interface ExportMenuProps {
|
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
const itemClass =
|
|
27
|
-
'text-
|
|
33
|
+
'text-txt hover:bg-acc-l hover:text-acc data-highlighted:bg-acc-l data-highlighted:text-acc flex cursor-pointer items-center gap-2 rounded-[7px] px-2.5 py-[7px] text-[13px] outline-none'
|
|
28
34
|
|
|
29
|
-
export function ExportMenu({
|
|
35
|
+
export function ExportMenu({
|
|
36
|
+
formId,
|
|
37
|
+
folder,
|
|
38
|
+
search,
|
|
39
|
+
assigneeId,
|
|
40
|
+
disabled,
|
|
41
|
+
triggerClassName,
|
|
42
|
+
}: ExportMenuProps) {
|
|
30
43
|
const [busy, setBusy] = useState(false)
|
|
31
44
|
|
|
32
|
-
const run = async (format: EntriesExportFormat) => {
|
|
45
|
+
const run = async (format: EntriesExportFormat, scope: 'view' | 'all' = 'view') => {
|
|
33
46
|
setBusy(true)
|
|
34
47
|
try {
|
|
35
|
-
const
|
|
48
|
+
const payload: Parameters<typeof downloadEntriesExport>[0] = {
|
|
49
|
+
formId: scope === 'all' ? undefined : formId,
|
|
50
|
+
format,
|
|
51
|
+
}
|
|
52
|
+
if (scope === 'view') {
|
|
53
|
+
if (folder && folder !== 'all') payload.folder = folder
|
|
54
|
+
if (search?.trim()) payload.search = search.trim()
|
|
55
|
+
if (folder === 'mine' && assigneeId) payload.assigneeId = assigneeId
|
|
56
|
+
}
|
|
57
|
+
const res = await downloadEntriesExport(payload)
|
|
36
58
|
if (res.error) toast.error(res.error)
|
|
37
59
|
} finally {
|
|
38
60
|
setBusy(false)
|
|
@@ -55,19 +77,21 @@ export function ExportMenu({ formId, disabled, triggerClassName }: ExportMenuPro
|
|
|
55
77
|
<DropdownMenu.Portal container={adminPortalContainer()}>
|
|
56
78
|
<DropdownMenu.Content
|
|
57
79
|
align="end"
|
|
58
|
-
sideOffset={
|
|
59
|
-
className="border-
|
|
80
|
+
sideOffset={5}
|
|
81
|
+
className="border-bdr bg-card shadow-shd2 z-50 min-w-[190px] rounded-[10px] border p-[5px]"
|
|
60
82
|
>
|
|
61
|
-
<DropdownMenu.
|
|
62
|
-
Exports all submissions with attribution
|
|
63
|
-
</DropdownMenu.Label>
|
|
64
|
-
<DropdownMenu.Item onSelect={() => void run('csv')} className={itemClass}>
|
|
83
|
+
<DropdownMenu.Item onSelect={() => void run('csv', 'view')} className={itemClass}>
|
|
65
84
|
<FileText size={14} aria-hidden />
|
|
66
|
-
CSV
|
|
85
|
+
Current view · CSV
|
|
67
86
|
</DropdownMenu.Item>
|
|
68
|
-
<DropdownMenu.Item onSelect={() => void run('xlsx')} className={itemClass}>
|
|
87
|
+
<DropdownMenu.Item onSelect={() => void run('xlsx', 'view')} className={itemClass}>
|
|
69
88
|
<FileSpreadsheet size={14} aria-hidden />
|
|
70
|
-
Excel
|
|
89
|
+
Current view · Excel
|
|
90
|
+
</DropdownMenu.Item>
|
|
91
|
+
<DropdownMenu.Separator className="bg-bdr my-1 h-px" />
|
|
92
|
+
<DropdownMenu.Item onSelect={() => void run('csv', 'all')} className={itemClass}>
|
|
93
|
+
<Download size={14} aria-hidden />
|
|
94
|
+
Every entry · CSV
|
|
71
95
|
</DropdownMenu.Item>
|
|
72
96
|
</DropdownMenu.Content>
|
|
73
97
|
</DropdownMenu.Portal>
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
Search as SearchIcon,
|
|
30
30
|
Settings,
|
|
31
31
|
ShieldX,
|
|
32
|
+
Star,
|
|
32
33
|
TextAlignStart,
|
|
33
34
|
Trash2,
|
|
34
35
|
Users,
|
|
@@ -308,6 +309,12 @@ export function applyFormsNav(items: NavItem[], forms: FormsSidebarCount[]): Nav
|
|
|
308
309
|
badge: f.unread,
|
|
309
310
|
})),
|
|
310
311
|
},
|
|
312
|
+
{
|
|
313
|
+
path: '/forms/entries?filter=starred',
|
|
314
|
+
label: 'Starred',
|
|
315
|
+
icon: Star,
|
|
316
|
+
iconSize: 14,
|
|
317
|
+
},
|
|
311
318
|
{
|
|
312
319
|
path: '/forms',
|
|
313
320
|
label: 'All Forms',
|
|
@@ -321,6 +328,7 @@ export function applyFormsNav(items: NavItem[], forms: FormsSidebarCount[]): Nav
|
|
|
321
328
|
})),
|
|
322
329
|
},
|
|
323
330
|
{ path: '/forms/spam', label: 'Spam', icon: ShieldX, iconSize: 14 },
|
|
331
|
+
{ path: '/forms/entries?filter=trash', label: 'Trash', icon: Trash2, iconSize: 14 },
|
|
324
332
|
{ path: '/forms/deliveries', label: 'SMTP Log', icon: Mail, iconSize: 14 },
|
|
325
333
|
{ path: '/forms/settings', label: 'Form Settings', icon: Settings, iconSize: 14 },
|
|
326
334
|
]
|
|
@@ -1,8 +1,49 @@
|
|
|
1
1
|
import type { FormSubmission } from '@prenta/core'
|
|
2
2
|
|
|
3
|
+
export interface AttributionClickId {
|
|
4
|
+
key: string
|
|
5
|
+
platform: string
|
|
6
|
+
value: string
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
export interface AttributionRow {
|
|
4
10
|
label: string
|
|
5
11
|
value: string
|
|
12
|
+
/** Set on the Click ID row. Empty means "None · not an ad click". */
|
|
13
|
+
clickIds?: AttributionClickId[]
|
|
14
|
+
/** Channel key for the Channel chip row. */
|
|
15
|
+
channelKey?: string
|
|
16
|
+
/** Source / Medium split for custom rendering. */
|
|
17
|
+
sourceMedium?: { source: string; medium: string }
|
|
18
|
+
/** URL for Landing page link rendering. */
|
|
19
|
+
href?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AttributionSummary {
|
|
23
|
+
channelKey: string
|
|
24
|
+
channelLabel: string
|
|
25
|
+
channelFg: string
|
|
26
|
+
channelBg: string
|
|
27
|
+
source: string
|
|
28
|
+
medium: string
|
|
29
|
+
campaign: string
|
|
30
|
+
term: string
|
|
31
|
+
landingPage: string
|
|
32
|
+
referrer: string
|
|
33
|
+
device: string
|
|
34
|
+
ip: string
|
|
35
|
+
spamScore: number
|
|
36
|
+
clickIds: AttributionClickId[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const CHANNEL_META: Record<string, { label: string; fg: string; bg: string }> = {
|
|
40
|
+
paid: { label: 'Paid', fg: 'var(--warn)', bg: 'var(--warn-l)' },
|
|
41
|
+
search_organic: { label: 'Organic search', fg: 'var(--suc)', bg: 'var(--suc-l)' },
|
|
42
|
+
social: { label: 'Social', fg: 'var(--info)', bg: 'var(--info-l)' },
|
|
43
|
+
email: { label: 'Email', fg: 'var(--acc)', bg: 'var(--acc-l)' },
|
|
44
|
+
ai: { label: 'AI assistant', fg: 'var(--acc)', bg: 'var(--acc-l)' },
|
|
45
|
+
referral: { label: 'Referral', fg: 'var(--sub)', bg: 'var(--bg)' },
|
|
46
|
+
direct: { label: 'Direct', fg: 'var(--sub)', bg: 'var(--bg)' },
|
|
6
47
|
}
|
|
7
48
|
|
|
8
49
|
const CHANNEL_LABELS: Record<string, string> = {
|
|
@@ -15,16 +56,19 @@ const CHANNEL_LABELS: Record<string, string> = {
|
|
|
15
56
|
direct: 'Direct',
|
|
16
57
|
}
|
|
17
58
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
59
|
+
/** Entries SPEC §5. gbraid and wbraid are stored on `extraIds`, not `clickIds`. */
|
|
60
|
+
const CLICK_ID_ORDER: ReadonlyArray<{ key: string; platform: string }> = [
|
|
61
|
+
{ key: 'gclid', platform: 'Google Ads' },
|
|
62
|
+
{ key: 'gbraid', platform: 'Google Ads · iOS app' },
|
|
63
|
+
{ key: 'wbraid', platform: 'Google Ads · iOS web' },
|
|
64
|
+
{ key: 'dclid', platform: 'Google Display & Video' },
|
|
65
|
+
{ key: 'fbclid', platform: 'Meta' },
|
|
66
|
+
{ key: 'msclkid', platform: 'Microsoft Ads' },
|
|
67
|
+
{ key: 'ttclid', platform: 'TikTok' },
|
|
68
|
+
{ key: 'li_fat_id', platform: 'LinkedIn' },
|
|
69
|
+
{ key: 'twclid', platform: 'X' },
|
|
70
|
+
{ key: 'rdt_cid', platform: 'Reddit' },
|
|
71
|
+
]
|
|
28
72
|
|
|
29
73
|
const DEVICE_LABELS: Record<string, string> = {
|
|
30
74
|
desktop: 'Desktop',
|
|
@@ -50,6 +94,60 @@ function formatDateTime(iso: string): string {
|
|
|
50
94
|
})
|
|
51
95
|
}
|
|
52
96
|
|
|
97
|
+
export function getEntryAttributionSummary(entry: FormSubmission): AttributionSummary {
|
|
98
|
+
const blob =
|
|
99
|
+
entry.attribution && typeof entry.attribution === 'object' && !Array.isArray(entry.attribution)
|
|
100
|
+
? (entry.attribution as Record<string, unknown>)
|
|
101
|
+
: {}
|
|
102
|
+
|
|
103
|
+
const rawChannel = attrString(blob, 'channel')
|
|
104
|
+
const clickIds = clickIdsFor(blob)
|
|
105
|
+
const source = attrString(blob, 'source') || entry.utmSource || '(direct)'
|
|
106
|
+
const medium = attrString(blob, 'medium') || entry.utmMedium || '(none)'
|
|
107
|
+
const campaign = attrString(blob, 'campaign') || entry.utmCampaign || ''
|
|
108
|
+
const term = attrString(blob, 'term')
|
|
109
|
+
const channelKey =
|
|
110
|
+
rawChannel && CHANNEL_META[rawChannel]
|
|
111
|
+
? rawChannel
|
|
112
|
+
: clickIds.length > 0
|
|
113
|
+
? 'paid'
|
|
114
|
+
: source !== '(direct)' && medium === 'organic'
|
|
115
|
+
? 'search_organic'
|
|
116
|
+
: 'direct'
|
|
117
|
+
const meta = CHANNEL_META[channelKey] ?? CHANNEL_META.direct!
|
|
118
|
+
const landingPage = attrString(blob, 'landingPage') || entry.pageUrl || '—'
|
|
119
|
+
const referrer = attrString(blob, 'referrer') || entry.referrer || '(none)'
|
|
120
|
+
const deviceType = DEVICE_LABELS[attrString(blob, 'deviceType')] ?? ''
|
|
121
|
+
const device = entry.userAgent || deviceType || '—'
|
|
122
|
+
const ip = attrString(blob, 'ip') || entry.ipAddressHash || '—'
|
|
123
|
+
const rawScore = blob.spamScore ?? blob.spam
|
|
124
|
+
const spamScore =
|
|
125
|
+
typeof rawScore === 'number'
|
|
126
|
+
? rawScore
|
|
127
|
+
: entry.spamStatus === 'spam'
|
|
128
|
+
? 95
|
|
129
|
+
: entry.spamStatus === 'suspected'
|
|
130
|
+
? 80
|
|
131
|
+
: 0
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
channelKey,
|
|
135
|
+
channelLabel: meta.label,
|
|
136
|
+
channelFg: meta.fg,
|
|
137
|
+
channelBg: meta.bg,
|
|
138
|
+
source,
|
|
139
|
+
medium,
|
|
140
|
+
campaign,
|
|
141
|
+
term,
|
|
142
|
+
landingPage,
|
|
143
|
+
referrer,
|
|
144
|
+
device,
|
|
145
|
+
ip,
|
|
146
|
+
spamScore,
|
|
147
|
+
clickIds,
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
53
151
|
/**
|
|
54
152
|
* The attribution rows for an entry. Prefers the client-captured blob
|
|
55
153
|
* (channel, click IDs, first touch) and falls back to the denormalized UTM
|
|
@@ -68,27 +166,55 @@ export function buildAttributionRows(entry: FormSubmission): AttributionRow[] {
|
|
|
68
166
|
? `${CHANNEL_LABELS[channel] ?? channel}${referrerName ? ` · ${referrerName}` : ''}`
|
|
69
167
|
: ''
|
|
70
168
|
|
|
71
|
-
const
|
|
72
|
-
{ label:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
169
|
+
const filled = (
|
|
170
|
+
rows: Array<{ label: string; value: string | null | undefined }>,
|
|
171
|
+
): AttributionRow[] =>
|
|
172
|
+
rows.filter((r): r is AttributionRow => typeof r.value === 'string' && r.value !== '')
|
|
173
|
+
|
|
174
|
+
const present = clickIdsFor(blob)
|
|
175
|
+
const clickRow: AttributionRow = {
|
|
176
|
+
label: present.length > 1 ? 'Click IDs' : 'Click ID',
|
|
177
|
+
value: present.length === 0 ? 'None · not an ad click' : '',
|
|
178
|
+
clickIds: present,
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return [
|
|
182
|
+
...filled([
|
|
183
|
+
{ label: 'Channel', value: channelLabel },
|
|
184
|
+
{ label: 'Source', value: attrString(blob, 'source') || entry.utmSource },
|
|
185
|
+
{ label: 'Medium', value: attrString(blob, 'medium') || entry.utmMedium },
|
|
186
|
+
{ label: 'Campaign', value: attrString(blob, 'campaign') || entry.utmCampaign },
|
|
187
|
+
{ label: 'Term', value: attrString(blob, 'term') },
|
|
188
|
+
{ label: 'Content', value: attrString(blob, 'content') },
|
|
189
|
+
]),
|
|
190
|
+
clickRow,
|
|
191
|
+
...filled([
|
|
192
|
+
{ label: 'Landing page', value: attrString(blob, 'landingPage') },
|
|
193
|
+
{ label: 'Page', value: entry.pageUrl },
|
|
194
|
+
{ label: 'Referrer', value: attrString(blob, 'referrer') || entry.referrer },
|
|
195
|
+
{ label: 'Device', value: DEVICE_LABELS[attrString(blob, 'deviceType')] ?? '' },
|
|
196
|
+
{ label: 'First touch', value: formatDateTime(attrString(blob, 'firstTouchAt')) },
|
|
197
|
+
]),
|
|
83
198
|
]
|
|
199
|
+
}
|
|
84
200
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
201
|
+
function clickIdsFor(blob: Record<string, unknown>): AttributionClickId[] {
|
|
202
|
+
const primary = asStringRecord(blob.clickIds)
|
|
203
|
+
const extra = asStringRecord(blob.extraIds)
|
|
204
|
+
const ids = asStringRecord(blob.ids)
|
|
205
|
+
const lines: AttributionClickId[] = []
|
|
206
|
+
for (const { key, platform } of CLICK_ID_ORDER) {
|
|
207
|
+
const value = primary[key] || extra[key] || ids[key] || ''
|
|
208
|
+
if (value) lines.push({ key, platform, value })
|
|
91
209
|
}
|
|
210
|
+
return lines
|
|
211
|
+
}
|
|
92
212
|
|
|
93
|
-
|
|
213
|
+
function asStringRecord(value: unknown): Record<string, string> {
|
|
214
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return {}
|
|
215
|
+
const out: Record<string, string> = {}
|
|
216
|
+
for (const [key, item] of Object.entries(value)) {
|
|
217
|
+
if (typeof item === 'string' && item) out[key] = item
|
|
218
|
+
}
|
|
219
|
+
return out
|
|
94
220
|
}
|
package/src/lib/forms-service.ts
CHANGED
|
@@ -46,6 +46,32 @@ export type {
|
|
|
46
46
|
EntryCounts,
|
|
47
47
|
} from '@prenta/core'
|
|
48
48
|
|
|
49
|
+
export interface FormEntryNote {
|
|
50
|
+
authorId: string
|
|
51
|
+
authorName?: string
|
|
52
|
+
at: string
|
|
53
|
+
text: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface FormEntryDeleted {
|
|
57
|
+
at: string
|
|
58
|
+
by: string
|
|
59
|
+
byName?: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface FormEntryPartial {
|
|
63
|
+
step: number
|
|
64
|
+
of: number
|
|
65
|
+
stepName: string
|
|
66
|
+
lastAt: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface FormEntrySpamMeta {
|
|
70
|
+
by: 'ai' | 'keyword' | 'fast' | 'honeypot' | 'manual'
|
|
71
|
+
reason: string
|
|
72
|
+
score?: number
|
|
73
|
+
}
|
|
74
|
+
|
|
49
75
|
/**
|
|
50
76
|
* `cmsApi` never throws — it returns `{ error, status }` on a network/HTTP
|
|
51
77
|
* failure. Read (GET) fetchers must re-surface that as a thrown error so the
|
|
@@ -354,12 +380,23 @@ export interface EntryPatch {
|
|
|
354
380
|
unread?: boolean
|
|
355
381
|
starred?: boolean
|
|
356
382
|
archived?: boolean
|
|
383
|
+
status?: string
|
|
384
|
+
spamStatus?: 'clean' | 'suspected' | 'spam'
|
|
385
|
+
assigneeId?: string | null
|
|
386
|
+
assigneeName?: string | null
|
|
387
|
+
notes?: FormEntryNote[]
|
|
388
|
+
note?: { text: string; authorName?: string }
|
|
389
|
+
deleted?: FormEntryDeleted | null
|
|
390
|
+
partial?: FormEntryPartial | null
|
|
391
|
+
spamMeta?: FormEntrySpamMeta | null
|
|
357
392
|
}
|
|
358
393
|
|
|
359
394
|
function buildEntriesQuery(params: FetchFormEntriesParams): string {
|
|
360
395
|
const qs = new URLSearchParams()
|
|
361
396
|
if (params.search) qs.set('search', params.search)
|
|
362
397
|
if (params.formId) qs.set('formId', params.formId)
|
|
398
|
+
if (params.folder) qs.set('folder', params.folder)
|
|
399
|
+
if (params.assigneeId) qs.set('assigneeId', params.assigneeId)
|
|
363
400
|
if (typeof params.unread === 'boolean') qs.set('unread', String(params.unread))
|
|
364
401
|
if (typeof params.starred === 'boolean') qs.set('starred', String(params.starred))
|
|
365
402
|
if (typeof params.archived === 'boolean') qs.set('archived', String(params.archived))
|
|
@@ -395,6 +432,7 @@ export async function fetchEntryCounts(params: FetchFormEntriesParams = {}): Pro
|
|
|
395
432
|
export interface EntryDetail {
|
|
396
433
|
entry: FormSubmission
|
|
397
434
|
fields: FormField[]
|
|
435
|
+
otherEntryCount?: number
|
|
398
436
|
}
|
|
399
437
|
|
|
400
438
|
export async function fetchEntry(id: string): Promise<EntryDetail | null> {
|
|
@@ -443,11 +481,17 @@ export async function downloadEntriesExport(
|
|
|
443
481
|
options: {
|
|
444
482
|
formId?: string
|
|
445
483
|
format?: EntriesExportFormat
|
|
484
|
+
folder?: string
|
|
485
|
+
search?: string
|
|
486
|
+
assigneeId?: string
|
|
446
487
|
} = {},
|
|
447
488
|
): Promise<{ error?: string }> {
|
|
448
489
|
const format: EntriesExportFormat = options.format ?? 'csv'
|
|
449
490
|
const qs = new URLSearchParams({ format })
|
|
450
491
|
if (options.formId) qs.set('formId', options.formId)
|
|
492
|
+
if (options.folder && options.folder !== 'all') qs.set('folder', options.folder)
|
|
493
|
+
if (options.search?.trim()) qs.set('search', options.search.trim())
|
|
494
|
+
if (options.assigneeId) qs.set('assigneeId', options.assigneeId)
|
|
451
495
|
|
|
452
496
|
let res: Response
|
|
453
497
|
try {
|
|
@@ -148,6 +148,9 @@ export function validatePage(page: EditorPage, forPublish = false): ValidationRe
|
|
|
148
148
|
for (const issue of result.errors) {
|
|
149
149
|
errors.push(`${label}: ${issue.message}`)
|
|
150
150
|
}
|
|
151
|
+
for (const issue of result.warnings) {
|
|
152
|
+
warnings.push(`${label}: ${issue.message}`)
|
|
153
|
+
}
|
|
151
154
|
}
|
|
152
155
|
|
|
153
156
|
if (isBlank(page.seoTitle)) warnings.push('Add an SEO title to improve search results.')
|
|
@@ -7,8 +7,23 @@ import { EntriesInbox } from './entries/EntriesInbox.js'
|
|
|
7
7
|
|
|
8
8
|
export interface FormEntriesProps {
|
|
9
9
|
onNavigate?: (path: string) => void
|
|
10
|
+
currentPath?: string
|
|
11
|
+
currentUserId?: string
|
|
12
|
+
currentUserName?: string
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
export function FormEntries({
|
|
13
|
-
|
|
15
|
+
export function FormEntries({
|
|
16
|
+
onNavigate,
|
|
17
|
+
currentPath,
|
|
18
|
+
currentUserId,
|
|
19
|
+
currentUserName,
|
|
20
|
+
}: FormEntriesProps) {
|
|
21
|
+
return (
|
|
22
|
+
<EntriesInbox
|
|
23
|
+
onNavigate={onNavigate}
|
|
24
|
+
currentPath={currentPath}
|
|
25
|
+
currentUserId={currentUserId}
|
|
26
|
+
currentUserName={currentUserName}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
14
29
|
}
|
|
@@ -9,8 +9,22 @@ import { EntriesInbox } from './entries/EntriesInbox.js'
|
|
|
9
9
|
export interface FormSubmissionsProps {
|
|
10
10
|
formId: string
|
|
11
11
|
onNavigate?: (path: string) => void
|
|
12
|
+
currentUserId?: string
|
|
13
|
+
currentUserName?: string
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
export function FormSubmissions({
|
|
15
|
-
|
|
16
|
+
export function FormSubmissions({
|
|
17
|
+
formId,
|
|
18
|
+
onNavigate,
|
|
19
|
+
currentUserId,
|
|
20
|
+
currentUserName,
|
|
21
|
+
}: FormSubmissionsProps) {
|
|
22
|
+
return (
|
|
23
|
+
<EntriesInbox
|
|
24
|
+
formId={formId}
|
|
25
|
+
onNavigate={onNavigate}
|
|
26
|
+
currentUserId={currentUserId}
|
|
27
|
+
currentUserName={currentUserName}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
16
30
|
}
|