From 14f3fe7fbbc4551a92b70487716f55b1d1fc7466 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Wed, 4 Feb 2026 15:56:25 +0100 Subject: [PATCH] feat: add duplicate event name validation in SiteSettingsPage and update user guidance for event name changes --- app/sites/[id]/settings/page.tsx | 10 ++++++++++ public/script.js | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/sites/[id]/settings/page.tsx b/app/sites/[id]/settings/page.tsx index 18cbc01..5367ffe 100644 --- a/app/sites/[id]/settings/page.tsx +++ b/app/sites/[id]/settings/page.tsx @@ -164,6 +164,13 @@ export default function SiteSettingsPage() { toast.error('Event name can only contain letters, numbers, and underscores') return } + const duplicateEventName = editingGoal + ? goals.some((g) => g.id !== editingGoal.id && g.event_name === eventName) + : goals.some((g) => g.event_name === eventName) + if (duplicateEventName) { + toast.error('A goal with this event name already exists') + return + } setGoalSaving(true) try { if (editingGoal) { @@ -1002,6 +1009,9 @@ export default function SiteSettingsPage() { required />

Spaces become underscores; max 64 characters after formatting.

+ {editingGoal && goalForm.event_name.trim().toLowerCase().replace(/\s+/g, '_') !== editingGoal.event_name && ( +

Changing event name does not reassign events already tracked under the previous name.

+ )}