button guest

This commit is contained in:
2026-03-22 02:37:19 +01:00
parent b122600ffa
commit e235f3ff3d
3 changed files with 29 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import { FormEvent, useState } from "react";
import { GUEST_EMAIL, GUEST_PASSWORD } from "../constants";
interface Props {
onLogin: (email: string, password: string) => Promise<void>;
@@ -23,6 +24,18 @@ export function LoginForm({ onLogin }: Props) {
}
}
async function handleGuestLogin() {
setError("");
setLoading(true);
try {
await onLogin(GUEST_EMAIL, GUEST_PASSWORD);
} catch {
setError("Guest login failed. Please try again.");
} finally {
setLoading(false);
}
}
return (
<div className="min-h-screen flex items-center justify-center bg-slate-900">
<div className="w-full max-w-md">
@@ -86,6 +99,16 @@ export function LoginForm({ onLogin }: Props) {
>
{loading ? "Signing in…" : "Sign In"}
</button>
<button
type="button"
onClick={handleGuestLogin}
disabled={loading}
className="w-full bg-slate-700 hover:bg-slate-600 disabled:opacity-60 disabled:cursor-not-allowed
text-slate-300 font-semibold rounded-lg px-4 py-2.5 transition-colors"
>
Login as Guest
</button>
</form>
</div>
</div>