Build AgentMinder Campaign Command Center - Phase 1 complete
Full-featured sales campaign dashboard replacing Looker Studio with responsive Next.js app. Includes Executive Overview, Account Explorer with priority algorithm, Activities with detail overlay, Pipeline/Opps with deal panels, Implementation tracking, and Data Admin with CSV import and CRUD operations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
54
src/app/api/admin/route.ts
Normal file
54
src/app/api/admin/route.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import {
|
||||
upsertAccount, deleteAccount,
|
||||
upsertPipeline, deletePipeline,
|
||||
addActivity, deleteActivity,
|
||||
upsertTarget, deleteTarget,
|
||||
getDbStats, getDashboardData,
|
||||
} from '@/lib/db';
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json({ stats: getDbStats() });
|
||||
}
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
const { action, table, record } = await req.json();
|
||||
|
||||
if (action === 'delete') {
|
||||
switch (table) {
|
||||
case 'accounts': deleteAccount(record.Account_Name); break;
|
||||
case 'pipeline': deletePipeline(record.Opportunity_ID); break;
|
||||
case 'activities': deleteActivity(record.id); break;
|
||||
case 'targets': deleteTarget(record.Account_Name); break;
|
||||
}
|
||||
return NextResponse.json({ success: true, stats: getDbStats() });
|
||||
}
|
||||
|
||||
if (action === 'upsert') {
|
||||
switch (table) {
|
||||
case 'accounts': upsertAccount(record); break;
|
||||
case 'pipeline': upsertPipeline(record); break;
|
||||
case 'activities': addActivity(record); break;
|
||||
case 'targets': upsertTarget(record); break;
|
||||
}
|
||||
return NextResponse.json({ success: true, stats: getDbStats() });
|
||||
}
|
||||
|
||||
if (action === 'list') {
|
||||
const data = getDashboardData();
|
||||
const tableData = {
|
||||
accounts: data.accounts,
|
||||
pipeline: data.pipeline,
|
||||
activities: data.activities,
|
||||
targets: data.targets,
|
||||
}[table];
|
||||
return NextResponse.json({ data: tableData || [] });
|
||||
}
|
||||
|
||||
return NextResponse.json({ error: 'Unknown action' }, { status: 400 });
|
||||
} catch (error) {
|
||||
console.error('[Admin API]', error);
|
||||
return NextResponse.json({ error: String(error) }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user