Skip to content

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.

feat(web): add CSV exports to action center (#931)

sajjadka21963cf3e96e68
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/action-center/actions/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/action-center/actions/page.tsx
index f13c6341e..cba256369 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/action-center/actions/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/action-center/actions/page.tsx
@@ -6,6 +6,7 @@ import {
AlertCircle,
ArrowUpDown,
CircleDot,
+ Download,
ListChecks,
Search,
Shield,
@@ -48,6 +49,20 @@ import {
} from '@/components/ui/select';
import { Skeleton } from '@/components/ui/skeleton';
import { cn } from '@/lib/utils';
+import { toCsv } from '@/lib/csv';
+
+const ACTION_EXPORT_HEADERS = [
+ 'number',
+ 'title',
+ 'category',
+ 'impact',
+ 'status',
+ 'assignee',
+ 'due_date',
+ 'tasks_done_total',
+ 'signal_count',
+ 'created',
+];
const OPEN_STATUSES: ActionStatus[] = ['new', 'in_progress', 'on_hold'];
@@ -97,6 +112,7 @@ export default function ActionCenterActionsPage() {
function ActionsContent({ brand }: { brand: Brand }) {
const t = useTranslations('actionCenter.actionsPage');
+ const common = useTranslations('common');
const tTexts = useTranslations('actionCenter.actionTexts');
const tCategories = useTranslations('actionCenter.actionCategories');
@@ -192,6 +208,36 @@ function ActionsContent({ brand }: { brand: Brand }) {
});
}, [actions, focus, category, impact, status, assignee, search, sort, tTexts, t]);
+ const handleExportCsv = useCallback(() => {
+ if (visible.length === 0) return;
+
+ const rows = visible.map((action) => ({
+ number: action.actionNo,
+ title: actionTexts(action, tTexts).title,
+ category: tCategories(action.category),
+ impact: t(`impact.${action.impact}`),
+ status: t(`status.${action.status}`),
+ assignee: action.assignee?.fullName ?? '',
+ due_date: action.dueDate ?? '',
+ tasks_done_total: `${action.taskCompleted} / ${action.taskTotal}`,
+ signal_count: action.signalCount,
+ created: action.createdAt,
+ }));
+
+ const csv = toCsv(rows, ACTION_EXPORT_HEADERS);
+ const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ const date = new Date().toISOString().slice(0, 10);
+ const slug = brand.slug ?? 'brand';
+
+ link.href = url;
+ link.download = `ansvisor_${slug}_actions_${date}.csv`;
+ link.click();
+
+ URL.revokeObjectURL(url);
+ }, [brand.slug, visible, tTexts, tCategories, t]);
+
const categoryCounts = useMemo(() => {
const counts = new Map<ActionCategory, number>();
for (const action of actions ?? []) {
@@ -403,6 +449,17 @@ function ActionsContent({ brand }: { brand: Brand }) {
{t('filters.clear')}
</Button>
)}
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="ml-auto gap-2 text-xs"
+ onClick={handleExportCsv}
+ disabled={visible.length === 0}
+ >
+ <Download className="h-3.5 w-3.5" />
+ {common('exportCsv')}
+ </Button>
</div>
{visible.length > 0 ? (
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/action-center/signals/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/action-center/signals/page.tsx
index 988e0fbde..07aae5c70 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/action-center/signals/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/action-center/signals/page.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
import dynamic from 'next/dynamic';
import { useTranslations } from 'next-intl';
import { toast } from 'sonner';
-import { AlertCircle, Radar, Search, TrendingDown, TrendingUp, X } from 'lucide-react';
+import { AlertCircle, Download, Radar, Search, TrendingDown, TrendingUp, X } from 'lucide-react';
import { useBrandStore } from '@/stores/use-brand-store';
import type { Brand } from '@/types';
import {
@@ -26,7 +26,7 @@ import {
} from '@/lib/signals/registry';
import { signalAffected, signalTexts } from '@/lib/signals/display';
import { ActionCenterTabs } from '@/components/action-center/action-center-tabs';
-import { SignalTable } from '@/components/action-center/signal-table';
+import { isSuperseded, SignalTable } from '@/components/action-center/signal-table';
import { SignalDrawer } from '@/components/action-center/signal-drawer';
import { Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
@@ -40,8 +40,19 @@ import {
} from '@/components/ui/select';
import { Skeleton } from '@/components/ui/skeleton';
import { cn } from '@/lib/utils';
+import { toCsv } from '@/lib/csv';
import type { KpiTrendPoint } from '@/lib/actions/kpis';
+const SIGNAL_EXPORT_HEADERS = [
+ 'title',
+ 'category',
+ 'impact',
+ 'status',
+ 'sources',
+ 'detected',
+ 'last_detected',
+];
+
const KpiSparkline = dynamic(() => import('@/components/action-center/kpi-sparkline'), {
ssr: false,
loading: () => <Skeleton className="h-8 w-[110px]" />,
@@ -81,6 +92,7 @@ export default function ActionCenterSignalsPage() {
function SignalsContent({ brand }: { brand: Brand }) {
const t = useTranslations('actionCenter.signalsPage');
+ const common = useTranslations('common');
const tTexts = useTranslations('actionCenter.signalTexts');
const tCategories = useTranslations('actionCenter.signalCategories');
@@ -168,6 +180,33 @@ function SignalsContent({ brand }: { brand: Brand }) {
});
}, [signals, category, impact, status, source, search, tTexts, t]);
+ const handleExportCsv = useCallback(() => {
+ if (visible.length === 0) return;
+
+ const rows = visible.map((signal) => ({
+ title: signalTexts(signal, tTexts).title,
+ category: tCategories(signal.category),
+ impact: t(`impact.${signal.impact}`),
+ status: isSuperseded(signal) ? t('superseded') : t(`status.${signal.status}`),
+ sources: signal.source.map((item) => t(`sources.${item}`)).join(', '),
+ detected: signal.detectedAt,
+ last_detected: signal.lastDetectedAt,
+ }));
+
+ const csv = toCsv(rows, SIGNAL_EXPORT_HEADERS);
+ const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ const date = new Date().toISOString().slice(0, 10);
+ const slug = brand.slug ?? 'brand';
+
+ link.href = url;
+ link.download = `ansvisor_${slug}_signals_${date}.csv`;
+ link.click();
+
+ URL.revokeObjectURL(url);
+ }, [brand.slug, visible, tTexts, tCategories, t]);
+
const categoryCounts = useMemo(() => {
const counts = new Map<SignalCategory, number>();
for (const signal of signals ?? []) {
@@ -387,6 +426,17 @@ function SignalsContent({ brand }: { brand: Brand }) {
{t('filters.clear')}
</Button>
)}
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="ml-auto gap-2 text-xs"
+ onClick={handleExportCsv}
+ disabled={visible.length === 0}
+ >
+ <Download className="h-3.5 w-3.5" />
+ {common('exportCsv')}
+ </Button>
</div>
{visible.length > 0 ? (