Fixes #68. - Bar switcher and stats page get a low-contrast "wutzcalc <git-sha>" footer at the bottom (VersionFooter component, shared). - Admin panel gets a fuller Diagnose section: version, user agent, screen resolution + device pixel ratio, viewport size, browser language. Version is the short git commit sha, baked in at build time via vite.config.ts define (falls back to "dev" if .git is unavailable at build time, e.g. a tarball/CI-artifact deploy) - matches how deploys actually run (pnpm build from a git checkout, per deploy/wutzcalc.service), but stays defensive rather than failing the build. pnpm --filter client typecheck and build both clean.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { useState } from 'preact/hooks';
|
|
import type { Bar } from '@wutzcalc/shared';
|
|
import { getTheme, setTheme } from '../api';
|
|
import { VersionFooter } from '../VersionFooter';
|
|
|
|
interface Props {
|
|
bars: Bar[] | null;
|
|
onPick: (id: number) => void;
|
|
}
|
|
|
|
export function BarPicker({ bars, onPick }: Props) {
|
|
const [theme, setThemeState] = useState(getTheme());
|
|
|
|
function toggleTheme() {
|
|
const next = theme === 'dark' ? 'light' : 'dark';
|
|
setTheme(next);
|
|
setThemeState(next);
|
|
}
|
|
|
|
return (
|
|
<div class="bar-picker">
|
|
<h1>Bar auswählen</h1>
|
|
{bars == null ? (
|
|
<p>Lade…</p>
|
|
) : bars.length === 0 ? (
|
|
// A fresh install (or every bar deleted) otherwise renders nothing
|
|
// but the header here — indistinguishable from "still loading".
|
|
<p class="muted">Keine Bars angelegt — bitte im Backoffice anlegen.</p>
|
|
) : (
|
|
bars.map(b => (
|
|
<button key={b.id} onClick={() => onPick(b.id)}>
|
|
{b.name}
|
|
</button>
|
|
))
|
|
)}
|
|
<button class="theme-toggle" onClick={toggleTheme}>
|
|
{theme === 'dark' ? '☀ Heller Modus' : '🌙 Dunkler Modus'}
|
|
</button>
|
|
<VersionFooter />
|
|
</div>
|
|
);
|
|
}
|