button guest
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
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;
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user