Compare commits

...

5 Commits

Author SHA1 Message Date
edc1826a7d back to tunneling port 3000 2025-08-11 23:36:28 +02:00
43a99d7e77 even better styling 2025-08-11 23:34:44 +02:00
f60cade344 track id check events 2025-08-11 02:35:32 +02:00
bb1505a463 standalone next build 2025-08-11 02:05:52 +02:00
48ca910f83 fix build errors 2025-08-11 02:04:12 +02:00
10 changed files with 62 additions and 43 deletions

View File

@@ -1,7 +1,7 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
output: "standalone",
};
export default nextConfig;

View File

@@ -6,10 +6,7 @@ export async function POST(req: NextRequest) {
const { password } = await req.json();
if (password !== process.env.PASSWORD) {
return NextResponse.json(
{ error: "Invalid password" },
{ status: 401 }
);
return NextResponse.json({ error: "Invalid password" }, { status: 401 });
}
const session = await getSession();
@@ -18,6 +15,7 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ success: true });
} catch (error) {
console.error(error);
return NextResponse.json(
{ error: "Authentication failed" },
{ status: 500 }

View File

@@ -8,10 +8,7 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ success: true });
} catch (error) {
return NextResponse.json(
{ error: "Logout failed" },
{ status: 500 }
);
console.error(error);
return NextResponse.json({ error: "Logout failed" }, { status: 500 });
}
}
}

View File

@@ -68,10 +68,7 @@ export async function POST(req: NextRequest) {
sessionOptions
);
if (!session.authenticated) {
return NextResponse.json(
{ error: "Not authenticated" },
{ status: 401 }
);
return NextResponse.json({ error: "Not authenticated" }, { status: 401 });
}
const token = await fetchOidcToken();
@@ -81,7 +78,7 @@ export async function POST(req: NextRequest) {
const sessionUrl = apiBase + "/api/merchant/session";
// parse sessionId from request body, handle missing/invalid JSON
let body: any;
let body: { sessionId?: unknown } | undefined;
try {
body = await req.json();
} catch {
@@ -124,7 +121,11 @@ export async function POST(req: NextRequest) {
{ status: 500 }
);
}
} catch (err: any) {
return NextResponse.json({ error: err.message }, { status: 500 });
} catch (error) {
console.error(error);
return NextResponse.json(
{ error: "An unexpected error occurred" },
{ status: 500 }
);
}
}

View File

@@ -8,6 +8,7 @@ export async function GET() {
return NextResponse.json({ authenticated: isAuthenticated });
} catch (error) {
console.error(error)
return NextResponse.json({ authenticated: false });
}
}

View File

@@ -29,5 +29,5 @@
body {
background: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
font-family: var(--font-geist-sans), Arial, Helvetica, sans-serif;
}

View File

@@ -24,6 +24,15 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<head>
{process.env.UMAMI_SCRIPT_URL && process.env.UMAMI_WEBSITE_ID && (
<script
defer
src={process.env.UMAMI_SCRIPT_URL}
data-website-id={process.env.UMAMI_WEBSITE_ID}
></script>
)}
</head>
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>

View File

@@ -28,34 +28,34 @@ function SessionInfo({
}) {
return (
<div className="max-w-md mx-auto mt-2 p-2 bg-neuf-black space-y-4">
<div className="flex justify-center">
<div className="flex items-center relative bg-white rounded-lg overflow-hidden">
<button
onClick={onClear}
className="w-8 h-8 bg-red-600 text-white rounded-full hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 flex items-center justify-center font-bold text-lg transition-colors duration-200"
className="w-10 h-10 absolute top-2 right-2 bg-red-600 text-white rounded-full hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 flex items-center justify-center font-bold text-lg transition-colors duration-200"
aria-label="Clear session"
>
×
&times;
</button>
</div>
<div className="flex flex-col items-center">
<Image
src={`data:image/jpeg;base64,${session.documentPhoto}`}
alt="Document"
width={200}
height={261}
className="w-40 h-50 object-cover rounded-lg mb-4 border border-black-300 shadow"
className="w-40 h-50 object-cover border border-black-300 shadow"
unoptimized
/>
{(session.firstName || session.lastName) && (
<div className="text-xl font-bold text-white">
{[session.firstName, session.lastName].filter(Boolean).join(" ")}
</div>
)}
{typeof session.age === "number" && (
<div className="text-3xl font-extrabold text-white mt-2">
{session.age} år
</div>
)}
<div className="py-4 px-4">
{(session.firstName || session.lastName) && (
<div className="text-xl font-bold">
{[session.firstName, session.lastName].filter(Boolean).join(" ")}
</div>
)}
{typeof session.age === "number" && (
<div className="text-5xl font-extrabold text-neuf-black mt-2">
{session.age} år
</div>
)}
</div>
</div>
</div>
);
@@ -70,6 +70,20 @@ async function lookupSession(sessionId: string) {
return res.json();
}
declare global {
interface Window {
umami?: {
track: (eventName: string, eventData?: Record<string, unknown>) => void;
};
}
}
const trackEvent = (eventName: string, eventData?: Record<string, unknown>) => {
if (typeof window !== "undefined" && window.umami) {
window.umami.track(eventName, eventData);
}
};
function HomeInner() {
const [session, setSession] = useState<SessionResponse | null>(null);
const [scannedCodes, setScannedCodes] = useState<Set<string>>(new Set());
@@ -91,6 +105,7 @@ function HomeInner() {
if (data && typeof data.age === "number") {
setSession(data);
setScannedCodes((prev) => new Set(prev).add(variables));
trackEvent("id-check");
}
pendingCodeRef.current = null;
},

View File

@@ -37,14 +37,14 @@ export default function LoginForm({ onLogin }: LoginFormProps) {
return (
<div className="max-w-md mx-auto mt-20 p-6 bg-neuf-black">
<h1 className="text-2xl font-bold text-center mb-6 text-white">
<h1 className="text-5xl font-bold text-center mb-20 text-white">
Oldeneuf?
</h1>
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<label
htmlFor="password"
className="block text-sm font-medium text-gray-300 mb-1"
className="block text-md font-medium text-gray-300 mb-1"
>
Passord
</label>
@@ -56,17 +56,15 @@ export default function LoginForm({ onLogin }: LoginFormProps) {
setPassword(e.target.value);
setError("");
}}
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
className="w-full px-3 py-4 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
required
disabled={isLoading}
/>
{error && (
<p className="text-red-500 text-sm mt-1">{error}</p>
)}
{error && <p className="text-red-500 text-md mt-1">{error}</p>}
</div>
<button
type="submit"
className="w-full bg-golden-orange text-neuf-black py-2 px-4 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-500 disabled:opacity-50"
className="w-full font-bold bg-golden-orange text-neuf-black py-4 px-4 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-500 disabled:opacity-50"
disabled={isLoading}
>
{isLoading ? "Logger inn..." : "Logg inn"}

View File

@@ -290,7 +290,7 @@ export default function Scanner({ onScan }: ScannerProps) {
margin-left: 0 !important;
margin-right: 0 !important;
margin-top: 0 !important;
height: 50vh !important;
height: 55dvh !important;
background: #000;
border-radius: 0 !important;
display: flex;
@@ -299,7 +299,7 @@ export default function Scanner({ onScan }: ScannerProps) {
}
.video-container-responsive video {
width: 100vw !important;
height: 50vh !important;
height: 55dvh !important;
object-fit: cover;
border-radius: 0 !important;
border: none !important;