"use server"

import { redirect } from "next/navigation"
import { eq } from "drizzle-orm"
import { db } from "@/lib/db"
import { profiles } from "@/lib/db/schema"
import { getSessionUser } from "@/lib/session"

/** Marks onboarding as finished and sends the user to the dashboard. */
export async function completeOnboarding() {
  const user = await getSessionUser()
  if (!user) redirect("/login")
  await db.update(profiles).set({ onboarding_completed: true }).where(eq(profiles.id, user.id))
  redirect("/dashboard")
}
