"use client"; import { useState } from "react"; const LoginForm = () => { const [handle, setHandle] = useState(""); const [isLoading, setIsLoading] = useState(false); const handleSubmit = async (event: Event) => { event.preventDefault(); setIsLoading(true); try { const response = await fetch("/oauth/login", { body: JSON.stringify({ handle }), headers: { "Content-Type": "application/json" }, method: "POST" }); const json = await response.json(); if(!response.ok){ throw new Error(json.error || "Login failed") } window.location.href = json.redirectURL; } catch (error) { } finally { setIsLoading(false); } }; return (
setHandle(event.currentTarget.value)} placeholder="alice.blacksky.app" type="text" value={handle} />
); }; export default LoginForm;