{"path":"src/app/api/reviews/route.ts","size":844,"locked":false,"binary":false,"truncated":false,"content":"import { createClient } from \"@/lib/supabase/server\";\nimport { NextResponse } from \"next/server\";\n\nexport async function POST(request: Request) {\n  const supabase = await createClient();\n\n  if (!supabase) {\n    return NextResponse.json({ error: \"Database not connected\" }, { status: 503 });\n  }\n\n  const body = await request.json();\n  const { name, rating, comment, product_id } = body;\n\n  if (!name || !rating || !comment) {\n    return NextResponse.json({ error: \"Missing required fields\" }, { status: 400 });\n  }\n\n  const { error } = await supabase.from(\"reviews\").insert({\n    user_id: null,\n    rating,\n    comment,\n    author: name,\n    approved: false,\n    product_id: product_id || null,\n  });\n\n  if (error) {\n    return NextResponse.json({ error: error.message }, { status: 500 });\n  }\n\n  return NextResponse.json({ success: true });\n}\n"}