button guest
This commit is contained in:
@@ -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>
|
||||
|
||||
2
analytics-view/src/constants.ts
Normal file
2
analytics-view/src/constants.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const GUEST_EMAIL = import.meta.env.VITE_GUEST_EMAIL;
|
||||
export const GUEST_PASSWORD = import.meta.env.VITE_GUEST_PASSWORD;
|
||||
Reference in New Issue
Block a user