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 { FormEvent, useState } from "react";
import { GUEST_EMAIL, GUEST_PASSWORD } from "../constants";
interface Props { interface Props {
onLogin: (email: string, password: string) => Promise<void>; 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 ( return (
<div className="min-h-screen flex items-center justify-center bg-slate-900"> <div className="min-h-screen flex items-center justify-center bg-slate-900">
<div className="w-full max-w-md"> <div className="w-full max-w-md">
@@ -86,6 +99,16 @@ export function LoginForm({ onLogin }: Props) {
> >
{loading ? "Signing in…" : "Sign In"} {loading ? "Signing in…" : "Sign In"}
</button> </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> </form>
</div> </div>
</div> </div>

View 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;

View File

@@ -3,6 +3,10 @@ WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm ci RUN npm ci
COPY . . COPY . .
ARG VITE_GUEST_EMAIL
ARG VITE_GUEST_PASSWORD
ENV VITE_GUEST_EMAIL=$VITE_GUEST_EMAIL
ENV VITE_GUEST_PASSWORD=$VITE_GUEST_PASSWORD
RUN npm run build RUN npm run build
FROM nginx:alpine FROM nginx:alpine