import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; interface StaffUser { id: string; userId: string | null; name: string; email: string; role: string; } interface ClientUser { id: string; name: string; email: string | null; petCount: number; } export function DevLoginSelector() { const navigate = useNavigate(); const [staff, setStaff] = useState([]); const [clients, setClients] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetch("/api/dev/users") .then((r) => r.json()) .then((data) => { setStaff(data.staff ?? []); setClients(data.clients ?? []); }) .finally(() => setLoading(false)); }, []); function selectUser(type: "staff" | "client", id: string, name: string) { localStorage.setItem("dev-user", JSON.stringify({ type, id, name })); navigate(type === "staff" ? "/admin" : "/"); } function skipLogin() { localStorage.removeItem("dev-user"); navigate("/admin"); } if (loading) { return (

Loading users...

); } return (

GroomBook

Dev Login Selector

Staff

{staff.map((s) => ( ))}

Clients

{clients.map((cl) => ( ))}
); } export function getDevUser(): { type: string; id: string; name: string } | null { try { const raw = localStorage.getItem("dev-user"); if (!raw) return null; return JSON.parse(raw); } catch { return null; } } export function clearDevUser() { localStorage.removeItem("dev-user"); } const containerStyle: React.CSSProperties = { minHeight: "100vh", display: "flex", alignItems: "center", justifyContent: "center", fontFamily: "system-ui, sans-serif", background: "#f0f2f5", padding: "1rem", }; const cardStyle: React.CSSProperties = { background: "#fff", borderRadius: 12, padding: "2rem", width: "100%", maxWidth: 420, boxShadow: "0 4px 12px rgba(0, 0, 0, 0.08)", }; const sectionStyle: React.CSSProperties = { fontSize: 11, fontWeight: 600, color: "#6b7280", textTransform: "uppercase", letterSpacing: "0.05em", margin: "0 0 0.5rem", }; const userButtonStyle: React.CSSProperties = { display: "block", width: "100%", padding: "0.75rem 1rem", border: "1px solid #e5e7eb", borderRadius: 8, background: "#fff", cursor: "pointer", textAlign: "left", transition: "border-color 0.15s, background 0.15s", }; const skipButtonStyle: React.CSSProperties = { padding: "0.5rem 1.25rem", border: "1px solid #d1d5db", borderRadius: 6, background: "transparent", cursor: "pointer", fontSize: 13, color: "#6b7280", };