mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-02-13 16:15:43 +01:00
- Fix syntax errors in skills markdown files (.github/skills, .opencode/skills) - Change typescript to tsx for code blocks with JSX - Replace ellipsis (...) in array examples with valid syntax - Separate CSS from TypeScript into distinct code blocks - Convert JavaScript object examples to valid JSON in docs - Fix enum definitions with proper comma separation
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import { type NextRequest, NextResponse } from "next/server";
|
|
import { neonAuth } from "@/lib/auth/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
// MIGRATED: Removed "export const dynamic = 'force-dynamic'" - dynamic by default with Cache Components
|
|
|
|
export async function GET(_request: NextRequest) {
|
|
const { session: authSession, user: authUser } = await neonAuth();
|
|
if (!authSession || !authUser?.email) {
|
|
return NextResponse.json({ error: "Not logged in" }, { status: 401 });
|
|
}
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { email: authUser.email },
|
|
});
|
|
|
|
if (!user || !user.companyId) {
|
|
return NextResponse.json({ error: "No user or company" }, { status: 401 });
|
|
}
|
|
|
|
// Get company data
|
|
const company = await prisma.company.findUnique({
|
|
where: { id: user.companyId },
|
|
});
|
|
|
|
return NextResponse.json({ company });
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
const { session: authSession, user: authUser } = await neonAuth();
|
|
if (!authSession || !authUser?.email) {
|
|
return NextResponse.json({ error: "Not logged in" }, { status: 401 });
|
|
}
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { email: authUser.email },
|
|
});
|
|
|
|
if (!user || !user.companyId) {
|
|
return NextResponse.json({ error: "No user or company" }, { status: 401 });
|
|
}
|
|
|
|
const body = await request.json();
|
|
const { csvUrl } = body;
|
|
|
|
await prisma.company.update({
|
|
where: { id: user.companyId },
|
|
data: { csvUrl },
|
|
});
|
|
|
|
return NextResponse.json({ ok: true });
|
|
}
|