import { useState } from "react"; import { useLocation, useSearch, Link } from "wouter"; import { useLocalLogin } from "@workspace/api-client-react"; import { useQueryClient } from "@tanstack/react-query"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { ThemeToggle } from "@/components/theme-toggle"; import { Wrench, AlertCircle } from "lucide-react"; export default function Login() { const [, setLocation] = useLocation(); const search = useSearch(); const params = new URLSearchParams(search); const returnTo = params.get("returnTo") || "/"; const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const queryClient = useQueryClient(); const localLogin = useLocalLogin(); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); setError(null); localLogin.mutate( { data: { username, password } }, { onSuccess: () => { queryClient.invalidateQueries(); setLocation(returnTo); }, onError: (err) => { setError(err.data?.error || err.message || "Invalid username or password"); }, }, ); }; return (
toolr

Sign in to your account

Sign in Enter your credentials to continue
setUsername(e.target.value)} placeholder="admin" autoFocus required />
setPassword(e.target.value)} required />
{error && (
{error}
)}
Back to Home
); }