"use client"; import { useState } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import { Terminal } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Alert, AlertDescription } from "@/components/ui/alert"; export function LoginForm() { const router = useRouter(); const searchParams = useSearchParams(); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [pending, setPending] = useState(false); async function handleSubmit(event: React.FormEvent) { event.preventDefault(); setPending(true); setError(null); const response = await fetch("/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password }), }); if (response.ok) { const next = searchParams.get("next") ?? "/"; router.push(next); router.refresh(); return; } const data = await response.json().catch(() => ({})); setError(data.error ?? "Login failed"); setPending(false); } return (
TriggerShell
Sign in to run and monitor your configured scripts.
{error && ( {error} )}
setUsername(event.target.value)} required />
setPassword(event.target.value)} required />
); }