BusyBee3333 4e6467ffb0 Add CRESync CRM application with Setup page
- Build complete Next.js CRM for commercial real estate
- Add authentication with JWT sessions and role-based access
- Add GoHighLevel API integration for contacts, conversations, opportunities
- Add AI-powered Control Center with tool calling
- Add Setup page with onboarding checklist (/setup)
- Add sidebar navigation with Setup menu item
- Fix type errors in onboarding API, GHL services, and control center tools
- Add Prisma schema with SQLite for local development
- Add UI components with clay morphism design system

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 17:30:55 -05:00

55 lines
1.5 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { z } from 'zod';
import { prisma } from '@/lib/db';
import { getSession } from '@/lib/auth';
export async function GET(request: NextRequest) {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const status = await prisma.setupStatus.findUnique({
where: { userId: session.user.id },
});
return NextResponse.json({ status: status || {
smsConfigured: false,
emailConfigured: false,
contactsImported: false,
campaignsSetup: false,
}});
}
const updateStatusSchema = z.object({
smsConfigured: z.boolean().optional(),
emailConfigured: z.boolean().optional(),
contactsImported: z.boolean().optional(),
campaignsSetup: z.boolean().optional(),
});
export async function PUT(request: NextRequest) {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
try {
const body = await request.json();
const validated = updateStatusSchema.parse(body);
const status = await prisma.setupStatus.upsert({
where: { userId: session.user.id },
update: validated,
create: {
userId: session.user.id,
...validated,
},
});
return NextResponse.json({ success: true, status });
} catch (error) {
return NextResponse.json({ error: 'Failed to update status' }, { status: 500 });
}
}