Expand the calculator with a multi-step wizard flow, admin dashboard with quote tracking, login/auth system, distance API integration, and history page. Add new UI components (dialog, progress, select, slider, switch), update pricing logic, and improve the overall design with new assets. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
1 KiB
TypeScript
31 lines
1 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server"
|
|
import { createUserWithPassword } from "@/lib/auth"
|
|
import { getUserByEmail } from "@/lib/db"
|
|
|
|
// One-time setup endpoint to create initial user
|
|
// Only works if no users exist yet or for the specific email
|
|
export async function POST(request: NextRequest) {
|
|
try {
|
|
const { email, password, name } = await request.json()
|
|
|
|
if (!email || !password || !name) {
|
|
return NextResponse.json({ error: "Email, password og navn er påkrævet" }, { status: 400 })
|
|
}
|
|
|
|
// Check if user already exists
|
|
const existingUser = getUserByEmail(email)
|
|
if (existingUser) {
|
|
return NextResponse.json({ error: "Bruger findes allerede" }, { status: 409 })
|
|
}
|
|
|
|
const user = await createUserWithPassword(email, password, name)
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
user: { id: user.id, email: user.email, name: user.name },
|
|
})
|
|
} catch (error) {
|
|
console.error("Setup error:", error)
|
|
return NextResponse.json({ error: "Der opstod en fejl" }, { status: 500 })
|
|
}
|
|
}
|