acupedia-web-ui/src/components/auth/AdminLoginForm.tsx

102 lines
4.1 KiB
TypeScript

import React from 'react';
import { Sparkles, AlertCircle, Shield, Eye, EyeOff } from 'lucide-react';
interface AdminLoginFormProps {
email: string;
password: string;
showPassword: boolean;
loading: boolean;
error: string | null;
loggedInUser: any;
isAdmin: boolean;
onEmailChange: (v: string) => void;
onPasswordChange: (v: string) => void;
onToggleShowPassword: () => void;
onSubmit: (e: React.FormEvent) => void;
}
export const AdminLoginForm: React.FC<AdminLoginFormProps> = ({
email,
password,
showPassword,
loading,
error,
loggedInUser,
isAdmin,
onEmailChange,
onPasswordChange,
onToggleShowPassword,
onSubmit,
}) => {
return (
<div className="min-h-screen bg-[#08080C] text-slate-100 flex items-center justify-center p-4 selection:bg-indigo-500 selection:text-white">
<div className="w-full max-w-md bg-slate-900/90 border border-slate-800 rounded-3xl p-8 shadow-2xl backdrop-blur-xl space-y-6">
<div className="text-center space-y-2">
<div className="h-12 w-12 rounded-2xl bg-gradient-to-tr from-indigo-500 to-cyan-400 flex items-center justify-center mx-auto shadow-lg shadow-indigo-500/20">
<Sparkles className="h-6 w-6 text-white" />
</div>
<h1 className="text-xl font-black tracking-tight text-white">ACUPEDIA BACKOFFICE</h1>
<p className="text-xs text-slate-400 font-semibold">Clinical Platform Administrative Suite</p>
</div>
{error && (
<div className="p-3 bg-rose-500/10 border border-rose-500/30 text-rose-400 text-xs rounded-xl font-bold flex items-center gap-2">
<AlertCircle className="h-4 w-4 shrink-0" />
<span>{error}</span>
</div>
)}
{loggedInUser && !isAdmin && (
<div className="p-3 bg-amber-500/10 border border-amber-500/30 text-amber-400 text-xs rounded-xl font-bold flex items-center gap-2">
<Shield className="h-4 w-4 shrink-0" />
<span>Account {loggedInUser.email} lacks administrative privileges.</span>
</div>
)}
<form onSubmit={onSubmit} className="space-y-4">
<div className="space-y-1">
<label className="text-[10px] uppercase font-black tracking-wider text-slate-400">Admin Email</label>
<input
type="email"
required
value={email}
onChange={(e) => onEmailChange(e.target.value)}
placeholder="admin@acupedia.in"
className="w-full px-4 py-3 rounded-xl bg-slate-800/80 border border-slate-700 text-white text-xs font-semibold focus:outline-none focus:border-indigo-500"
/>
</div>
<div className="space-y-1">
<label className="text-[10px] uppercase font-black tracking-wider text-slate-400">Password</label>
<div className="relative">
<input
type={showPassword ? 'text' : 'password'}
required
value={password}
onChange={(e) => onPasswordChange(e.target.value)}
placeholder="••••••••"
className="w-full px-4 py-3 rounded-xl bg-slate-800/80 border border-slate-700 text-white text-xs font-semibold focus:outline-none focus:border-indigo-500"
/>
<button
type="button"
onClick={onToggleShowPassword}
className="absolute right-3 top-3 text-slate-400 hover:text-white cursor-pointer"
>
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
</button>
</div>
</div>
<button
type="submit"
disabled={loading}
className="w-full py-3 bg-indigo-600 hover:bg-indigo-500 disabled:bg-slate-800 text-white text-xs font-black rounded-xl transition-all shadow-lg shadow-indigo-600/20 cursor-pointer disabled:opacity-50"
>
{loading ? 'Authenticating...' : 'Sign In to Console'}
</button>
</form>
</div>
</div>
);
};