import { redirect } from "next/navigation";

import { LoginForm1 } from "./components/login-form-1";
import { getCurrentUser } from "@/lib/appwrite/server";

export default async function Page({
  searchParams,
}: {
  searchParams: Promise<{ invite?: string; reset?: string }>;
}) {
  const { invite, reset } = await searchParams;
  const user = await getCurrentUser();
  if (user) redirect(invite ? `/d/${invite}` : "/dashboard");

  return <LoginForm1 inviteCode={invite} passwordReset={reset === "success"} />;
}
