From e122466c8d1ce98ac9445e4fcb2f72136555f19b Mon Sep 17 00:00:00 2001 From: notshop Date: Sun, 26 Apr 2026 16:36:06 +0000 Subject: [PATCH] chore: add client/src/pages/admin/login.tsx --- client/src/pages/admin/login.tsx | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 client/src/pages/admin/login.tsx diff --git a/client/src/pages/admin/login.tsx b/client/src/pages/admin/login.tsx new file mode 100644 index 0000000..b70cba7 --- /dev/null +++ b/client/src/pages/admin/login.tsx @@ -0,0 +1,63 @@ +import { useState } from "react"; +import { useLocation } from "wouter"; +import { queryClient, apiRequest } from "../../lib/queryClient"; +import { toast } from "../../hooks/use-toast"; +import { ShoppingBag } from "lucide-react"; + +export default function AdminLogin() { + const [, setLocation] = useLocation(); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [loading, setLoading] = useState(false); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setLoading(true); + try { + await apiRequest("POST", "/api/admin/login", { email, password }); + await queryClient.invalidateQueries({ queryKey: ["/api/admin/me"] }); + setLocation("/admin"); + } catch (err: any) { + toast({ title: "Sign in failed", description: err.message, variant: "destructive" }); + } finally { + setLoading(false); + } + }; + + return ( +
+
+
+ +

Admin Login

+

NoShop Store Management

+
+
+
+
+ + setEmail(e.target.value)} required + className="w-full px-3 py-2 border border-border rounded-md text-sm bg-background focus:outline-none focus:ring-2 focus:ring-primary/30" + data-testid="input-admin-email" + /> +
+
+ + setPassword(e.target.value)} required + className="w-full px-3 py-2 border border-border rounded-md text-sm bg-background focus:outline-none focus:ring-2 focus:ring-primary/30" + data-testid="input-admin-password" + /> +
+ +
+
+
+
+ ); +}