@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,37 +1,534 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Forms → Form Settings. Five tabs from the form-settings handoff, saved as
|
|
5
|
+
* one `formsSettings` global. Per-form editors still override these defaults.
|
|
6
|
+
*/
|
|
7
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { AlertCircle, Check, Clock, FileText, Lock, Mail, Send, Shield, Target } from 'lucide-react';
|
|
9
|
+
import { toast } from 'sonner';
|
|
5
10
|
import { Breadcrumb } from '../components/ui/Breadcrumb.js';
|
|
6
|
-
import {
|
|
11
|
+
import { Button } from '../components/ui/Button.js';
|
|
12
|
+
import { Toggle } from '../components/ui/Toggle.js';
|
|
7
13
|
import { UnderlineTabs } from '../components/ui/UnderlineTabs.js';
|
|
8
|
-
import {
|
|
14
|
+
import { BlocklistDialog, BlocklistSummary, } from '../components/forms/BlocklistDialog.js';
|
|
15
|
+
import { LONG_TAIL_CLICK_IDS, TOP_TIER_CLICK_IDS } from '@prenta/core/forms/attribution';
|
|
16
|
+
import { validateAttributionWindows } from '@prenta/core/forms/attribution-settings';
|
|
17
|
+
import { fetchFormCaptchaSettings, saveFormCaptchaSettings, setLoginCaptcha, fetchConsentConfig, fetchEmailSummary, fetchFormsSettings, fetchRetentionPreview, fetchSpamAiStats, saveFormsSettings, sendFormEmailTest, downloadEntriesExport, } from '../lib/forms-service.js';
|
|
18
|
+
import { getRecaptchaV3Token } from '../lib/recaptcha.js';
|
|
9
19
|
const TABS = [
|
|
10
|
-
{ id: 'spam', label: 'Spam protection' },
|
|
11
|
-
{ id: 'defaults', label: 'Defaults' },
|
|
12
|
-
{ id: 'retention', label: 'Retention' },
|
|
13
|
-
{ id: 'attribution', label: 'Attribution' },
|
|
14
|
-
{ id: 'email', label: 'Email delivery' },
|
|
20
|
+
{ id: 'spam', label: 'Spam protection', icon: Shield },
|
|
21
|
+
{ id: 'defaults', label: 'Defaults', icon: FileText },
|
|
22
|
+
{ id: 'retention', label: 'Retention', icon: Clock },
|
|
23
|
+
{ id: 'attribution', label: 'Attribution', icon: Target },
|
|
24
|
+
{ id: 'email', label: 'Email delivery', icon: Mail },
|
|
15
25
|
];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
/** Turn on in the change that ships the retention job (F-04). */
|
|
27
|
+
const RETENTION_APPLIED = false;
|
|
28
|
+
const CLICK_COPY = {
|
|
29
|
+
gclid: 'Google Ads',
|
|
30
|
+
fbclid: 'Meta',
|
|
31
|
+
msclkid: 'Microsoft Ads',
|
|
32
|
+
ttclid: 'TikTok Ads',
|
|
33
|
+
li_fat_id: 'LinkedIn Ads',
|
|
34
|
+
dclid: 'Google Display',
|
|
35
|
+
twclid: 'X Ads',
|
|
36
|
+
rdt_cid: 'Reddit Ads',
|
|
37
|
+
};
|
|
38
|
+
const CAMPAIGN_FIELDS = [
|
|
39
|
+
['source', 'utm_source, or the referring site'],
|
|
40
|
+
['medium', 'utm_medium, e.g. cpc, email'],
|
|
41
|
+
['campaign', 'utm_campaign'],
|
|
42
|
+
['term', 'utm_term (paid keyword)'],
|
|
43
|
+
['content', 'utm_content (ad or link variant)'],
|
|
44
|
+
['channel', 'paid, search_organic, social, email, ai, referral or direct'],
|
|
45
|
+
['referrerName', 'Friendly name, e.g. ChatGPT, Google'],
|
|
46
|
+
];
|
|
47
|
+
const VISIT_FIELDS = [
|
|
48
|
+
['landingPage', 'First page they arrived on'],
|
|
49
|
+
['referrer', 'External site that sent them'],
|
|
50
|
+
['deviceType', 'desktop, tablet or mobile'],
|
|
51
|
+
['pageViews', 'Pages viewed this session'],
|
|
52
|
+
['sessionStart', 'When the session began'],
|
|
53
|
+
['firstTouchAt', 'When the first touch was recorded'],
|
|
54
|
+
['lastTouchAt', 'When the last touch was recorded'],
|
|
55
|
+
];
|
|
56
|
+
const EXTRA_IDS = [...new Set(LONG_TAIL_CLICK_IDS.map((id) => id.toLowerCase()))];
|
|
57
|
+
function diffCount(left, right) {
|
|
58
|
+
const a = left;
|
|
59
|
+
const b = right;
|
|
60
|
+
const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
61
|
+
let count = 0;
|
|
62
|
+
for (const key of keys) {
|
|
63
|
+
if (JSON.stringify(a[key]) !== JSON.stringify(b[key]))
|
|
64
|
+
count += 1;
|
|
65
|
+
}
|
|
66
|
+
return count;
|
|
67
|
+
}
|
|
68
|
+
function sectionChanges(saved, draft, id) {
|
|
69
|
+
if (id === 'spam') {
|
|
70
|
+
const { rateLimit: savedRate, ...savedRest } = saved.spam;
|
|
71
|
+
const { rateLimit: draftRate, ...draftRest } = draft.spam;
|
|
72
|
+
return diffCount(savedRest, draftRest) + diffCount(savedRate, draftRate);
|
|
73
|
+
}
|
|
74
|
+
if (id === 'defaults')
|
|
75
|
+
return diffCount(saved.defaults, draft.defaults);
|
|
76
|
+
if (id === 'retention')
|
|
77
|
+
return diffCount(saved.retention, draft.retention);
|
|
78
|
+
if (id === 'attribution') {
|
|
79
|
+
return JSON.stringify(saved.attribution) === JSON.stringify(draft.attribution) ? 0 : 1;
|
|
80
|
+
}
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
function restoreSection(saved, draft, id) {
|
|
84
|
+
if (id === 'spam')
|
|
85
|
+
return { ...draft, spam: saved.spam };
|
|
86
|
+
if (id === 'defaults')
|
|
87
|
+
return { ...draft, defaults: saved.defaults };
|
|
88
|
+
if (id === 'retention')
|
|
89
|
+
return { ...draft, retention: saved.retention };
|
|
90
|
+
if (id === 'attribution')
|
|
91
|
+
return { ...draft, attribution: saved.attribution };
|
|
92
|
+
return draft;
|
|
93
|
+
}
|
|
94
|
+
const KEEP_LABEL = {
|
|
95
|
+
730: '2 years',
|
|
96
|
+
365: '1 year',
|
|
97
|
+
180: '6 months',
|
|
98
|
+
90: '90 days',
|
|
99
|
+
};
|
|
100
|
+
const STRICTNESS = {
|
|
101
|
+
relaxed: 'Only flags obvious junk. Fewer mistakes, some spam gets through.',
|
|
102
|
+
balanced: 'Flags scams, bulk outreach and off-topic pitches. A good starting point.',
|
|
103
|
+
strict: 'Also flags sales pitches, guest-post requests and vague one-liners. Check Spam more often.',
|
|
104
|
+
};
|
|
105
|
+
function tabFromPath(path) {
|
|
106
|
+
const segment = path.split('?')[0]?.split('/').filter(Boolean)[2];
|
|
107
|
+
return TABS.some((tab) => tab.id === segment) ? segment : 'spam';
|
|
108
|
+
}
|
|
109
|
+
export function FormsSettings({ currentPath = '/forms/settings/spam', onNavigate, role, }) {
|
|
110
|
+
const readOnly = !!role && role !== 'OWNER' && role !== 'ADMIN';
|
|
111
|
+
const routeTab = tabFromPath(currentPath);
|
|
112
|
+
const [tab, setTab] = useState(routeTab);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
setTab(routeTab);
|
|
115
|
+
}, [routeTab]);
|
|
116
|
+
const [saved, setSaved] = useState(null);
|
|
117
|
+
const [draft, setDraft] = useState(null);
|
|
118
|
+
const [error, setError] = useState(null);
|
|
119
|
+
const [fieldErrors, setFieldErrors] = useState({});
|
|
120
|
+
const [saving, setSaving] = useState(false);
|
|
121
|
+
const [saveState, setSaveState] = useState('idle');
|
|
122
|
+
const [blocklistKind, setBlocklistKind] = useState(null);
|
|
123
|
+
const [captchaSettings, setCaptchaSettings] = useState(null);
|
|
124
|
+
const captcha = captchaSettings ? captchaSettings.provider !== 'none' : null;
|
|
125
|
+
const [aiStats, setAiStats] = useState({ reviewed: 0, flagged: 0, corrected: 0 });
|
|
126
|
+
const [email, setEmail] = useState(null);
|
|
127
|
+
const [consent, setConsent] = useState({ installed: false, bannerEnabled: false });
|
|
128
|
+
const [purgeCount, setPurgeCount] = useState(0);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
let cancelled = false;
|
|
131
|
+
void fetchFormsSettings()
|
|
132
|
+
.then((doc) => {
|
|
133
|
+
if (cancelled)
|
|
134
|
+
return;
|
|
135
|
+
setSaved(doc);
|
|
136
|
+
setDraft(doc);
|
|
137
|
+
})
|
|
138
|
+
.catch((err) => {
|
|
139
|
+
if (!cancelled)
|
|
140
|
+
setError(err instanceof Error ? err.message : 'Could not load form settings');
|
|
141
|
+
});
|
|
142
|
+
void fetchFormCaptchaSettings().then(setCaptchaSettings);
|
|
143
|
+
void fetchSpamAiStats().then(setAiStats);
|
|
144
|
+
void fetchEmailSummary().then(setEmail);
|
|
145
|
+
void fetchConsentConfig().then(setConsent);
|
|
146
|
+
return () => {
|
|
147
|
+
cancelled = true;
|
|
148
|
+
};
|
|
149
|
+
}, []);
|
|
150
|
+
const entryDays = draft?.retention?.entryDays;
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (entryDays == null) {
|
|
153
|
+
setPurgeCount(0);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
void fetchRetentionPreview(entryDays).then((preview) => setPurgeCount(preview.entries));
|
|
157
|
+
}, [entryDays]);
|
|
158
|
+
const attributionErrors = useMemo(() => {
|
|
159
|
+
if (!draft?.attribution.record)
|
|
160
|
+
return {};
|
|
161
|
+
const result = validateAttributionWindows(draft.attribution);
|
|
162
|
+
if (result.ok)
|
|
163
|
+
return {};
|
|
164
|
+
const bag = result.errors ??
|
|
165
|
+
{ [result.field]: result.message };
|
|
166
|
+
const errors = {};
|
|
167
|
+
for (const [field, message] of Object.entries(bag)) {
|
|
168
|
+
if (message)
|
|
169
|
+
errors[`attribution.${field}`] = message;
|
|
170
|
+
}
|
|
171
|
+
return errors;
|
|
172
|
+
}, [draft]);
|
|
173
|
+
const dirtyCount = useMemo(() => {
|
|
174
|
+
if (!saved || !draft)
|
|
175
|
+
return 0;
|
|
176
|
+
return TABS.reduce((sum, item) => sum + sectionChanges(saved, draft, item.id), 0);
|
|
177
|
+
}, [saved, draft]);
|
|
178
|
+
const dirty = dirtyCount > 0;
|
|
179
|
+
function tabDirty(id) {
|
|
180
|
+
if (!saved || !draft)
|
|
181
|
+
return 0;
|
|
182
|
+
return sectionChanges(saved, draft, id);
|
|
183
|
+
}
|
|
184
|
+
function go(next) {
|
|
185
|
+
if (next === tab)
|
|
186
|
+
return;
|
|
187
|
+
const pending = tabDirty(tab);
|
|
188
|
+
if (pending > 0 && saved && draft) {
|
|
189
|
+
const label = `${pending} unsaved ${pending === 1 ? 'change' : 'changes'}`;
|
|
190
|
+
if (!window.confirm(`You have ${label} on this tab. Discard them?`))
|
|
191
|
+
return;
|
|
192
|
+
setDraft(restoreSection(saved, draft, tab));
|
|
193
|
+
}
|
|
194
|
+
setTab(next);
|
|
195
|
+
onNavigate?.(`/forms/settings/${next}`);
|
|
196
|
+
}
|
|
197
|
+
async function save() {
|
|
198
|
+
if (!draft || readOnly || saving)
|
|
199
|
+
return;
|
|
200
|
+
if (Object.keys(attributionErrors).length > 0) {
|
|
201
|
+
setFieldErrors(attributionErrors);
|
|
202
|
+
setSaveState('idle');
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
setSaving(true);
|
|
206
|
+
setSaveState('saving');
|
|
207
|
+
const result = await saveFormsSettings(draft);
|
|
208
|
+
setSaving(false);
|
|
209
|
+
if (result.fields && Object.keys(result.fields).length > 0) {
|
|
210
|
+
setFieldErrors(result.fields);
|
|
211
|
+
setSaveState('error');
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (result.error || !result.data) {
|
|
215
|
+
setSaveState('error');
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
setFieldErrors({});
|
|
219
|
+
setSaved(result.data);
|
|
220
|
+
setDraft(result.data);
|
|
221
|
+
setSaveState('saved');
|
|
222
|
+
}
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (saveState !== 'saved')
|
|
225
|
+
return;
|
|
226
|
+
const timer = window.setTimeout(() => setSaveState('idle'), 1600);
|
|
227
|
+
return () => window.clearTimeout(timer);
|
|
228
|
+
}, [saveState]);
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
function onKey(event) {
|
|
231
|
+
if (!(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== 's')
|
|
232
|
+
return;
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
void save();
|
|
235
|
+
}
|
|
236
|
+
window.addEventListener('keydown', onKey);
|
|
237
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
238
|
+
});
|
|
239
|
+
if (error) {
|
|
240
|
+
return (_jsx("p", { className: "text-err p-6", role: "alert", children: error }));
|
|
241
|
+
}
|
|
242
|
+
if (!draft) {
|
|
243
|
+
return (_jsx("p", { className: "text-sub p-6", role: "status", children: "Loading form settings\u2026" }));
|
|
244
|
+
}
|
|
245
|
+
return (_jsxs("div", { className: "flex h-full min-h-0 flex-col overflow-x-hidden overflow-y-auto", children: [_jsxs("header", { className: "px-7 pt-5", children: [_jsx(Breadcrumb, { items: [{ label: 'Forms', path: '/forms' }, { label: 'Settings' }] }), _jsx("h1", { className: "text-txt m-0 mt-2 text-[21px] font-bold tracking-[-0.5px]", children: "Form settings" }), _jsx("p", { className: "text-sub mt-1 max-w-[620px] text-[13px]", children: "Rules that apply to every form: how spam is caught, what new forms start with, how long submissions are kept, and where visitors came from." })] }), _jsx(UnderlineTabs, { className: "mx-7 mt-4", label: "Form settings tabs", value: tab, onChange: (id) => go(id), tabs: TABS.map((item) => {
|
|
246
|
+
const Icon = item.icon;
|
|
247
|
+
const pending = tabDirty(item.id);
|
|
248
|
+
return {
|
|
249
|
+
id: item.id,
|
|
250
|
+
label: item.label,
|
|
251
|
+
icon: _jsx(Icon, { size: 15, strokeWidth: 1.75 }),
|
|
252
|
+
badge: pending > 0 ? (_jsx("i", { className: "bg-warn ml-1 inline-block h-1.5 w-1.5 rounded-full", "aria-label": "unsaved" })) : undefined,
|
|
253
|
+
};
|
|
254
|
+
}) }), _jsxs("div", { className: "mx-auto flex w-full max-w-[836px] flex-col gap-4 px-7 py-5 pb-28", children: [readOnly ? (_jsxs("p", { className: "border-bdr bg-card text-sub flex items-center gap-2.5 rounded-[10px] border px-3.5 py-2.5 text-[13px]", children: [_jsx(Lock, { size: 16, className: "text-faint shrink-0", "aria-hidden": true }), "You have view-only access to form settings. Ask an admin to make changes."] })) : null, _jsxs("fieldset", { disabled: readOnly, className: "m-0 flex min-w-0 flex-col gap-4 border-0 p-0", children: [tab === 'spam' ? (_jsxs(_Fragment, { children: [_jsxs(Card, { title: "Spam protection", description: "Checks run on every submission before it reaches your inbox.", children: [_jsx(Row, { label: "Honeypot field", help: "A hidden field people never see. Bots fill it in and get caught.", children: _jsx(Toggle, { checked: draft.spam.honeypot, onCheckedChange: (honeypot) => setDraft({ ...draft, spam: { ...draft.spam, honeypot } }), "aria-label": "Honeypot field" }) }), _jsxs(Row, { label: "CAPTCHA", help: captchaHelp(captchaSettings), children: [_jsx("span", { className: `rounded-pill px-2 py-0.5 text-[12px] font-semibold ${captcha ? 'bg-suc-l text-suc' : 'bg-warn-l text-warn'}`, children: captcha ? 'Active' : 'Not set up' }), _jsxs("select", { "aria-label": "CAPTCHA", disabled: captcha === false, value: draft.spam.captchaScope, onChange: (event) => setDraft({
|
|
255
|
+
...draft,
|
|
256
|
+
spam: {
|
|
257
|
+
...draft.spam,
|
|
258
|
+
captchaScope: event.target
|
|
259
|
+
.value,
|
|
260
|
+
},
|
|
261
|
+
}), className: "border-bdr bg-card text-txt h-9 rounded-[8px] border px-2.5 text-[13px] disabled:opacity-45", children: [_jsx("option", { value: "all", children: "On all forms" }), _jsx("option", { value: "per", children: "Choose per form" }), _jsx("option", { value: "off", children: "Off" })] })] }), captchaSettings ? (_jsx(RecaptchaKeys, { settings: captchaSettings, readOnly: readOnly, onSaved: setCaptchaSettings })) : null, _jsxs(Row, { label: "Submission limit", help: "Stops one visitor from flooding a form.", children: [_jsx("input", { "aria-label": "Submission limit", type: "number", min: 1, value: draft.spam.rateLimit.max, onChange: (event) => setDraft({
|
|
262
|
+
...draft,
|
|
263
|
+
spam: {
|
|
264
|
+
...draft.spam,
|
|
265
|
+
rateLimit: { ...draft.spam.rateLimit, max: Number(event.target.value) },
|
|
266
|
+
},
|
|
267
|
+
}), className: "border-bdr bg-card h-9 w-[72px] rounded-[8px] border px-2.5 text-right text-[13px] tabular-nums" }), _jsx("span", { className: "text-sub text-[13px]", children: "per visitor every" }), _jsxs("select", { "aria-label": "Submission window", value: draft.spam.rateLimit.window, onChange: (event) => setDraft({
|
|
268
|
+
...draft,
|
|
269
|
+
spam: {
|
|
270
|
+
...draft.spam,
|
|
271
|
+
rateLimit: {
|
|
272
|
+
...draft.spam.rateLimit,
|
|
273
|
+
window: event.target
|
|
274
|
+
.value,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
}), className: "border-bdr bg-card h-9 rounded-[8px] border px-2.5 text-[13px]", children: [_jsx("option", { value: "1m", children: "minute" }), _jsx("option", { value: "10m", children: "10 minutes" }), _jsx("option", { value: "1h", children: "hour" }), _jsx("option", { value: "1d", children: "day" })] })] }), _jsxs(Row, { label: "Too-fast submissions", help: "People take a few seconds to fill in a form. Anything quicker is treated as a bot.", children: [_jsx("span", { className: "text-sub text-[13px]", children: "Flag if sent in under" }), _jsx("input", { "aria-label": "Minimum seconds", type: "number", min: 0, value: draft.spam.minSeconds, onChange: (event) => setDraft({
|
|
278
|
+
...draft,
|
|
279
|
+
spam: { ...draft.spam, minSeconds: Number(event.target.value) },
|
|
280
|
+
}), className: "border-bdr bg-card h-9 w-[72px] rounded-[8px] border px-2.5 text-right text-[13px] tabular-nums" }), _jsx("span", { className: "text-sub text-[13px]", children: "seconds" })] }), _jsx(Row, { label: "Blocked words & email domains", help: "Entries that contain a blocked word, or come from a blocked domain, go straight to Spam.", children: _jsx(BlocklistSummary, { value: draft.spam.blocklist, disabled: readOnly, onManage: setBlocklistKind }) }), _jsx(Row, { label: "When spam is caught", children: _jsxs("div", { className: "flex flex-col gap-2", role: "radiogroup", "aria-label": "When spam is caught", children: [_jsx(RadioCard, { name: "spam-action", checked: draft.spam.action === 'quarantine', title: "Move to Spam", help: "Kept out of your inbox. Review and restore anything flagged by mistake.", onChange: () => setDraft({ ...draft, spam: { ...draft.spam, action: 'quarantine' } }) }), _jsx(RadioCard, { name: "spam-action", checked: draft.spam.action === 'discard', title: "Discard", help: "Never saved. Notifications aren't sent and nothing can be recovered.", onChange: () => setDraft({ ...draft, spam: { ...draft.spam, action: 'discard' } }) })] }) })] }), _jsxs(Card, { title: "AI spam review", description: "Reads entries that get past the checks above and moves likely spam to the Spam folder. It never deletes anything.", children: [_jsx("p", { className: "bg-bg text-sub mx-5 mt-3.5 rounded-[9px] px-3 py-2.5 text-[12.5px]", role: "note", children: "AI spam review isn't running yet. These choices are saved for when it does." }), _jsxs("p", { className: `mx-5 mt-3.5 mb-1 rounded-[10px] px-3 py-2 text-[13px] ${draft.spam.ai.on ? 'bg-acc-l text-txt' : 'bg-bg text-sub'}`, children: [_jsx("b", { children: draft.spam.ai.on ? 'On' : 'Off' }), draft.spam.ai.on
|
|
281
|
+
? ` · Uses the AI provider from Settings → AI. Last 30 days: ${aiStats.reviewed} reviewed · ${aiStats.flagged} flagged · ${aiStats.corrected} marked Not spam.`
|
|
282
|
+
: ' · Only the checks above run. Entries that look human-written reach your inbox.'] }), _jsx(Row, { label: "Review entries with AI", help: "Runs last, so most bots are caught for free before AI is used.", children: _jsx(Toggle, { checked: draft.spam.ai.on, onCheckedChange: (on) => setDraft({ ...draft, spam: { ...draft.spam, ai: { ...draft.spam.ai, on } } }), "aria-label": "Review entries with AI" }) }), _jsxs("fieldset", { disabled: !draft.spam.ai.on, className: "m-0 min-w-0 border-0 p-0 disabled:opacity-45", children: [_jsx(Row, { label: "How strict", help: STRICTNESS[draft.spam.ai.strictness], children: _jsx("div", { role: "radiogroup", "aria-label": "How strict", className: "bg-bg flex rounded-[9px] p-[3px]", children: ['relaxed', 'balanced', 'strict'].map((level) => (_jsx("button", { type: "button", role: "radio", "aria-checked": draft.spam.ai.strictness === level, onClick: () => setDraft({
|
|
283
|
+
...draft,
|
|
284
|
+
spam: { ...draft.spam, ai: { ...draft.spam.ai, strictness: level } },
|
|
285
|
+
}), className: `rounded-[7px] px-2.5 py-[5px] text-[12.5px] font-medium capitalize ${draft.spam.ai.strictness === level ? 'bg-card text-txt shadow-shd' : 'text-sub'}`, children: level }, level))) }) }), _jsx(Row, { label: "Hold notifications for flagged entries", help: "Your team isn't emailed about entries AI moves to Spam.", children: _jsx(Toggle, { checked: draft.spam.ai.holdNotifications, onCheckedChange: (holdNotifications) => setDraft({
|
|
286
|
+
...draft,
|
|
287
|
+
spam: { ...draft.spam, ai: { ...draft.spam.ai, holdNotifications } },
|
|
288
|
+
}), "aria-label": "Hold notifications for flagged entries" }) }), _jsx(Row, { label: "Learn from your corrections", help: "When you mark something Not spam, similar entries are let through next time.", children: _jsx(Toggle, { checked: draft.spam.ai.learnFromCorrections, onCheckedChange: (learnFromCorrections) => setDraft({
|
|
289
|
+
...draft,
|
|
290
|
+
spam: { ...draft.spam, ai: { ...draft.spam.ai, learnFromCorrections } },
|
|
291
|
+
}), "aria-label": "Learn from your corrections" }) })] })] })] })) : null, tab === 'defaults' ? (_jsxs(Card, { title: "Defaults for new forms", description: "Starting values when someone creates a form. Each form can change them afterwards.", children: [_jsx(Row, { label: "Notify these addresses", help: "Who gets an email for each new submission.", children: _jsx("input", { "aria-label": "Notify these addresses", value: draft.defaults.recipients.join(', '), onChange: (event) => setDraft({
|
|
292
|
+
...draft,
|
|
293
|
+
defaults: {
|
|
294
|
+
...draft.defaults,
|
|
295
|
+
recipients: event.target.value
|
|
296
|
+
.split(',')
|
|
297
|
+
.map((item) => item.trim())
|
|
298
|
+
.filter(Boolean),
|
|
299
|
+
},
|
|
300
|
+
}), className: "border-bdr bg-card h-9 w-full max-w-sm rounded-[8px] border px-2.5 text-[13px]" }) }), fieldErrors['defaults.recipients'] ? (_jsx("p", { className: "text-err px-5 text-[12px]", role: "alert", children: fieldErrors['defaults.recipients'] })) : null, _jsx(Row, { label: "Reply goes to the person who filled in the form", help: "Hitting Reply on a notification answers the submitter directly.", children: _jsx(Toggle, { checked: draft.defaults.replyToSubmitter, onCheckedChange: (replyToSubmitter) => setDraft({ ...draft, defaults: { ...draft.defaults, replyToSubmitter } }), "aria-label": "Reply goes to the person who filled in the form" }) }), _jsx(Row, { label: "Thank-you message", help: "Shown on the page after someone submits.", children: _jsx("textarea", { "aria-label": "Thank-you message", value: draft.defaults.successMessage, onChange: (event) => setDraft({
|
|
301
|
+
...draft,
|
|
302
|
+
defaults: { ...draft.defaults, successMessage: event.target.value },
|
|
303
|
+
}), className: "border-bdr bg-card min-h-[72px] w-full max-w-sm resize-y rounded-[8px] border px-2.5 py-2 text-[13px]" }) }), fieldErrors['defaults.successMessage'] ? (_jsx("p", { className: "text-err px-5 text-[12px]", role: "alert", children: fieldErrors['defaults.successMessage'] })) : null, _jsx(Row, { label: "Send a confirmation email", help: "An automatic we-got-it email to the person who submitted.", children: _jsx(Toggle, { checked: draft.defaults.confirmationEmail, onCheckedChange: (confirmationEmail) => setDraft({ ...draft, defaults: { ...draft.defaults, confirmationEmail } }), "aria-label": "Send a confirmation email" }) })] })) : null, tab === 'retention' ? (_jsxs(Card, { title: "Data retention", description: "How long submissions and logs are kept before they're permanently deleted.", children: [RETENTION_APPLIED ? null : (_jsx("p", { className: "bg-bg text-sub mx-5 mt-3.5 rounded-[9px] px-3 py-2.5 text-[12.5px]", role: "note", children: "These choices are saved but not applied yet. Nothing is deleted on this schedule until the retention job ships." })), _jsx(Row, { label: "Keep entries", help: "Starred entries are always kept.", children: _jsx(DaySelect, { ariaLabel: "Keep entries", value: draft.retention.entryDays, options: [
|
|
304
|
+
[null, 'Forever'],
|
|
305
|
+
[730, '2 years'],
|
|
306
|
+
[365, '1 year'],
|
|
307
|
+
[180, '6 months'],
|
|
308
|
+
[90, '90 days'],
|
|
309
|
+
], onChange: (entryDays) => setDraft({ ...draft, retention: { ...draft.retention, entryDays } }) }) }), RETENTION_APPLIED && draft.retention.entryDays != null && purgeCount > 0 ? (_jsxs("p", { className: "bg-bg text-sub mx-5 mb-4 rounded-[9px] px-3 py-2.5 text-[12.5px]", role: "note", children: [purgeCount, " entries older than", ' ', _jsx("b", { children: (KEEP_LABEL[draft.retention.entryDays] ?? 'this window').toLowerCase() }), ' ', "will be deleted tonight and can't be recovered.", ' ', _jsx("button", { type: "button", className: "text-acc font-semibold", onClick: () => void downloadEntriesExport({ format: 'csv' }), children: "Export a copy first" }), "."] })) : null, _jsx(Row, { label: "Empty Spam after", children: _jsx(DaySelect, { ariaLabel: "Empty Spam after", value: draft.retention.spamDays, options: [
|
|
310
|
+
[7, '7 days'],
|
|
311
|
+
[30, '30 days'],
|
|
312
|
+
[90, '90 days'],
|
|
313
|
+
], onChange: (spamDays) => setDraft({
|
|
314
|
+
...draft,
|
|
315
|
+
retention: { ...draft.retention, spamDays: spamDays },
|
|
316
|
+
}) }) }), _jsx(Row, { label: "Delete archived entries after", children: _jsx(DaySelect, { ariaLabel: "Delete archived entries after", value: draft.retention.archivedDays, options: [
|
|
317
|
+
[null, 'Never'],
|
|
318
|
+
[90, '90 days'],
|
|
319
|
+
[365, '1 year'],
|
|
320
|
+
], onChange: (archivedDays) => setDraft({ ...draft, retention: { ...draft.retention, archivedDays } }) }) }), _jsx(Row, { label: "Keep the SMTP log for", help: "Delivery history for notifications, confirmations, and webhooks.", children: _jsx(DaySelect, { ariaLabel: "Keep the SMTP log for", value: draft.retention.deliveryLogDays, options: [
|
|
321
|
+
[30, '30 days'],
|
|
322
|
+
[90, '90 days'],
|
|
323
|
+
[365, '1 year'],
|
|
324
|
+
], onChange: (deliveryLogDays) => setDraft({
|
|
325
|
+
...draft,
|
|
326
|
+
retention: {
|
|
327
|
+
...draft.retention,
|
|
328
|
+
deliveryLogDays: deliveryLogDays,
|
|
329
|
+
},
|
|
330
|
+
}) }) }), _jsx(Row, { label: "Visitor IP addresses", help: "Used for spam checks. Shortening hides the last part of the address.", children: _jsx("div", { role: "radiogroup", "aria-label": "Visitor IP addresses", className: "bg-bg flex rounded-[9px] p-[3px]", children: [
|
|
331
|
+
['full', 'Store'],
|
|
332
|
+
['anon', 'Shorten'],
|
|
333
|
+
['none', "Don't store"],
|
|
334
|
+
].map(([id, label]) => (_jsx("button", { type: "button", role: "radio", "aria-checked": draft.retention.ipStorage === id, onClick: () => setDraft({ ...draft, retention: { ...draft.retention, ipStorage: id } }), className: `rounded-[7px] px-2.5 py-[5px] text-[12.5px] font-medium ${draft.retention.ipStorage === id ? 'bg-card text-txt shadow-shd' : 'text-sub'}`, children: label }, id))) }) }), _jsx(Row, { label: "Delete uploaded files with their entry", help: "Removes attachments from Media when an entry is deleted.", children: _jsx(Toggle, { checked: draft.retention.deleteFilesWithEntry, onCheckedChange: (deleteFilesWithEntry) => setDraft({ ...draft, retention: { ...draft.retention, deleteFilesWithEntry } }), "aria-label": "Delete uploaded files with their entry" }) })] })) : null, tab === 'attribution' ? (_jsx(AttributionTab, { draft: draft, setDraft: setDraft, banner: consent.installed && consent.bannerEnabled, errors: attributionErrors, onOpenPrivacy: () => onNavigate?.('/settings') })) : null, tab === 'email' ? (_jsx(EmailDelivery, { email: email, onChange: setEmail, onNavigate: onNavigate })) : null] }), _jsx(BlocklistDialog, { open: blocklistKind !== null, initialTab: blocklistKind ?? 'words', value: draft.spam.blocklist, onChange: (blocklist) => setDraft({ ...draft, spam: { ...draft.spam, blocklist } }), onClose: () => setBlocklistKind(null) })] }), readOnly ? null : (_jsx(SettingsSaveBar, { dirty: dirty, count: dirtyCount, state: saveState, invalid: Object.keys(attributionErrors).length, onDiscard: () => saved && setDraft(saved), onSave: () => void save() }))] }));
|
|
335
|
+
}
|
|
336
|
+
const EMAIL_PROVIDER_LABEL = {
|
|
337
|
+
resend: 'Resend',
|
|
338
|
+
smtpcom: 'SMTP.com',
|
|
339
|
+
ses: 'Amazon SES',
|
|
340
|
+
smtp: 'SMTP server',
|
|
341
|
+
};
|
|
342
|
+
function emailProviderLabel(provider) {
|
|
343
|
+
if (!provider)
|
|
344
|
+
return '—';
|
|
345
|
+
return EMAIL_PROVIDER_LABEL[provider] ?? provider;
|
|
346
|
+
}
|
|
347
|
+
function emailTestDate(iso) {
|
|
348
|
+
const day = iso.slice(0, 10);
|
|
349
|
+
const date = new Date(`${day}T00:00:00Z`);
|
|
350
|
+
if (Number.isNaN(date.getTime()))
|
|
351
|
+
return day;
|
|
352
|
+
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' });
|
|
353
|
+
}
|
|
354
|
+
function EmailDelivery({ email, onChange, onNavigate, }) {
|
|
355
|
+
const [sending, setSending] = useState(false);
|
|
356
|
+
async function sendTest() {
|
|
357
|
+
setSending(true);
|
|
358
|
+
const result = await sendFormEmailTest();
|
|
359
|
+
setSending(false);
|
|
360
|
+
if (result.error || !result.sentTo) {
|
|
361
|
+
toast.error(result.error ?? 'Test send failed');
|
|
362
|
+
if (email) {
|
|
363
|
+
onChange({ ...email, lastTest: { ok: false, at: new Date().toISOString() } });
|
|
364
|
+
}
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
toast.success(`Test email sent to ${result.sentTo}`);
|
|
368
|
+
if (email) {
|
|
369
|
+
onChange({ ...email, lastTest: { ok: true, at: new Date().toISOString() } });
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return (_jsxs(Card, { title: "Email delivery", description: "The account that sends notifications and confirmation emails. Shared with invites and password resets.", children: [email?.configured ? (_jsx("dl", { className: "border-bdr grid grid-cols-1 border-b min-[641px]:grid-cols-3", children: [
|
|
373
|
+
['Provider', emailProviderLabel(email.provider), 'text-txt'],
|
|
374
|
+
['Sends from', email.from ?? '—', 'text-txt'],
|
|
375
|
+
[
|
|
376
|
+
'Last test',
|
|
377
|
+
email.lastTest
|
|
378
|
+
? `${email.lastTest.ok ? 'Passed' : 'Failed'} · ${emailTestDate(email.lastTest.at)}`
|
|
379
|
+
: 'Not tested',
|
|
380
|
+
email.lastTest ? (email.lastTest.ok ? 'text-suc' : 'text-err') : 'text-sub',
|
|
381
|
+
],
|
|
382
|
+
].map(([label, value, tone]) => (_jsxs("div", { className: "border-bdr min-w-0 px-5 py-3.5 max-[640px]:[&:not(:first-child)]:border-t min-[641px]:[&:not(:first-child)]:border-l", children: [_jsx("dt", { className: "text-faint text-[11px] font-semibold tracking-[0.4px] uppercase", children: label }), _jsx("dd", { className: `m-0 mt-0.5 truncate text-[13px] font-medium ${tone}`, children: value })] }, label))) })) : (_jsx("p", { className: "text-sub m-0 px-5 py-4 text-[13px]", children: "Email isn't set up yet. Notifications won't send." })), _jsx("div", { className: "flex flex-wrap justify-end gap-2 px-5 py-3", children: email?.configured ? (_jsxs(_Fragment, { children: [_jsx(Button, { type: "button", variant: "secondary", leftIcon: _jsx(Mail, { size: 14, strokeWidth: 1.75, "aria-hidden": true }), onClick: () => onNavigate?.('/forms/deliveries'), children: "SMTP log" }), _jsx(Button, { type: "button", variant: "secondary", loading: sending, leftIcon: _jsx(Send, { size: 14, strokeWidth: 1.75, "aria-hidden": true }), onClick: () => void sendTest(), children: "Send test email" }), _jsx(Button, { type: "button", onClick: () => onNavigate?.('/settings?tab=email'), children: "SMTP settings" })] })) : (_jsx(Button, { type: "button", onClick: () => onNavigate?.('/settings?tab=email'), children: "Set up email" })) })] }));
|
|
383
|
+
}
|
|
384
|
+
function SettingsSaveBar({ dirty, count, state, invalid, onDiscard, onSave, }) {
|
|
385
|
+
const show = dirty || state === 'saving' || state === 'saved' || state === 'error';
|
|
386
|
+
if (!show)
|
|
387
|
+
return null;
|
|
388
|
+
const saving = state === 'saving';
|
|
389
|
+
const label = state === 'saving'
|
|
390
|
+
? 'Saving…'
|
|
391
|
+
: state === 'saved'
|
|
392
|
+
? 'Changes saved'
|
|
393
|
+
: state === 'error'
|
|
394
|
+
? "Couldn't save. Check your connection and try again."
|
|
395
|
+
: invalid > 0
|
|
396
|
+
? `Fix ${invalid} ${invalid === 1 ? 'error' : 'errors'} to save`
|
|
397
|
+
: `${count} unsaved ${count === 1 ? 'change' : 'changes'}`;
|
|
398
|
+
const tone = state === 'saved'
|
|
399
|
+
? 'bg-suc text-white'
|
|
400
|
+
: state === 'error'
|
|
401
|
+
? 'bg-err text-white'
|
|
402
|
+
: 'bg-txt text-bg';
|
|
403
|
+
return (_jsxs("div", { role: state === 'error' ? 'alert' : 'region', "aria-label": "Unsaved changes", "aria-live": "polite", className: `rounded-12 sticky bottom-4 z-[var(--z-bar)] ml-auto flex w-[min(560px,calc(100%-56px))] items-center gap-2.5 py-2.5 pr-2.5 pl-4 text-[13px] font-[550] shadow-[0_10px_30px_rgba(0,0,0,0.22)] ${tone}`, children: [_jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2", children: [state === 'saved' ? _jsx(Check, { size: 16, "aria-hidden": true }) : null, invalid > 0 && state === 'idle' ? _jsx(AlertCircle, { size: 15, "aria-hidden": true }) : null, label] }), state === 'saved' ? null : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: onDiscard, disabled: saving, className: "h-8 rounded-[8px] border border-transparent bg-transparent px-3 disabled:opacity-50", children: "Discard" }), _jsx("button", { type: "button", onClick: onSave, disabled: saving || invalid > 0, className: `h-8 rounded-[8px] px-3 font-semibold disabled:opacity-50 ${state === 'error' ? 'text-err bg-white' : 'bg-acc text-acc-on'}`, children: state === 'error' ? 'Try again' : 'Save changes' })] }))] }));
|
|
404
|
+
}
|
|
405
|
+
function AttributionTab({ draft, setDraft, banner, errors, onOpenPrivacy, }) {
|
|
406
|
+
const off = !draft.attribution.record;
|
|
407
|
+
const firstError = off ? undefined : errors['attribution.firstTouchDays'];
|
|
408
|
+
const lastError = off ? undefined : errors['attribution.lastTouchHours'];
|
|
409
|
+
const clickFields = TOP_TIER_CLICK_IDS.map((key) => [key, CLICK_COPY[key] ?? key]);
|
|
410
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Card, { title: "Capture", description: "Record where each visitor came from and attach it to their submission. Works on every form automatically.", children: [_jsx(AttributionStatus, { record: draft.attribution.record, requireConsent: draft.attribution.requireConsent, banner: banner, onOpenPrivacy: onOpenPrivacy }), _jsx(Row, { label: "Record attribution", help: "Saves campaign, visit, and ad click details with every submission.", children: _jsx(Toggle, { checked: draft.attribution.record, onCheckedChange: (record) => setDraft({ ...draft, attribution: { ...draft.attribution, record } }), "aria-label": "Record attribution" }) }), _jsx(Row, { label: "Require consent", help: "Wait until the visitor accepts analytics cookies before recording anything.", children: _jsx(Toggle, { checked: draft.attribution.requireConsent, disabled: off, onCheckedChange: (requireConsent) => setDraft({ ...draft, attribution: { ...draft.attribution, requireConsent } }), "aria-label": "Require consent" }) })] }), _jsxs(Card, { title: "Memory", description: "How long a visit is remembered on the visitor's device before it stops counting.", children: [_jsx(WindowRow, { id: "at-first", label: "First touch", help: "What originally brought them here. Kept until it expires, even if they come back another way.", unit: "days", range: "1\u2013365", value: draft.attribution.firstTouchDays, disabled: off, error: firstError, onChange: (firstTouchDays) => setDraft({ ...draft, attribution: { ...draft.attribution, firstTouchDays } }) }), _jsx(WindowRow, { id: "at-last", label: "Last touch", help: "What brought them back for the visit that converted. Must be shorter than first touch.", unit: "hours", range: "1\u2013168", value: draft.attribution.lastTouchHours, disabled: off, error: lastError, onChange: (lastTouchHours) => setDraft({ ...draft, attribution: { ...draft.attribution, lastTouchHours } }) }), off ? (_jsx("p", { className: "text-faint m-0 px-5 pt-1 pb-3.5 text-[12px]", children: "Turn on Record attribution to change these." })) : null] }), _jsxs(Card, { title: "Fields on every submission", description: "Read only. These are the names used in entry details, exports, notification emails, and webhooks.", children: [_jsxs("div", { className: "flex flex-col gap-3.5 px-5 pt-1.5 pb-4", children: [_jsx(FieldGroup, { title: "Campaign", subtitle: "From UTM tags, or worked out from the referrer", fields: CAMPAIGN_FIELDS }), _jsx(FieldGroup, { title: "Visit", subtitle: "The visit that led to the submission", fields: VISIT_FIELDS }), _jsx(FieldGroup, { title: "Ad click IDs", subtitle: "Empty when the visitor didn't click an ad", fields: clickFields }), _jsxs("p", { className: "text-sub m-0 text-[12px] leading-[1.6]", children: ["Other ad networks are kept under ", _jsx("code", { className: "font-mono", children: "extraIds" }), ":", ' ', EXTRA_IDS.map((key) => (_jsx("code", { className: "border-bdr bg-bg mx-0.5 rounded-[5px] border px-1 font-mono text-[11.5px] whitespace-nowrap", children: key }, key)))] })] }), _jsxs("div", { className: "border-bdr text-sub flex flex-wrap items-center gap-1.5 border-t px-5 py-3 text-[12px]", children: [_jsx("span", { children: "Appears in" }), ['Entry details', 'CSV & Excel export', 'Notification email', 'Webhook payload'].map((label) => (_jsx("span", { className: "border-bdr bg-bg text-txt rounded-full border px-2 py-px text-[11.5px] font-semibold whitespace-nowrap", children: label }, label)))] })] })] }));
|
|
411
|
+
}
|
|
412
|
+
function AttributionStatus({ record, requireConsent, banner, onOpenPrivacy, }) {
|
|
413
|
+
if (!record) {
|
|
414
|
+
return (_jsxs("p", { className: "border-bdr bg-bg text-sub mx-5 mt-3.5 rounded-[10px] border px-3.5 py-3 text-[12.5px]", role: "status", children: [_jsx("b", { className: "text-txt mb-0.5 block text-[13px]", children: "Off" }), "New submissions save without campaign or visit details. Existing entries keep theirs."] }));
|
|
415
|
+
}
|
|
416
|
+
if (requireConsent && !banner) {
|
|
417
|
+
return (_jsxs("p", { className: "border-warn bg-warn-l text-txt mx-5 mt-3.5 rounded-[10px] border px-3.5 py-3 text-[12.5px]", role: "status", children: [_jsx("b", { className: "mb-0.5 block text-[13px]", children: "New visits aren't being recorded" }), "Require consent is on, but this site has no consent banner, so no visitor can say yes.", ' ', _jsx("button", { type: "button", className: "font-semibold underline", onClick: onOpenPrivacy, children: "Add a consent banner" }), ' ', "or turn off Require consent."] }));
|
|
418
|
+
}
|
|
419
|
+
if (requireConsent) {
|
|
420
|
+
return (_jsxs("p", { className: "border-info bg-info-l text-txt mx-5 mt-3.5 rounded-[10px] border px-3.5 py-3 text-[12.5px]", role: "status", children: [_jsx("b", { className: "mb-0.5 block text-[13px]", children: "Recording after consent" }), "Visits are saved once the visitor accepts analytics cookies in your consent banner."] }));
|
|
421
|
+
}
|
|
422
|
+
return (_jsxs("p", { className: "border-suc bg-suc-l text-txt mx-5 mt-3.5 rounded-[10px] border px-3.5 py-3 text-[12.5px]", role: "status", children: [_jsx("b", { className: "mb-0.5 block text-[13px]", children: "Recording" }), "Every form saves where the visitor came from with each submission."] }));
|
|
423
|
+
}
|
|
424
|
+
function WindowRow({ id, label, help, unit, range, value, disabled, error, onChange, }) {
|
|
425
|
+
return (_jsxs(Row, { label: label, help: help, children: [_jsx("input", { id: id, "aria-label": label, inputMode: "numeric", disabled: disabled, value: value, "aria-invalid": error ? true : undefined, "aria-describedby": error ? `${id}-e` : `${id}-r`, onChange: (event) => onChange(Number(event.target.value.replace(/\D/g, '') || 0)), className: "border-bdr bg-card h-9 w-[84px] rounded-[8px] border px-2.5 text-right text-[13px] tabular-nums disabled:opacity-55" }), _jsx("span", { className: "text-sub text-[12.5px]", children: unit }), _jsx("span", { id: `${id}-r`, className: "text-faint text-[11.5px] whitespace-nowrap", children: range }), error ? (_jsxs("span", { id: `${id}-e`, role: "alert", className: "text-err flex basis-full items-center justify-end gap-1 text-right text-[12px] font-medium", children: [_jsx(AlertCircle, { size: 13, "aria-hidden": true }), error] })) : null] }));
|
|
426
|
+
}
|
|
427
|
+
function FieldGroup({ title, subtitle, fields, }) {
|
|
428
|
+
return (_jsxs("div", { children: [_jsxs("div", { className: "text-faint mb-2 flex items-baseline gap-2 text-[11px] font-bold tracking-[0.5px] uppercase", children: [title, _jsx("small", { className: "text-[11.5px] font-medium tracking-normal normal-case", children: subtitle })] }), _jsx("div", { className: "grid grid-cols-2 gap-1.5 min-[760px]:grid-cols-3", children: fields.map(([key, description]) => (_jsxs("div", { title: description, className: "border-bdr bg-bg min-w-0 rounded-[8px] border px-2.5 py-[7px]", children: [_jsx("code", { className: "text-txt block truncate font-mono text-[12px] font-medium", children: key }), _jsx("span", { className: "text-sub block truncate text-[11.5px]", children: description })] }, key))) })] }));
|
|
429
|
+
}
|
|
430
|
+
const CAPTCHA_PROVIDER_LABELS = {
|
|
431
|
+
recaptcha: 'Google reCAPTCHA v3',
|
|
432
|
+
turnstile: 'Cloudflare Turnstile',
|
|
433
|
+
none: 'Google reCAPTCHA v3',
|
|
434
|
+
};
|
|
435
|
+
function captchaHelp(settings) {
|
|
436
|
+
if (settings?.source === 'env') {
|
|
437
|
+
return `${CAPTCHA_PROVIDER_LABELS[settings.provider]}, set by environment variables.`;
|
|
438
|
+
}
|
|
439
|
+
return 'Google reCAPTCHA v3. Invisible to visitors: each submission gets a score.';
|
|
440
|
+
}
|
|
441
|
+
const keyInputClass = 'border-bdr bg-card text-txt h-9 w-full max-w-[340px] rounded-[8px] border px-2.5 font-mono text-[12.5px] disabled:opacity-55';
|
|
442
|
+
/**
|
|
443
|
+
* The reCAPTCHA v3 keys. Saved on their own, not with the page's save bar,
|
|
444
|
+
* because the secret is write-only and never part of the settings document.
|
|
445
|
+
*/
|
|
446
|
+
function RecaptchaKeys({ settings, readOnly, onSaved, }) {
|
|
447
|
+
const [siteKey, setSiteKey] = useState(settings.siteKey);
|
|
448
|
+
const [secretKey, setSecretKey] = useState('');
|
|
449
|
+
const [threshold, setThreshold] = useState(String(settings.scoreThreshold));
|
|
450
|
+
const [errors, setErrors] = useState({});
|
|
451
|
+
const [busy, setBusy] = useState(null);
|
|
452
|
+
useEffect(() => {
|
|
453
|
+
setSiteKey(settings.siteKey);
|
|
454
|
+
setThreshold(String(settings.scoreThreshold));
|
|
455
|
+
}, [settings.siteKey, settings.scoreThreshold]);
|
|
456
|
+
if (settings.envOverride) {
|
|
457
|
+
return (_jsx(Row, { label: "reCAPTCHA keys", help: "RECAPTCHA_* or TURNSTILE_* environment variables are set, so keys entered here aren't used. Remove those variables to manage keys here.", children: _jsx("span", { className: "text-sub text-[12.5px]", children: "Managed by your deployment" }) }));
|
|
458
|
+
}
|
|
459
|
+
const dirty = siteKey.trim() !== settings.siteKey ||
|
|
460
|
+
secretKey.trim() !== '' ||
|
|
461
|
+
Number(threshold) !== settings.scoreThreshold;
|
|
462
|
+
async function save(clear = false) {
|
|
463
|
+
setBusy(clear ? 'remove' : 'save');
|
|
464
|
+
setErrors({});
|
|
465
|
+
const res = await saveFormCaptchaSettings(clear
|
|
466
|
+
? { clear: true }
|
|
467
|
+
: {
|
|
468
|
+
siteKey: siteKey.trim(),
|
|
469
|
+
...(secretKey.trim() ? { secretKey: secretKey.trim() } : {}),
|
|
470
|
+
scoreThreshold: Number(threshold),
|
|
471
|
+
});
|
|
472
|
+
setBusy(null);
|
|
473
|
+
if (res.data) {
|
|
474
|
+
setSecretKey('');
|
|
475
|
+
onSaved(res.data);
|
|
476
|
+
toast.success(clear ? 'reCAPTCHA keys removed' : 'reCAPTCHA keys saved');
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (res.fields)
|
|
480
|
+
setErrors(res.fields);
|
|
481
|
+
else
|
|
482
|
+
toast.error(res.error ?? 'Could not save the reCAPTCHA keys');
|
|
483
|
+
}
|
|
484
|
+
async function toggleLogin(enabled) {
|
|
485
|
+
setBusy('login');
|
|
486
|
+
let token;
|
|
487
|
+
if (enabled) {
|
|
488
|
+
try {
|
|
489
|
+
token = await getRecaptchaV3Token(settings.siteKey, 'login');
|
|
490
|
+
}
|
|
491
|
+
catch {
|
|
492
|
+
setBusy(null);
|
|
493
|
+
toast.error("reCAPTCHA didn't load with this site key. Check that this domain is added in the reCAPTCHA admin console.");
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
const res = await setLoginCaptcha({ enabled, token });
|
|
498
|
+
setBusy(null);
|
|
499
|
+
if (res.data) {
|
|
500
|
+
onSaved(res.data);
|
|
501
|
+
toast.success(enabled ? 'Admin login protected' : 'Admin login protection off');
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
toast.error(res.error ?? 'Could not change login protection');
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const hasKeys = settings.source === 'admin' && settings.hasSecret;
|
|
508
|
+
const loginLocked = readOnly || settings.loginDisabledByEnv || !hasKeys || dirty;
|
|
509
|
+
const loginHelp = settings.loginDisabledByEnv
|
|
510
|
+
? 'CAPTCHA_LOGIN=off is set, so sign-ins aren’t checked.'
|
|
511
|
+
: !hasKeys
|
|
512
|
+
? 'Save keys first. Sign-ins are then checked with the same keys.'
|
|
513
|
+
: dirty
|
|
514
|
+
? 'Save your key changes first.'
|
|
515
|
+
: 'Checks sign-ins with these keys. Turning it on runs a test on this domain first.';
|
|
516
|
+
const fieldError = (key) => errors[key] ? (_jsxs("span", { id: `recaptcha-${key}-e`, role: "alert", className: "text-err flex basis-full items-center justify-end gap-1 text-right text-[12px] font-medium", children: [_jsx(AlertCircle, { size: 13, "aria-hidden": true }), errors[key]] })) : null;
|
|
517
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Row, { label: "reCAPTCHA site key", help: "From the reCAPTCHA admin console. Choose reCAPTCHA v3 and add your site's domains.", children: [_jsx("input", { "aria-label": "reCAPTCHA site key", value: siteKey, disabled: readOnly, autoComplete: "off", spellCheck: false, "aria-invalid": errors.siteKey ? true : undefined, "aria-describedby": errors.siteKey ? 'recaptcha-siteKey-e' : undefined, onChange: (event) => setSiteKey(event.target.value), className: keyInputClass }), fieldError('siteKey')] }), _jsxs(Row, { label: "reCAPTCHA secret key", help: settings.hasSecret
|
|
518
|
+
? 'Saved and encrypted. Leave blank to keep it.'
|
|
519
|
+
: 'Stored encrypted. It never leaves the server.', children: [_jsx("input", { "aria-label": "reCAPTCHA secret key", type: "password", value: secretKey, disabled: readOnly, autoComplete: "new-password", spellCheck: false, placeholder: settings.secretLast4 ? `•••• ${settings.secretLast4}` : '', "aria-invalid": errors.secretKey ? true : undefined, "aria-describedby": errors.secretKey ? 'recaptcha-secretKey-e' : undefined, onChange: (event) => setSecretKey(event.target.value), className: keyInputClass }), fieldError('secretKey')] }), _jsxs(Row, { label: "Score threshold", help: "Submissions scoring below this are rejected. 0 is likely a bot, 1 likely a person; Google suggests 0.5.", children: [_jsx("input", { "aria-label": "Score threshold", type: "number", min: 0, max: 1, step: 0.1, value: threshold, disabled: readOnly, "aria-invalid": errors.scoreThreshold ? true : undefined, "aria-describedby": errors.scoreThreshold ? 'recaptcha-scoreThreshold-e' : undefined, onChange: (event) => setThreshold(event.target.value), className: "border-bdr bg-card h-9 w-[84px] rounded-[8px] border px-2.5 text-right text-[13px] tabular-nums disabled:opacity-55" }), fieldError('scoreThreshold')] }), readOnly ? null : (_jsxs("div", { className: "border-bdr flex flex-wrap justify-end gap-2 border-b px-5 py-3", children: [settings.source === 'admin' ? (_jsx(Button, { type: "button", variant: "danger", size: "sm", loading: busy === 'remove', disabled: busy !== null, onClick: () => void save(true), children: "Remove keys" })) : null, _jsx(Button, { type: "button", size: "sm", loading: busy === 'save', disabled: busy !== null || !dirty, onClick: () => void save(), children: "Save keys" })] })), _jsx(Row, { label: "Protect the admin login", help: loginHelp, children: _jsx(Toggle, { checked: settings.protectLogin, disabled: loginLocked || busy !== null, onCheckedChange: (enabled) => void toggleLogin(enabled), "aria-label": "Protect the admin login" }) })] }));
|
|
520
|
+
}
|
|
521
|
+
function Card({ title, description, children, }) {
|
|
522
|
+
const id = title.replace(/\s+/g, '-').toLowerCase();
|
|
523
|
+
return (_jsxs("section", { "aria-labelledby": id, className: "border-bdr bg-card shadow-shd overflow-hidden rounded-[12px] border", children: [_jsxs("header", { className: "border-bdr border-b px-5 py-4", children: [_jsx("h2", { id: id, className: "text-txt m-0 text-[15px] font-semibold", children: title }), _jsx("p", { className: "text-sub m-0 mt-1 text-[12.5px]", children: description })] }), children] }));
|
|
524
|
+
}
|
|
525
|
+
function Row({ label, help, children }) {
|
|
526
|
+
return (_jsxs("div", { className: "border-bdr grid items-center gap-5 border-b px-5 py-[15px] last:border-b-0 md:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)]", children: [_jsxs("div", { children: [_jsx("div", { className: "text-txt text-[13px] font-semibold", children: label }), help ? _jsx("p", { className: "text-sub m-0 mt-1 text-[12px] leading-[1.45]", children: help }) : null] }), _jsx("div", { className: "flex flex-wrap items-center justify-end gap-2", children: children })] }));
|
|
527
|
+
}
|
|
528
|
+
function RadioCard({ name, checked, title, help, onChange, }) {
|
|
529
|
+
return (_jsxs("label", { className: `block cursor-pointer rounded-[9px] border px-3 py-2.5 ${checked ? 'border-acc bg-acc-l' : 'border-bdr'}`, children: [_jsx("input", { type: "radio", name: name, checked: checked, onChange: onChange, className: "sr-only" }), _jsx("span", { className: "text-txt block text-[13px] font-semibold", children: title }), _jsx("span", { className: "text-sub block text-[12px]", children: help })] }));
|
|
530
|
+
}
|
|
531
|
+
function DaySelect({ ariaLabel, value, options, onChange, }) {
|
|
532
|
+
return (_jsx("select", { "aria-label": ariaLabel, value: value == null ? 'null' : String(value), onChange: (event) => onChange(event.target.value === 'null' ? null : Number(event.target.value)), className: "border-bdr bg-card text-txt h-9 rounded-[8px] border px-2.5 text-[13px]", children: options.map(([option, label]) => (_jsx("option", { value: option == null ? 'null' : String(option), children: label }, label))) }));
|
|
36
533
|
}
|
|
37
534
|
//# sourceMappingURL=FormsSettings.js.map
|