import { useState } from "react"; import { api } from "../api.js"; import { Button, ErrorNote, Field } from "../ui.jsx"; export default function Login({ onSignedIn, setupNeeded, agency, hasLogo }) { const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [confirm, setConfirm] = useState(""); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const [forgot, setForgot] = useState(false); const submit = async (e) => { e.preventDefault(); setError(null); if (setupNeeded && password !== confirm) return setError(new Error("The two passwords don't match.")); setBusy(true); try { if (setupNeeded) await api("/api/auth/setup", { method: "POST", body: { name, email, password, setupToken: new URLSearchParams(location.search).get("setup") || "" } }); else await api("/api/auth/login", { method: "POST", body: { email, password } }); onSignedIn(); } catch (err) { setError(err); setBusy(false); } }; return (
Plan, approve and publish to Instagram, Facebook, TikTok, YouTube, LinkedIn and more, with live numbers, AI-run audits and weekly plans, and reports your clients can read.