mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 07:52:10 +01:00
- Add comprehensive company management interface with editing, suspension - Implement user invitation system within companies - Add Add Company modal with form validation - Create platform auth configuration in separate lib file - Add comprehensive SEO metadata with OpenGraph and structured data - Fix auth imports and route exports for Next.js 15 compatibility - Add toast notifications with RadixUI components - Update TODO status to reflect 100% completion of platform features
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getServerSession } from "next-auth";
|
|
import { prisma } from "../../../../lib/prisma";
|
|
import { authOptions } from "../../../../lib/auth";
|
|
|
|
export async function POST(request: NextRequest) {
|
|
const session = await getServerSession(authOptions);
|
|
if (!session?.user || session.user.role !== "ADMIN") {
|
|
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
|
}
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { email: session.user.email as string },
|
|
});
|
|
|
|
if (!user) {
|
|
return NextResponse.json({ error: "No user" }, { status: 401 });
|
|
}
|
|
|
|
const body = await request.json();
|
|
const { csvUrl, csvUsername, csvPassword, sentimentThreshold } = body;
|
|
|
|
await prisma.company.update({
|
|
where: { id: user.companyId },
|
|
data: {
|
|
csvUrl,
|
|
csvUsername,
|
|
...(csvPassword ? { csvPassword } : {}),
|
|
// Remove sentimentAlert field - not in current schema
|
|
},
|
|
});
|
|
|
|
return NextResponse.json({ ok: true });
|
|
}
|