mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 20:32:09 +01:00
- Add eslint-plugin-react-hooks dependency to fix ESLint errors - Fix unused sentimentThreshold variable in settings route - Add comprehensive dark mode accessibility tests as requested - Implement custom error classes for better error handling - Create centralized error handling system with proper typing - Add dark mode contrast and focus indicator tests - Extend accessibility test coverage for theme switching
35 lines
1012 B
TypeScript
35 lines
1012 B
TypeScript
import { type NextRequest, NextResponse } from "next/server";
|
|
import { getServerSession } from "next-auth";
|
|
import { authOptions } from "../../../../lib/auth";
|
|
import { prisma } from "../../../../lib/prisma";
|
|
|
|
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 } = 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 });
|
|
}
|