"use client"; import NextLink from "next/link"; import { useActionState } from "react"; import { Link } from "@unlocalhosted/metalui"; import { forgotPasswordAction, loginAction, resetPasswordAction, signupAction, twoFactorLoginAction } from "@/app/actions/auth"; import { TextField } from "./settings-fields"; import { Alert, Button } from "./ui"; /** With `canReset`, links to resetting a forgotten password (only when the server can send email). */ export function LoginForm({ next, canReset }: { next: string; canReset?: boolean }) { const [state, action, pending] = useActionState(loginAction, undefined); return (
{state?.error && {state.error}} }>Forgot your password?} name="password" type="password" required autoComplete="current-password" /> ); } export function TwoFactorLoginForm({ next }: { next: string }) { const [state, action, pending] = useActionState(twoFactorLoginAction, undefined); return (
{state?.error && {state.error}} ); } export function SignupForm({ next }: { next: string }) { const [state, action, pending] = useActionState(signupAction, undefined); return (
{state?.error && {state.error}}

Already have an account?{" "} }>Sign in

); } export function ForgotPasswordForm() { const [state, action, pending] = useActionState(forgotPasswordAction, undefined); if (state?.success) return {state.success}; return (
{state?.error && {state.error}} ); } export function ResetPasswordForm({ token, username }: { token: string; username: string }) { const [state, action, pending] = useActionState(resetPasswordAction, undefined); return (
{/* For password managers. */} {state?.error && {state.error}} ); }