feat: add authentication and admin features

- Added `jose` library for JWT token generation and verification.
- Implemented login functionality with token storage using cookies.
- Created `HeaderAdmin` component for admin panel with login/logout capabilities.
- Developed `LoginForm` component for user authentication.
- Added `Table` component to display data with caching from localStorage.
- Introduced `SubHeaderAdmin` for additional admin actions.
- Enhanced `database.js` with functions for admin login and fetching table data.
- Updated `server.js` to handle new routes for login and table data retrieval.
- Modified `package.json` and `package-lock.json` to include new dependencies.
This commit is contained in:
2025-08-12 22:56:58 +02:00
parent 97eaf1e484
commit 8c2049fa24
15 changed files with 744 additions and 14 deletions

View File

@@ -0,0 +1,48 @@
import React from "react";
import { Sheet, WholeWord } from "lucide-react";
// Sub navigation bar for admin views: provides import + clear selection actions
const SubHeaderAdmin: React.FC = () => {
return (
<header className="sticky top-0 z-30 w-full border-b border-gray-200/70 bg-white/90 backdrop-blur supports-[backdrop-filter]:bg-white/60">
<div className="mx-auto flex max-w-7xl items-center justify-between gap-4 px-4 py-2.5 md:px-6">
<div className="flex items-center gap-3">
<h2 className="text-base font-semibold tracking-tight text-gray-800 sm:text-lg">
Verwaltung
</h2>
<span
className="hidden h-5 w-px bg-gray-300 sm:inline-block"
aria-hidden="true"
/>
<p className="hidden text-sm text-gray-500 md:block">
Aktionen für Daten in der Datenbank
</p>
</div>
<div className="flex items-center gap-2">
<button
type="button"
className="group inline-flex items-center gap-2 rounded-md border border-gray-300 bg-white px-3.5 py-2 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/60 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
>
<Sheet
className="h-4 w-4 shrink-0 text-gray-500 transition group-hover:text-gray-600"
strokeWidth={1.75}
/>
<span className="whitespace-nowrap">Losnummern importieren</span>
</button>
<button
type="button"
className="group inline-flex items-center gap-2 rounded-md bg-rose-600 px-3.5 py-2 text-sm font-medium text-white shadow-sm transition hover:bg-rose-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-500/60 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60"
>
<WholeWord
className="h-4 w-4 shrink-0 text-white/90 transition group-hover:text-white"
strokeWidth={1.75}
/>
<span className="whitespace-nowrap">Auswahl löschen</span>
</button>
</div>
</div>
</header>
);
};
export default SubHeaderAdmin;