2026-06-01 21:44:29 +07:00
|
|
|
import { Lock } from "lucide-react";
|
2026-06-03 03:16:06 +07:00
|
|
|
import { useEffect, useState } from "react";
|
2026-06-01 16:42:36 +07:00
|
|
|
import { login } from "../../shared/api/client";
|
2026-06-03 03:16:06 +07:00
|
|
|
import { useGsapTransition } from "../../shared/hooks/useGsapTransition";
|
2026-06-01 21:44:29 +07:00
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardDescription,
|
|
|
|
|
CardHeader,
|
|
|
|
|
CardTitle,
|
|
|
|
|
Input,
|
2026-06-03 13:56:11 +07:00
|
|
|
MascotImage,
|
2026-06-01 21:44:29 +07:00
|
|
|
} from "../../shared/ui";
|
2026-05-17 00:20:29 +07:00
|
|
|
|
|
|
|
|
interface AuthOverlayProps {
|
|
|
|
|
onAuthenticated: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function AuthOverlay({ onAuthenticated }: AuthOverlayProps) {
|
|
|
|
|
const [password, setPassword] = useState("");
|
|
|
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
2026-06-03 03:16:06 +07:00
|
|
|
const { pageRef, animateIn } = useGsapTransition("auth");
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
animateIn();
|
|
|
|
|
}, [animateIn]);
|
2026-05-17 00:20:29 +07:00
|
|
|
|
2026-06-01 16:42:36 +07:00
|
|
|
const handleSubmit = async (e: { preventDefault: () => void }) => {
|
2026-05-17 00:20:29 +07:00
|
|
|
e.preventDefault();
|
|
|
|
|
setLoading(true);
|
|
|
|
|
setError(null);
|
|
|
|
|
try {
|
|
|
|
|
await login(password);
|
|
|
|
|
localStorage.setItem("admin-password", password);
|
|
|
|
|
onAuthenticated();
|
2026-06-01 16:42:36 +07:00
|
|
|
} catch {
|
2026-05-17 00:20:29 +07:00
|
|
|
setError("Invalid password");
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2026-06-03 03:16:06 +07:00
|
|
|
<div ref={pageRef} className="flex items-center justify-center p-4">
|
|
|
|
|
<Card className="w-full max-w-md border-primary/30 shadow-lg shadow-primary/10">
|
2026-05-17 00:20:29 +07:00
|
|
|
<CardHeader className="text-center">
|
2026-06-03 03:16:06 +07:00
|
|
|
<div className="mx-auto mb-4 flex items-center justify-center gap-3">
|
|
|
|
|
<div className="flex h-12 w-12 items-center justify-center rounded-full bg-primary/10 text-primary">
|
|
|
|
|
<Lock className="h-6 w-6" />
|
|
|
|
|
</div>
|
2026-06-03 13:56:11 +07:00
|
|
|
<MascotImage size="sm" />
|
2026-05-17 00:20:29 +07:00
|
|
|
</div>
|
|
|
|
|
<CardTitle>Admin Access Required</CardTitle>
|
2026-06-01 21:44:29 +07:00
|
|
|
<CardDescription>
|
|
|
|
|
Enter the admin password to access Voice and Media controls.
|
|
|
|
|
</CardDescription>
|
2026-05-17 00:20:29 +07:00
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<form onSubmit={handleSubmit} className="space-y-4">
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
<Input
|
|
|
|
|
type="password"
|
|
|
|
|
placeholder="Enter password"
|
|
|
|
|
value={password}
|
|
|
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
|
|
|
autoFocus
|
|
|
|
|
/>
|
|
|
|
|
{error && <p className="text-xs text-destructive">{error}</p>}
|
|
|
|
|
</div>
|
2026-06-01 21:44:29 +07:00
|
|
|
<Button
|
|
|
|
|
type="submit"
|
|
|
|
|
className="w-full"
|
|
|
|
|
disabled={loading || !password}
|
|
|
|
|
>
|
2026-05-17 00:20:29 +07:00
|
|
|
{loading ? "Authenticating..." : "Unlock Controls"}
|
|
|
|
|
</Button>
|
|
|
|
|
</form>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|