mirror of
https://github.com/Such-Software/wowcheckout.git
synced 2026-10-17 05:51:45 +02:00
- POST/GET/DELETE /api/admin/users endpoints - Admin UI at /admin with login, user list, create/delete - Auth via ADMIN_API_KEY env var (separate from tenant auth) - Tenants remain scoped to their own store only
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { useActionState } from "react";
|
|
import { adminLoginAction, type AdminLoginState } from "./actions";
|
|
|
|
const initialState: AdminLoginState = { error: null };
|
|
|
|
export function AdminLoginForm() {
|
|
const [state, formAction, pending] = useActionState(adminLoginAction, initialState);
|
|
|
|
return (
|
|
<form action={formAction} className="space-y-4">
|
|
<div>
|
|
<label htmlFor="admin_key" className="block text-sm font-medium mb-1">
|
|
Admin API Key
|
|
</label>
|
|
<input
|
|
type="password"
|
|
id="admin_key"
|
|
name="admin_key"
|
|
className="w-full rounded border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary"
|
|
required
|
|
autoFocus
|
|
/>
|
|
</div>
|
|
{state.error && (
|
|
<p className="text-sm text-red-500">{state.error}</p>
|
|
)}
|
|
<button
|
|
type="submit"
|
|
disabled={pending}
|
|
className="w-full rounded bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50"
|
|
>
|
|
{pending ? "Verifying…" : "Sign in"}
|
|
</button>
|
|
</form>
|
|
);
|
|
}
|