"use client"; import { useActionState } from "react"; import { Button } from "@/components/ui/button"; import { Field, inputClass } from "@/components/ui/field"; import { sendMagicLink, type LoginState } from "./actions"; const initialState: LoginState = { status: "idle", message: "" }; export function LoginForm({ initialError }: { initialError: string | null }) { const [state, formAction, pending] = useActionState(sendMagicLink, initialState); const error = state.status === "error" ? state.message : state.status === "idle" ? initialError : null; return (

{state.status === "sent" && {state.message}} {error && {error}}

); }