Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat: add topic creation from topics dashboard (#522)
Bharadwajjjjj9579f373ca22
diff --git a/web/messages/en.json b/web/messages/en.jsonindex c3eb48b93..63f1f42b8 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -169,6 +169,11 @@"negative": "Negative"},"topics": {+ "addTopic": "Add Topic",+ "addTopicDescription": "Create a new topic for this brand.",+ "topicAlreadyExists": "This topic already exists",+ "topicAdded": "\"{name}\" added. Assign prompts to this topic to start tracking it.",+ "failedToAddTopic": "Failed to add topic","noBrandTitle": "No brand selected","noBrandBody": "Select a brand from the top switcher to view topic analytics.","title": "Topics",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/topics/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/topics/page.tsxindex 8aec0db2f..f8cc5955c 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/topics/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/topics/page.tsx@@ -8,6 +8,10 @@ import { useUserRole } from '@/hooks/use-user-role';import { getTopicsOverview, type TopicOverviewRow } from '@/lib/actions/topic';import { TopicSuggestionsCard } from './_suggestions-card';import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';+import { createTopic } from '@/lib/actions/topic';+import { toast } from 'sonner';+import { Input } from '@/components/ui/input';+import { Loader2, Plus } from 'lucide-react';import {Table,TableBody,@@ -16,6 +20,15 @@ import {TableHeader,TableRow,} from '@/components/ui/table';+import {+ Dialog,+ DialogClose,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@/components/ui/dialog';import { Skeleton } from '@/components/ui/skeleton';import { Badge } from '@/components/ui/badge';import { Button, buttonVariants } from '@/components/ui/button';@@ -152,6 +165,7 @@ function KpiCard({export default function TopicsPage() {const t = useTranslations('topics');+ const common = useTranslations('common');const activeBrandId = useBrandStore((s) => s.activeBrandId);const activeBrand = useBrandStore((s) => s.brands.find((brand) => brand.id === s.activeBrandId) ?? null,@@ -160,6 +174,9 @@ export default function TopicsPage() {const [topics, setTopics] = useState<TopicOverviewRow[]>([]);const [unassignedPromptCount, setUnassignedPromptCount] = useState(0);const [loading, setLoading] = useState(true);+ const [isAdding, setIsAdding] = useState(false);+ const [newName, setNewName] = useState('');+ const [open, setOpen] = useState(false);const loadData = useCallback(async () => {if (!activeBrandId) {@@ -262,6 +279,28 @@ export default function TopicsPage() {);}+ const handleAddTopic = async () => {+ if (isAdding) return;+ const name = newName.trim();+ if (!name) return;+ if (topics.some((t) => t.name.toLowerCase() === name.toLowerCase())) {+ toast.error(t('topicAlreadyExists'));+ return;+ }+ setIsAdding(true);+ try {+ const added = await createTopic(activeBrandId, name);+ await loadData();+ setNewName('');+ setOpen(false);+ toast.success(t('topicAdded', { name: added.name }));+ } catch (err) {+ toast.error(err instanceof Error ? err.message : t('failedToAddTopic'));+ } finally {+ setIsAdding(false);+ }+ };+return (<div className="space-y-6">{/* Header */}@@ -291,6 +330,57 @@ export default function TopicsPage() {<Settings2 className="h-4 w-4" />{t('manageTopics')}</Link>+ {canManage && (+ <>+ <Button size="sm" onClick={() => setOpen(true)}>+ <Plus className="mr-2 h-4 w-4" />+ {t('addTopic')}+ </Button>+ <Dialog+ open={open}+ onOpenChange={(value) => {+ setOpen(value);+ if (!value) {+ setNewName('');+ }+ }}+ >+ <DialogContent className="sm:max-w-sm">+ <DialogHeader>+ <DialogTitle>{t('addTopic')}</DialogTitle>+ <DialogDescription>{t('addTopicDescription')}</DialogDescription>+ </DialogHeader>+ <div className="flex gap-2">+ <Input+ placeholder="e.g. Industry, Comparison..."+ value={newName}+ onChange={(e) => setNewName(e.target.value)}+ onKeyDown={(e) => e.key === 'Enter' && newName.trim() && handleAddTopic()}+ className="flex-1"+ />+ </div>+ <DialogFooter>+ <DialogClose render={<Button variant="outline" />}>+ {common('cancel')}+ </DialogClose>+ <Button+ variant="default"+ onClick={handleAddTopic}+ disabled={isAdding || !newName.trim()}+ className="gap-1.5 shrink-0"+ >+ {isAdding ? (+ <Loader2 className="h-4 w-4 animate-spin" />+ ) : (+ <Plus className="h-4 w-4" />+ )}+ {t('addTopic')}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ </>+ )}</div></div>@@ -369,6 +459,12 @@ export default function TopicsPage() {<Tag className="mx-auto h-9 w-9 text-muted-foreground/40" /><p className="mt-2">{t('emptyTitle')}</p><p className="text-xs">{t('emptyBody')}</p>+ {canManage && (+ <Button className="mt-4" onClick={() => setOpen(true)}>+ <Plus className="mr-2 h-4 w-4" />+ {t('addTopic')}+ </Button>+ )}</div>) : (<Table>