import { redirect } from "next/navigation";
import { isSetupComplete } from "@/lib/setup";
import { SetupForm } from "./client";

export default async function SetupPage() {
  if (await isSetupComplete()) redirect("/login");

  const currentDatabaseUrl = process.env.DATABASE_URL ?? "file:./dev.db";
  const currentBackupDir = process.env.BACKUP_DIR ?? "./backups";

  return (
    <div className="mx-auto max-w-lg space-y-6 py-6">
      <div>
        <h1 className="text-2xl font-semibold">Set up Horse Records</h1>
        <p className="mt-1 text-sm text-neutral-700 dark:text-neutral-300">
          This only runs once. Create the first admin account to get started - everything else can be changed later
          from the Account and Admin pages.
        </p>
      </div>
      <SetupForm currentDatabaseUrl={currentDatabaseUrl} currentBackupDir={currentBackupDir} />
    </div>
  );
}
