Some checks failed
CI / Lint, typecheck, test (pull_request) Successful in 4m43s
CI / Build container images (pull_request) Successful in 1m11s
CI / Auth e2e pack (pull_request) Successful in 7m14s
CI / Import/export fidelity gate (pull_request) Successful in 56s
CD / Deploy to Test (push) Blocked by required conditions
CD / Smoke tests against Test (push) Blocked by required conditions
CD / Promote to Int (push) Blocked by required conditions
CI / Auth e2e pack (push) Blocked by required conditions
CI / Import/export fidelity gate (push) Blocked by required conditions
CI / Build container images (push) Blocked by required conditions
CD / Build and push images (push) Has been cancelled
CI / Lint, typecheck, test (push) Has been cancelled
i18n spiegelt die aktive Sprache auf <html lang> (Init + languageChanged; der User-Locale-Wechsel in auth-context läuft über dasselbe Event). Neuer useDocumentTitle-Hook setzt je Route einen sprechenden Titel (Seite — Teich — Dorfteich), verdrahtet in allen Routen-Komponenten; dynamische Titel folgen den geladenen Daten. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AGM8jo3hwoV9wsCVGfy8iq
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { LegalPageView, isLegalKind } from '@dorfteich/shared';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { Link, useParams } from 'react-router-dom';
|
|
|
|
import { useAuth } from '../auth/auth-context';
|
|
import { apiGet } from '../lib/api';
|
|
import { NotFoundPage } from './NotFoundPage';
|
|
|
|
import { useDocumentTitle } from '../lib/use-document-title';
|
|
/**
|
|
* Public legal page (issue #82): imprint or privacy policy, reachable
|
|
* without a session. The HTML comes from the api's sanitizing Markdown
|
|
* pipeline (like #56's public view) — safe to render. An unconfigured page
|
|
* shows a notice instead of silently missing, and Site Admins additionally
|
|
* get a warning banner pointing at the settings (AC).
|
|
*/
|
|
export function LegalPage(): React.JSX.Element {
|
|
const { t } = useTranslation('legal');
|
|
const { user } = useAuth();
|
|
const { kind = '' } = useParams<{ kind: string }>();
|
|
useDocumentTitle(t(`title.${kind}`));
|
|
|
|
const query = useQuery({
|
|
queryKey: ['legal', kind],
|
|
queryFn: () => apiGet<LegalPageView>(`/legal/${kind}/content`),
|
|
enabled: isLegalKind(kind),
|
|
});
|
|
|
|
if (!isLegalKind(kind)) return <NotFoundPage />;
|
|
if (!query.data) return <div aria-busy="true" />;
|
|
|
|
return (
|
|
<article className="legal-page">
|
|
<h1>{t(`title.${kind}`)}</h1>
|
|
{!query.data.configured && user?.isSiteAdmin && (
|
|
<p className="form-banner form-banner--error" role="alert">
|
|
{t('adminWarning')} <Link to="/admin">{t('adminWarningLink')}</Link>
|
|
</p>
|
|
)}
|
|
{query.data.configured ? (
|
|
// Server-rendered through the sanitizing editor pipeline — safe.
|
|
<div className="legal-page__body" dangerouslySetInnerHTML={{ __html: query.data.html }} />
|
|
) : (
|
|
<p className="legal-page__placeholder">{t('notConfigured')}</p>
|
|
)}
|
|
</article>
|
|
);
|
|
}
|