forked from fahrPool/fahrPool
1215 lines
46 KiB
Markdown
1215 lines
46 KiB
Markdown
# Design-System (Mobile-First, Widmann-Branding) Implementation Plan
|
||
|
||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||
|
||
**Goal:** Apply a mobile-first, Widmann-branded visual design (Tailwind CSS v4) across every existing page of the Aushilfsfahrer app, replacing the current unstyled semantic HTML — a pure presentation-layer change with no new business logic.
|
||
|
||
**Architecture:** Tailwind CSS v4 (PostCSS-only setup, no `tailwind.config.js`) with a `@theme` block defining the 5 extracted Widmann brand tokens plus 4 status-semantic colors. A small `web/components/ui/` primitives layer (`Button`, `Card`, `Alert`, `FormField`, `StatusBadge`) is built once and then wired into every existing page. Mobile navigation uses a client-side drawer (`MobileNav`), replaced by a plain horizontal header row at the `lg:` breakpoint.
|
||
|
||
**Tech Stack:** Next.js 16 (App Router, already in place), Tailwind CSS v4, `next/font/google` (Inter), existing Vitest suite (no new test dependencies).
|
||
|
||
## Global Constraints
|
||
|
||
- Brand color tokens (exact hex, from `docs/superpowers/specs/2026-07-06-design-system-design.md`): `performance-blue` `#0071ed`, `night-blue` `#0a185c`, `asphalt-grey` `#1a1a1a`, `aluminium-grey` `#eef2f6`, `white` `#fff`.
|
||
- Status-semantic colors (not brand tokens, additive per spec section 3): `status-neutral` `#6b7280` (offen), `status-warning` `#f59e0b` (unterwegs), `status-success` `#16a34a` (abgeschlossen), `status-danger` `#dc2626` (storniert; also used for error `Alert`).
|
||
- Font: Inter, loaded via `next/font/google` (no runtime request to Google Fonts — Next.js self-hosts it at build time).
|
||
- Mobile-first breakpoints: Tailwind v4 defaults — unprefixed = base/mobile, `md:` ≈768px, `lg:` ≈1024px.
|
||
- Touch targets: minimum 44×44px (Tailwind spacing `11` = 2.75rem = 44px) on every interactive element.
|
||
- Logo asset already committed at `web/public/brand/widmann-logo.svg` (SVG wordmark, viewBox `0 0 233.65 35.31`, monochrome black fill).
|
||
- No changes to Server Actions, RLS policies, the data model, or any redirect/validation logic in `actions.ts` files — visual/structural changes only.
|
||
- No dark mode (spec explicitly excludes it).
|
||
- No new automated test dependencies (no `@testing-library/react`, no new test runner config). Verification per task is `npm run build` + `npm test` (existing Vitest suite must stay green) plus a manual/curl-based structural check. Full cross-browser/cross-breakpoint visual verification is done by the project owner in the running Docker container after all tasks land (per spec section 6) — do not attempt to spin up a headless browser for this.
|
||
- **Corrected curl login technique** (the plain `curl -d "email=..." -d "password=..." -X POST .../login` shown in some task verification steps below does NOT work against a real Next.js Server Action and will be silently rejected — this was discovered and fixed during Task 3). `login` in `web/app/login/actions.ts` is an *unbound* Server Action; a real `<form>` submit encodes it as a hidden `multipart/form-data` field named `$ACTION_ID_<hash>` (the hash changes on every dev-server restart/rebuild — always re-read it fresh, never hardcode a previously seen value). Correct technique:
|
||
```bash
|
||
# 1. Read the current action id from the rendered page
|
||
curl -s http://localhost:<port>/login | grep -o '\$ACTION_ID_[a-z0-9]*'
|
||
# 2. Submit with that id as an empty multipart field, alongside the real form fields
|
||
curl -s -c /tmp/cookies.txt -X POST http://localhost:<port>/login \
|
||
-F '$ACTION_ID_<HASH>=' \
|
||
-F 'email=admin@aushilfsfahrer.local' \
|
||
-F 'password=Admin123!' \
|
||
-L -o /tmp/response.html -w "HTTP_STATUS:%{http_code} FINAL_URL:%{url_effective}\n"
|
||
# 3. Reuse the cookie jar for subsequent authenticated page fetches:
|
||
curl -s -b /tmp/cookies.txt http://localhost:<port>/dashboard
|
||
```
|
||
A test admin user already exists in the local Supabase CLI dev stack (`npx supabase status` from the repo root to confirm it's running) for exactly this purpose: `admin@aushilfsfahrer.local` / `Admin123!`, profile name `Admin`, role `admin`. Also note: this worktree's `web/.env.local` (gitignored) must point at the local CLI dev stack (`http://127.0.0.1:54321` + the real anon key from `npx supabase status`), not the master Docker-Compose stack — verify this first if login curls return `E-Mail oder Passwort ist falsch.` despite correct credentials.
|
||
|
||
---
|
||
|
||
### Task 1: Tailwind CSS v4 setup, brand tokens, Inter font
|
||
|
||
**Files:**
|
||
- Modify: `web/package.json`
|
||
- Create: `web/postcss.config.mjs`
|
||
- Modify: `web/app/globals.css` (full rewrite)
|
||
- Modify: `web/app/layout.tsx:1-8` (font wiring only — header/nav restructuring happens in Task 3)
|
||
- Delete: `web/app/page.module.css` (dead code — confirmed unused by `grep -r "page.module.css" web/`, `web/app/page.tsx` only calls `redirect("/dashboard")` and never renders JSX)
|
||
|
||
**Interfaces:**
|
||
- Produces: Tailwind utility classes for all brand/status tokens (`bg-performance-blue`, `text-performance-blue`, `border-performance-blue`, `bg-night-blue`, `text-asphalt-grey`, `bg-aluminium-grey`, `bg-status-neutral`, `bg-status-warning`, `bg-status-success`, `bg-status-danger`, `text-status-*` equivalents, etc. — Tailwind v4 auto-generates `bg-*`/`text-*`/`border-*` utilities for every `--color-*` variable in `@theme`). Produces the `font-sans` utility resolving to Inter. All later tasks consume these classes; none of them touch `globals.css` or `postcss.config.mjs` again.
|
||
|
||
- [ ] **Step 1: Install Tailwind CSS v4 and its PostCSS plugin**
|
||
|
||
```bash
|
||
cd web
|
||
npm install -D tailwindcss@^4 @tailwindcss/postcss@^4 postcss@^8
|
||
```
|
||
|
||
- [ ] **Step 2: Create the PostCSS config**
|
||
|
||
Create `web/postcss.config.mjs`:
|
||
|
||
```js
|
||
const config = {
|
||
plugins: {
|
||
"@tailwindcss/postcss": {},
|
||
},
|
||
};
|
||
|
||
export default config;
|
||
```
|
||
|
||
- [ ] **Step 3: Replace `globals.css` with Tailwind import + brand theme**
|
||
|
||
Replace the entire contents of `web/app/globals.css` with:
|
||
|
||
```css
|
||
@import "tailwindcss";
|
||
|
||
@theme {
|
||
--color-performance-blue: #0071ed;
|
||
--color-night-blue: #0a185c;
|
||
--color-asphalt-grey: #1a1a1a;
|
||
--color-aluminium-grey: #eef2f6;
|
||
|
||
--color-status-neutral: #6b7280;
|
||
--color-status-warning: #f59e0b;
|
||
--color-status-success: #16a34a;
|
||
--color-status-danger: #dc2626;
|
||
|
||
--font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
|
||
}
|
||
|
||
html,
|
||
body {
|
||
height: 100%;
|
||
}
|
||
|
||
body {
|
||
color: var(--color-asphalt-grey);
|
||
background: #fff;
|
||
}
|
||
```
|
||
|
||
This drops the old dark-mode `@media (prefers-color-scheme: dark)` block and the Arial font fallback (Global Constraints: no dark mode; Inter replaces Arial). Tailwind's Preflight (bundled with `@import "tailwindcss"`) already resets margins/padding/box-sizing, so the old manual `* { box-sizing: border-box; padding: 0; margin: 0; }` reset is redundant and removed.
|
||
|
||
- [ ] **Step 4: Delete the unused `page.module.css`**
|
||
|
||
```bash
|
||
rm web/app/page.module.css
|
||
```
|
||
|
||
- [ ] **Step 5: Wire Inter into the root layout**
|
||
|
||
In `web/app/layout.tsx`, add the font import and apply it to the `<html>` tag. Change only these parts (leave the rest of the file, including the header/`<body>` structure, untouched — Task 3 restructures those):
|
||
|
||
```tsx
|
||
import { Inter } from "next/font/google";
|
||
import "./globals.css";
|
||
import { loadProfile } from "@/lib/auth/profile";
|
||
import { NavLinks } from "@/components/NavLinks";
|
||
import { LogoutButton } from "@/components/LogoutButton";
|
||
|
||
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
|
||
|
||
export const metadata = {
|
||
title: "Aushilfsfahrer",
|
||
};
|
||
```
|
||
|
||
And add `className={inter.variable}` to both `<html>` tags in the file (the `missing-profile` branch and the main return):
|
||
|
||
```tsx
|
||
<html lang="de" className={inter.variable}>
|
||
```
|
||
|
||
Also add `font-sans` to the `<body>` tag's existing (currently absent) className in both branches:
|
||
|
||
```tsx
|
||
<body className="font-sans">
|
||
```
|
||
|
||
- [ ] **Step 6: Verify the build**
|
||
|
||
```bash
|
||
cd web
|
||
npm run build
|
||
```
|
||
|
||
Expected: exit code 0, all routes compile (same route list as before: `/`, `/_not-found`, `/auftraege`, `/auftraege/[id]`, `/auftraege/neu`, `/dashboard`, `/login`).
|
||
|
||
- [ ] **Step 7: Verify the brand tokens actually compiled into CSS**
|
||
|
||
```bash
|
||
cd web
|
||
grep -r "0071ed" .next/static/css/*.css
|
||
```
|
||
|
||
Expected: at least one match (confirms the `@theme` block produced real utility classes containing the brand hex value — if this greps empty, the `@theme` block was not picked up and something in Steps 1-3 is wrong).
|
||
|
||
- [ ] **Step 8: Run the existing test suite**
|
||
|
||
```bash
|
||
cd web
|
||
npm test
|
||
```
|
||
|
||
Expected: `Test Files 4 passed (4)`, `Tests 17 passed (17)` — unchanged from before this task (this task touches no logic files, only CSS/font/build config).
|
||
|
||
- [ ] **Step 9: Commit**
|
||
|
||
```bash
|
||
git add web/package.json web/package-lock.json web/postcss.config.mjs web/app/globals.css web/app/layout.tsx
|
||
git rm web/app/page.module.css
|
||
git commit -m "feat: add Tailwind CSS v4 with Widmann brand tokens and Inter font"
|
||
```
|
||
|
||
---
|
||
|
||
### Task 2: UI primitives (Button, Card, Alert, FormField) + Login page
|
||
|
||
**Files:**
|
||
- Create: `web/components/ui/Button.tsx`
|
||
- Create: `web/components/ui/Card.tsx`
|
||
- Create: `web/components/ui/Alert.tsx`
|
||
- Create: `web/components/ui/FormField.tsx`
|
||
- Modify: `web/app/login/page.tsx` (full rewrite)
|
||
|
||
**Interfaces:**
|
||
- Consumes: Tailwind utilities from Task 1 (`bg-performance-blue`, `bg-night-blue`, `text-asphalt-grey`, `border-aluminium-grey`, `bg-status-danger`, `font-sans`).
|
||
- Produces:
|
||
- `Button` (default export: none; named export `Button`) — props: `variant?: "primary" | "secondary" | "destructive"` (default `"primary"`), `fullWidth?: boolean` (default `true`), plus all standard `<button>` HTML attributes (via `ComponentProps<"button">`).
|
||
- `buttonClasses(variant?: ButtonVariant, fullWidth?: boolean): string` — named export from the same file, returns the class string `Button` uses internally. Later tasks use this to style `<Link>` elements that must look like buttons (nesting a real `<button>` inside an `<a>` is invalid HTML).
|
||
- `Card` — named export, props: all standard `<div>` attributes (via `ComponentProps<"div">`), renders a styled `<div>`.
|
||
- `Alert` — named export, props: `{ children: React.ReactNode }`, renders a `<p role="alert">` with error styling (keeps the `role="alert"` accessibility contract every existing page already relies on).
|
||
- `FormField` — named export, props: `{ label: string; htmlFor: string; children: React.ReactNode }`, renders a `<label>` + the passed-in input/select.
|
||
- `FIELD_CLASSES` — named `string` export from the same file, the Tailwind class string every raw `<input>`/`<select>` in later tasks applies directly (kept as a shared constant instead of wrapping inputs in a generic polymorphic component — the existing pages use plain native `<input>`/`<select>` elements with `type`-specific attributes that don't need abstracting).
|
||
|
||
- [ ] **Step 1: Create the Button primitive**
|
||
|
||
Create `web/components/ui/Button.tsx`:
|
||
|
||
```tsx
|
||
import type { ComponentProps } from "react";
|
||
|
||
export type ButtonVariant = "primary" | "secondary" | "destructive";
|
||
|
||
const VARIANT_CLASSES: Record<ButtonVariant, string> = {
|
||
primary: "bg-performance-blue text-white hover:bg-night-blue",
|
||
secondary: "bg-white text-asphalt-grey border border-asphalt-grey hover:bg-aluminium-grey",
|
||
destructive: "bg-status-danger text-white hover:bg-red-700",
|
||
};
|
||
|
||
export function buttonClasses(variant: ButtonVariant = "primary", fullWidth = true): string {
|
||
return [
|
||
"inline-flex min-h-11 items-center justify-center rounded-md px-4 py-2 text-center font-medium",
|
||
"transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",
|
||
"focus-visible:outline-performance-blue disabled:cursor-not-allowed disabled:opacity-50",
|
||
VARIANT_CLASSES[variant],
|
||
fullWidth ? "w-full" : "",
|
||
].join(" ");
|
||
}
|
||
|
||
export function Button({
|
||
variant = "primary",
|
||
fullWidth = true,
|
||
className = "",
|
||
...props
|
||
}: ComponentProps<"button"> & { variant?: ButtonVariant; fullWidth?: boolean }) {
|
||
return <button className={`${buttonClasses(variant, fullWidth)} ${className}`} {...props} />;
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 2: Create the Card primitive**
|
||
|
||
Create `web/components/ui/Card.tsx`:
|
||
|
||
```tsx
|
||
import type { ComponentProps } from "react";
|
||
|
||
export function Card({ className = "", ...props }: ComponentProps<"div">) {
|
||
return <div className={`rounded-lg border border-aluminium-grey bg-white p-4 shadow-sm ${className}`} {...props} />;
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 3: Create the Alert primitive**
|
||
|
||
Create `web/components/ui/Alert.tsx`:
|
||
|
||
```tsx
|
||
export function Alert({ children }: { children: React.ReactNode }) {
|
||
return (
|
||
<p role="alert" className="rounded-md border border-status-danger bg-red-50 px-4 py-3 text-status-danger">
|
||
{children}
|
||
</p>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 4: Create the FormField primitive**
|
||
|
||
Create `web/components/ui/FormField.tsx`:
|
||
|
||
```tsx
|
||
export const FIELD_CLASSES =
|
||
"min-h-11 w-full rounded-md border border-aluminium-grey px-3 py-2 text-base text-asphalt-grey focus:outline-none focus:ring-2 focus:ring-performance-blue";
|
||
|
||
export function FormField({
|
||
label,
|
||
htmlFor,
|
||
children,
|
||
}: {
|
||
label: string;
|
||
htmlFor: string;
|
||
children: React.ReactNode;
|
||
}) {
|
||
return (
|
||
<div className="mb-4 flex flex-col gap-1">
|
||
<label htmlFor={htmlFor} className="text-sm font-medium text-asphalt-grey">
|
||
{label}
|
||
</label>
|
||
{children}
|
||
</div>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 5: Rewrite the login page using the new primitives**
|
||
|
||
Replace the entire contents of `web/app/login/page.tsx` with:
|
||
|
||
```tsx
|
||
import { login } from "./actions";
|
||
import { Button } from "@/components/ui/Button";
|
||
import { Card } from "@/components/ui/Card";
|
||
import { Alert } from "@/components/ui/Alert";
|
||
import { FormField, FIELD_CLASSES } from "@/components/ui/FormField";
|
||
|
||
export default async function LoginPage({
|
||
searchParams,
|
||
}: {
|
||
searchParams: Promise<{ error?: string }>;
|
||
}) {
|
||
const { error } = await searchParams;
|
||
|
||
return (
|
||
<main className="flex flex-1 items-center justify-center px-4 py-8">
|
||
<Card className="w-full max-w-sm">
|
||
<h1 className="mb-6 text-center text-xl font-semibold text-asphalt-grey">Anmelden</h1>
|
||
{error && (
|
||
<div className="mb-4">
|
||
<Alert>{error}</Alert>
|
||
</div>
|
||
)}
|
||
<form action={login}>
|
||
<FormField label="E-Mail" htmlFor="email">
|
||
<input id="email" name="email" type="email" required className={FIELD_CLASSES} />
|
||
</FormField>
|
||
<FormField label="Passwort" htmlFor="password">
|
||
<input id="password" name="password" type="password" required className={FIELD_CLASSES} />
|
||
</FormField>
|
||
<Button type="submit">Anmelden</Button>
|
||
</form>
|
||
</Card>
|
||
</main>
|
||
);
|
||
}
|
||
```
|
||
|
||
Note: `flex flex-1` on `<main>` requires the parent `<body>` to be a flex column — this is already true after Task 1's `globals.css`, and Task 3 will make it explicit on `<body>`'s className. If you run this task before Task 3 lands, vertical centering may not visibly take effect yet (the flex context isn't wired to `<body>` until Task 3) — that's expected and not a bug; `npm run build` will still succeed and the login page will render correctly once Task 3 is also in place. Do not add `min-h-screen` or similar workarounds here — that would conflict with Task 3's layout.
|
||
|
||
- [ ] **Step 6: Verify the build and tests**
|
||
|
||
```bash
|
||
cd web
|
||
npm run build
|
||
npm test
|
||
```
|
||
|
||
Expected: build exit code 0; `Tests 17 passed (17)` (unchanged — this task touches no Server Action or validation logic).
|
||
|
||
- [ ] **Step 7: Manually verify the rendered login page**
|
||
|
||
```bash
|
||
cd web
|
||
npm run dev -- -p 3111 &
|
||
sleep 3
|
||
curl -s http://localhost:3111/login | grep -o 'bg-performance-blue\|role="alert"\|E-Mail\|Passwort' | sort -u
|
||
kill %1
|
||
```
|
||
|
||
Expected output contains `E-Mail`, `Passwort`, and `bg-performance-blue` (confirms the primary submit button rendered with the brand color class). `role="alert"` will not appear on a fresh unauthenticated load (no `error` query param) — that's expected, not a failure.
|
||
|
||
- [ ] **Step 8: Commit**
|
||
|
||
```bash
|
||
git add web/components/ui/Button.tsx web/components/ui/Card.tsx web/components/ui/Alert.tsx web/components/ui/FormField.tsx web/app/login/page.tsx
|
||
git commit -m "feat: add UI primitives (Button, Card, Alert, FormField) and restyle login page"
|
||
```
|
||
|
||
---
|
||
|
||
### Task 3: Header, mobile drawer navigation, desktop header
|
||
|
||
**Files:**
|
||
- Create: `web/components/MobileNav.tsx` (client component)
|
||
- Modify: `web/components/NavLinks.tsx` (full rewrite)
|
||
- Modify: `web/components/LogoutButton.tsx` (full rewrite)
|
||
- Modify: `web/app/layout.tsx` (full rewrite, building on Task 1's font wiring)
|
||
|
||
**Interfaces:**
|
||
- Consumes: `buttonClasses`/`Button` from Task 2 (`web/components/ui/Button.tsx`), `inter.variable` font wiring already present in `web/app/layout.tsx` from Task 1.
|
||
- Produces: `NavLinks` gains a new `orientation?: "vertical" | "horizontal"` prop (default `"vertical"`) — later tasks do not consume `NavLinks` directly (only `layout.tsx` does), but the prop name/type is fixed here for anyone touching `layout.tsx` again later. `MobileNav` — named export, props: `{ children: React.ReactNode }`, manages its own open/closed state, renders a hamburger button + slide-in drawer containing `children`.
|
||
|
||
- [ ] **Step 1: Create the MobileNav client component**
|
||
|
||
Create `web/components/MobileNav.tsx`:
|
||
|
||
```tsx
|
||
"use client";
|
||
|
||
import { useEffect, useState } from "react";
|
||
|
||
export function MobileNav({ children }: { children: React.ReactNode }) {
|
||
const [open, setOpen] = useState(false);
|
||
|
||
useEffect(() => {
|
||
if (!open) return;
|
||
function onKeyDown(event: KeyboardEvent) {
|
||
if (event.key === "Escape") setOpen(false);
|
||
}
|
||
window.addEventListener("keydown", onKeyDown);
|
||
return () => window.removeEventListener("keydown", onKeyDown);
|
||
}, [open]);
|
||
|
||
return (
|
||
<div className="lg:hidden">
|
||
<button
|
||
type="button"
|
||
aria-label={open ? "Menü schließen" : "Menü öffnen"}
|
||
aria-expanded={open}
|
||
onClick={() => setOpen((value) => !value)}
|
||
className="flex min-h-11 min-w-11 items-center justify-center rounded-md text-asphalt-grey focus-visible:outline focus-visible:outline-2 focus-visible:outline-performance-blue"
|
||
>
|
||
<svg viewBox="0 0 24 24" className="h-6 w-6" fill="none" stroke="currentColor" strokeWidth={2}>
|
||
{open ? (
|
||
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||
) : (
|
||
<path strokeLinecap="round" strokeLinejoin="round" d="M4 6h16M4 12h16M4 18h16" />
|
||
)}
|
||
</svg>
|
||
</button>
|
||
|
||
{open && (
|
||
<div className="fixed inset-0 z-50">
|
||
<button
|
||
type="button"
|
||
aria-label="Menü schließen"
|
||
onClick={() => setOpen(false)}
|
||
className="absolute inset-0 bg-black/40"
|
||
/>
|
||
<div className="absolute right-0 top-0 h-full w-72 max-w-[85vw] bg-white p-4 shadow-lg">
|
||
<button
|
||
type="button"
|
||
aria-label="Menü schließen"
|
||
onClick={() => setOpen(false)}
|
||
className="mb-4 ml-auto flex min-h-11 min-w-11 items-center justify-center rounded-md text-asphalt-grey focus-visible:outline focus-visible:outline-2 focus-visible:outline-performance-blue"
|
||
>
|
||
<svg viewBox="0 0 24 24" className="h-6 w-6" fill="none" stroke="currentColor" strokeWidth={2}>
|
||
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||
</svg>
|
||
</button>
|
||
{children}
|
||
</div>
|
||
</div>
|
||
)}
|
||
</div>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 2: Add an orientation prop to NavLinks**
|
||
|
||
Replace the entire contents of `web/components/NavLinks.tsx` with:
|
||
|
||
```tsx
|
||
import Link from "next/link";
|
||
import { canManageUsers, type Role } from "@/lib/auth/roles";
|
||
|
||
export function NavLinks({
|
||
role,
|
||
orientation = "vertical",
|
||
}: {
|
||
role: Role;
|
||
orientation?: "vertical" | "horizontal";
|
||
}) {
|
||
const layoutClass = orientation === "horizontal" ? "flex flex-row items-center gap-6" : "flex flex-col gap-4";
|
||
|
||
return (
|
||
<nav className={layoutClass}>
|
||
<Link href="/dashboard" className="text-asphalt-grey hover:text-performance-blue">
|
||
Dashboard
|
||
</Link>
|
||
<Link href="/auftraege" className="text-asphalt-grey hover:text-performance-blue">
|
||
Aufträge
|
||
</Link>
|
||
{canManageUsers(role) && (
|
||
<Link href="/nutzerverwaltung" className="text-asphalt-grey hover:text-performance-blue">
|
||
Nutzerverwaltung
|
||
</Link>
|
||
)}
|
||
</nav>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 3: Restyle LogoutButton using the Button primitive**
|
||
|
||
Replace the entire contents of `web/components/LogoutButton.tsx` with:
|
||
|
||
```tsx
|
||
import { logout } from "@/app/login/actions";
|
||
import { Button } from "@/components/ui/Button";
|
||
|
||
export function LogoutButton() {
|
||
return (
|
||
<form action={logout}>
|
||
<Button type="submit" variant="secondary" fullWidth={false}>
|
||
Abmelden
|
||
</Button>
|
||
</form>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 4: Rewrite the root layout with the new header**
|
||
|
||
Replace the entire contents of `web/app/layout.tsx` with:
|
||
|
||
```tsx
|
||
import Image from "next/image";
|
||
import Link from "next/link";
|
||
import { Inter } from "next/font/google";
|
||
import "./globals.css";
|
||
import { loadProfile } from "@/lib/auth/profile";
|
||
import { NavLinks } from "@/components/NavLinks";
|
||
import { LogoutButton } from "@/components/LogoutButton";
|
||
import { MobileNav } from "@/components/MobileNav";
|
||
|
||
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
|
||
|
||
export const metadata = {
|
||
title: "Aushilfsfahrer",
|
||
};
|
||
|
||
export default async function RootLayout({
|
||
children,
|
||
}: Readonly<{ children: React.ReactNode }>) {
|
||
const result = await loadProfile();
|
||
|
||
if (result.status === "missing-profile") {
|
||
return (
|
||
<html lang="de" className={inter.variable}>
|
||
<body className="flex min-h-screen flex-col font-sans">
|
||
<main className="flex flex-1 items-center justify-center p-4">
|
||
<div>
|
||
<h1 className="text-xl font-semibold text-asphalt-grey">Profil nicht gefunden</h1>
|
||
<p className="mt-2 text-asphalt-grey">
|
||
Für deinen Account existiert kein Profil. Bitte wende dich an einen Admin.
|
||
</p>
|
||
</div>
|
||
</main>
|
||
</body>
|
||
</html>
|
||
);
|
||
}
|
||
|
||
return (
|
||
<html lang="de" className={inter.variable}>
|
||
<body className="flex min-h-screen flex-col font-sans">
|
||
{result.status === "ok" && (
|
||
<header className="flex h-16 items-center justify-between border-b border-aluminium-grey px-4 lg:px-8">
|
||
<Link href="/dashboard" className="flex items-center">
|
||
<Image src="/brand/widmann-logo.svg" alt="Widmann" width={140} height={21} priority />
|
||
</Link>
|
||
|
||
<div className="hidden items-center gap-6 lg:flex">
|
||
<NavLinks role={result.profile.role} orientation="horizontal" />
|
||
<span className="text-sm text-asphalt-grey">
|
||
{result.profile.name} ({result.profile.role})
|
||
</span>
|
||
<LogoutButton />
|
||
</div>
|
||
|
||
<MobileNav>
|
||
<div className="mb-6 text-sm text-asphalt-grey">
|
||
{result.profile.name} ({result.profile.role})
|
||
</div>
|
||
<NavLinks role={result.profile.role} orientation="vertical" />
|
||
<div className="mt-6">
|
||
<LogoutButton />
|
||
</div>
|
||
</MobileNav>
|
||
</header>
|
||
)}
|
||
<main className="flex-1">{children}</main>
|
||
</body>
|
||
</html>
|
||
);
|
||
}
|
||
```
|
||
|
||
Note: `MobileNav` is a client component receiving already-rendered Server Component output (`NavLinks`, `LogoutButton`, the profile `<div>`) as `children` — this is the standard, fully-supported Next.js App Router "server output passed into a client shell" composition pattern. `MobileNav` itself never imports server-only code, so this does not violate the client/server boundary.
|
||
|
||
- [ ] **Step 5: Verify the build and tests**
|
||
|
||
```bash
|
||
cd web
|
||
npm run build
|
||
npm test
|
||
```
|
||
|
||
Expected: build exit code 0; `Tests 17 passed (17)`.
|
||
|
||
- [ ] **Step 6: Manually verify the header renders for an authenticated session**
|
||
|
||
Reuse the cookie-jar login technique already documented in `.superpowers/sdd/task-10-report.md` / `.superpowers/sdd/task-11-report.md` (log in as `admin@aushilfsfahrer.local`, save cookies, then curl subsequent pages with `-b`):
|
||
|
||
```bash
|
||
cd web
|
||
npm run dev -- -p 3111 &
|
||
sleep 3
|
||
curl -s -c /tmp/cookies.txt -d "email=admin@aushilfsfahrer.local" -d "password=Admin123!" -X POST http://localhost:3111/login -L -o /dev/null
|
||
curl -s -b /tmp/cookies.txt http://localhost:3111/dashboard | grep -o 'aria-expanded\|widmann-logo.svg\|Abmelden' | sort -u
|
||
kill %1
|
||
rm /tmp/cookies.txt
|
||
```
|
||
|
||
Expected: all three of `aria-expanded` (the hamburger button), `widmann-logo.svg` (the logo image src), and `Abmelden` appear.
|
||
|
||
- [ ] **Step 7: Commit**
|
||
|
||
```bash
|
||
git add web/components/MobileNav.tsx web/components/NavLinks.tsx web/components/LogoutButton.tsx web/app/layout.tsx
|
||
git commit -m "feat: add mobile drawer navigation and restyle header"
|
||
```
|
||
|
||
---
|
||
|
||
### Task 4: Dashboard page
|
||
|
||
**Files:**
|
||
- Modify: `web/app/dashboard/page.tsx` (full rewrite)
|
||
|
||
**Interfaces:**
|
||
- Consumes: `Card` from `web/components/ui/Card.tsx` (Task 2).
|
||
|
||
- [ ] **Step 1: Rewrite the dashboard page**
|
||
|
||
Replace the entire contents of `web/app/dashboard/page.tsx` with:
|
||
|
||
```tsx
|
||
import { loadProfile } from "@/lib/auth/profile";
|
||
import { Card } from "@/components/ui/Card";
|
||
|
||
export default async function DashboardPage() {
|
||
const result = await loadProfile();
|
||
|
||
if (result.status !== "ok") {
|
||
return null;
|
||
}
|
||
|
||
return (
|
||
<div className="mx-auto max-w-2xl p-4 md:p-8">
|
||
<Card>
|
||
<h1 className="text-xl font-semibold text-asphalt-grey">Dashboard</h1>
|
||
<p className="mt-2 text-asphalt-grey">
|
||
Eingeloggt als {result.profile.name} ({result.profile.role})
|
||
</p>
|
||
</Card>
|
||
</div>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 2: Verify the build and tests**
|
||
|
||
```bash
|
||
cd web
|
||
npm run build
|
||
npm test
|
||
```
|
||
|
||
Expected: build exit code 0; `Tests 17 passed (17)`.
|
||
|
||
- [ ] **Step 3: Manually verify**
|
||
|
||
```bash
|
||
cd web
|
||
npm run dev -- -p 3111 &
|
||
sleep 3
|
||
curl -s -c /tmp/cookies.txt -d "email=admin@aushilfsfahrer.local" -d "password=Admin123!" -X POST http://localhost:3111/login -L -o /dev/null
|
||
curl -s -b /tmp/cookies.txt http://localhost:3111/dashboard | grep -o 'Eingeloggt als Admin'
|
||
kill %1
|
||
rm /tmp/cookies.txt
|
||
```
|
||
|
||
Expected: `Eingeloggt als Admin` appears (confirms the page still renders the correct data inside the new `Card` markup).
|
||
|
||
- [ ] **Step 4: Commit**
|
||
|
||
```bash
|
||
git add web/app/dashboard/page.tsx
|
||
git commit -m "feat: restyle dashboard page"
|
||
```
|
||
|
||
---
|
||
|
||
### Task 5: StatusBadge + Aufträge-Liste
|
||
|
||
**Files:**
|
||
- Create: `web/components/ui/StatusBadge.tsx`
|
||
- Modify: `web/components/AuftragListe.tsx` (full rewrite)
|
||
- Modify: `web/app/auftraege/page.tsx` (full rewrite)
|
||
|
||
**Interfaces:**
|
||
- Consumes: `AuftragStatus` type from `web/lib/auftraege/queries.ts:17` (`"offen" | "zugewiesen" | "unterwegs" | "abgeschlossen" | "storniert"`), `Card`/`Alert` from Task 2, `buttonClasses` from Task 2.
|
||
- Produces: `StatusBadge` — named export, props: `{ status: AuftragStatus }`, renders a colored pill with the German label. Consumed by Task 6 (Auftrag-Detail) as well.
|
||
|
||
- [ ] **Step 1: Create the StatusBadge primitive**
|
||
|
||
Create `web/components/ui/StatusBadge.tsx`:
|
||
|
||
```tsx
|
||
import type { AuftragStatus } from "@/lib/auftraege/queries";
|
||
|
||
const STATUS_LABELS: Record<AuftragStatus, string> = {
|
||
offen: "Offen",
|
||
zugewiesen: "Zugewiesen",
|
||
unterwegs: "Unterwegs",
|
||
abgeschlossen: "Abgeschlossen",
|
||
storniert: "Storniert",
|
||
};
|
||
|
||
const STATUS_CLASSES: Record<AuftragStatus, string> = {
|
||
offen: "bg-gray-100 text-status-neutral",
|
||
zugewiesen: "bg-blue-50 text-performance-blue",
|
||
unterwegs: "bg-amber-50 text-status-warning",
|
||
abgeschlossen: "bg-green-50 text-status-success",
|
||
storniert: "bg-red-50 text-status-danger",
|
||
};
|
||
|
||
export function StatusBadge({ status }: { status: AuftragStatus }) {
|
||
return (
|
||
<span className={`inline-block rounded-full px-3 py-1 text-sm font-medium ${STATUS_CLASSES[status]}`}>
|
||
{STATUS_LABELS[status]}
|
||
</span>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 2: Rewrite AuftragListe**
|
||
|
||
Replace the entire contents of `web/components/AuftragListe.tsx` with:
|
||
|
||
```tsx
|
||
import Link from "next/link";
|
||
import type { Auftrag } from "@/lib/auftraege/queries";
|
||
import { Card } from "@/components/ui/Card";
|
||
import { StatusBadge } from "@/components/ui/StatusBadge";
|
||
|
||
export function AuftragListe({ titel, auftraege }: { titel: string; auftraege: Auftrag[] }) {
|
||
return (
|
||
<section className="mb-8">
|
||
<h2 className="mb-3 text-lg font-semibold text-asphalt-grey">{titel}</h2>
|
||
{auftraege.length === 0 ? (
|
||
<p className="text-asphalt-grey">Keine Aufträge.</p>
|
||
) : (
|
||
<ul className="grid grid-cols-1 gap-3 md:grid-cols-2 lg:grid-cols-3">
|
||
{auftraege.map((auftrag) => (
|
||
<li key={auftrag.id}>
|
||
<Link href={`/auftraege/${auftrag.id}`} className="block">
|
||
<Card className="transition-colors hover:border-performance-blue">
|
||
<div className="mb-2">
|
||
<StatusBadge status={auftrag.status} />
|
||
</div>
|
||
<p className="text-asphalt-grey">
|
||
{auftrag.abholort.adresse} → {auftrag.zielort.adresse}
|
||
</p>
|
||
<p className="mt-1 text-sm text-asphalt-grey">{auftrag.fahrzeug.kennzeichen}</p>
|
||
</Card>
|
||
</Link>
|
||
</li>
|
||
))}
|
||
</ul>
|
||
)}
|
||
</section>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 3: Rewrite the Aufträge-Liste page**
|
||
|
||
Replace the entire contents of `web/app/auftraege/page.tsx` with:
|
||
|
||
```tsx
|
||
import Link from "next/link";
|
||
import { loadProfile } from "@/lib/auth/profile";
|
||
import { listAuftraegeFuerListe } from "@/lib/auftraege/queries";
|
||
import { AuftragListe } from "@/components/AuftragListe";
|
||
import { Alert } from "@/components/ui/Alert";
|
||
import { buttonClasses } from "@/components/ui/Button";
|
||
|
||
export default async function AuftraegePage({
|
||
searchParams,
|
||
}: {
|
||
searchParams: Promise<{ error?: string }>;
|
||
}) {
|
||
const { error } = await searchParams;
|
||
const profileResult = await loadProfile();
|
||
if (profileResult.status !== "ok") {
|
||
return null;
|
||
}
|
||
|
||
const { meine, offene, alle } = await listAuftraegeFuerListe(profileResult.profile);
|
||
const istFahrer = profileResult.profile.role === "fahrer";
|
||
const kannAnlegen = profileResult.profile.role === "admin" || profileResult.profile.role === "disponent";
|
||
|
||
return (
|
||
<main className="mx-auto max-w-5xl p-4 md:p-8">
|
||
<div className="mb-6 flex items-center justify-between">
|
||
<h1 className="text-xl font-semibold text-asphalt-grey">Aufträge</h1>
|
||
{kannAnlegen && (
|
||
<Link href="/auftraege/neu" className={buttonClasses("primary", false)}>
|
||
Neuen Auftrag anlegen
|
||
</Link>
|
||
)}
|
||
</div>
|
||
{error && (
|
||
<div className="mb-6">
|
||
<Alert>{error}</Alert>
|
||
</div>
|
||
)}
|
||
{istFahrer ? (
|
||
<>
|
||
<AuftragListe titel="Meine Aufträge" auftraege={meine} />
|
||
<AuftragListe titel="Offene Aufträge" auftraege={offene} />
|
||
</>
|
||
) : (
|
||
<AuftragListe titel="Alle Aufträge" auftraege={alle} />
|
||
)}
|
||
</main>
|
||
);
|
||
}
|
||
```
|
||
|
||
Note: `<Link>` is styled directly with `buttonClasses(...)` rather than wrapped around a `<Button>` — nesting a `<button>` inside an `<a>` is invalid HTML5 (both are interactive content). This pattern repeats in Task 6.
|
||
|
||
- [ ] **Step 4: Verify the build and tests**
|
||
|
||
```bash
|
||
cd web
|
||
npm run build
|
||
npm test
|
||
```
|
||
|
||
Expected: build exit code 0; `Tests 17 passed (17)`.
|
||
|
||
- [ ] **Step 5: Manually verify**
|
||
|
||
```bash
|
||
cd web
|
||
npm run dev -- -p 3111 &
|
||
sleep 3
|
||
curl -s -c /tmp/cookies.txt -d "email=admin@aushilfsfahrer.local" -d "password=Admin123!" -X POST http://localhost:3111/login -L -o /dev/null
|
||
curl -s -b /tmp/cookies.txt http://localhost:3111/auftraege | grep -o 'Alle Aufträge\|Neuen Auftrag anlegen\|Keine Aufträge'
|
||
kill %1
|
||
rm /tmp/cookies.txt
|
||
```
|
||
|
||
Expected: `Alle Aufträge` and `Neuen Auftrag anlegen` appear (admin sees the "alle" section and the create-link); `Keine Aufträge` appears too if the local dev DB has no seeded orders at this point — that's expected on a fresh `supabase db reset`, not a failure.
|
||
|
||
- [ ] **Step 6: Commit**
|
||
|
||
```bash
|
||
git add web/components/ui/StatusBadge.tsx web/components/AuftragListe.tsx web/app/auftraege/page.tsx
|
||
git commit -m "feat: add StatusBadge and restyle Aufträge list page"
|
||
```
|
||
|
||
---
|
||
|
||
### Task 6: Auftrag-Detail page
|
||
|
||
**Files:**
|
||
- Modify: `web/app/auftraege/[id]/page.tsx` (full rewrite)
|
||
|
||
**Interfaces:**
|
||
- Consumes: `Card`, `Button`, `buttonClasses`, `Alert` from Task 2, `FormField`/`FIELD_CLASSES` from Task 2, `StatusBadge` from Task 5. Does not touch `web/app/auftraege/[id]/actions.ts` — all five Server Actions (`uebernehmen`, `fahrtBeginnen`, `schadenFotoNachtragen`, `fahrtBeenden`, `stornieren`) are consumed exactly as already exported, no signature changes.
|
||
|
||
- [ ] **Step 1: Rewrite the Auftrag-Detail page**
|
||
|
||
Replace the entire contents of `web/app/auftraege/[id]/page.tsx` with:
|
||
|
||
```tsx
|
||
import { notFound } from "next/navigation";
|
||
import Link from "next/link";
|
||
import { loadAuftrag, findeFolgeauftrag } from "@/lib/auftraege/queries";
|
||
import { loadProfile } from "@/lib/auth/profile";
|
||
import { PFLICHT_FOTO_POSITIONEN } from "@/lib/auftraege/foto-positionen";
|
||
import { uebernehmen, fahrtBeginnen, schadenFotoNachtragen, fahrtBeenden, stornieren } from "./actions";
|
||
import { Card } from "@/components/ui/Card";
|
||
import { StatusBadge } from "@/components/ui/StatusBadge";
|
||
import { Button, buttonClasses } from "@/components/ui/Button";
|
||
import { Alert } from "@/components/ui/Alert";
|
||
import { FormField, FIELD_CLASSES } from "@/components/ui/FormField";
|
||
|
||
export default async function AuftragDetailPage({
|
||
params,
|
||
searchParams,
|
||
}: {
|
||
params: Promise<{ id: string }>;
|
||
searchParams: Promise<{ error?: string }>;
|
||
}) {
|
||
const { id } = await params;
|
||
const { error } = await searchParams;
|
||
const [auftrag, profileResult] = await Promise.all([loadAuftrag(id), loadProfile()]);
|
||
|
||
if (!auftrag || profileResult.status !== "ok") {
|
||
notFound();
|
||
}
|
||
|
||
const istEigenerAuftrag = auftrag.zugewiesen_an === profileResult.profile.id;
|
||
// Bewusst eine lokale Rollen-Pruefung statt `canManageUsers` (die ist fuer
|
||
// Nutzerverwaltung gedacht und liefert nur "ist admin"). Laut
|
||
// Rechtematrix duerfen sowohl Admin als auch Disponent stornieren --
|
||
// semantisch getrennte Berechtigung von der Nutzerverwaltung, auch wenn
|
||
// beide aktuell denselben Rollenkreis (admin) ueberschneiden koennten.
|
||
const kannStornieren =
|
||
profileResult.profile.role === "admin" || profileResult.profile.role === "disponent";
|
||
const folgeauftrag = auftrag.status === "abgeschlossen" ? await findeFolgeauftrag(auftrag.id) : null;
|
||
|
||
const uebernehmenAction = uebernehmen.bind(null, auftrag.id);
|
||
const fahrtBeginnenAction = fahrtBeginnen.bind(null, auftrag.id);
|
||
const schadenFotoNachtragenAction = schadenFotoNachtragen.bind(null, auftrag.id);
|
||
const fahrtBeendenAction = fahrtBeenden.bind(null, auftrag.id);
|
||
const stornierenAction = stornieren.bind(null, auftrag.id);
|
||
|
||
return (
|
||
<main className="mx-auto max-w-2xl p-4 md:p-8">
|
||
<Card className="mb-6">
|
||
<div className="mb-2">
|
||
<StatusBadge status={auftrag.status} />
|
||
</div>
|
||
<h1 className="text-xl font-semibold text-asphalt-grey">
|
||
{auftrag.abholort.adresse} → {auftrag.zielort.adresse}
|
||
</h1>
|
||
</Card>
|
||
|
||
{error && (
|
||
<div className="mb-6">
|
||
<Alert>{error}</Alert>
|
||
</div>
|
||
)}
|
||
|
||
<Card className="mb-6">
|
||
<dl className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||
<div>
|
||
<dt className="text-sm text-asphalt-grey/70">Fahrzeug</dt>
|
||
<dd className="text-asphalt-grey">{auftrag.fahrzeug.kennzeichen}</dd>
|
||
</div>
|
||
<div>
|
||
<dt className="text-sm text-asphalt-grey/70">Abholort</dt>
|
||
<dd className="text-asphalt-grey">
|
||
{auftrag.abholort.adresse} ({auftrag.abholort.ansprechpartner})
|
||
</dd>
|
||
</div>
|
||
<div>
|
||
<dt className="text-sm text-asphalt-grey/70">Zielort</dt>
|
||
<dd className="text-asphalt-grey">
|
||
{auftrag.zielort.adresse} ({auftrag.zielort.ansprechpartner})
|
||
</dd>
|
||
</div>
|
||
</dl>
|
||
</Card>
|
||
|
||
{auftrag.status === "offen" && (
|
||
<Card className="mb-6">
|
||
<form action={uebernehmenAction}>
|
||
<Button type="submit">Auftrag übernehmen</Button>
|
||
</form>
|
||
</Card>
|
||
)}
|
||
|
||
{auftrag.status === "zugewiesen" && istEigenerAuftrag && (
|
||
<Card className="mb-6">
|
||
<form action={fahrtBeginnenAction} encType="multipart/form-data">
|
||
<h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Fahrt beginnen</h2>
|
||
<FormField label="KM-Stand" htmlFor="start_km">
|
||
<input id="start_km" name="start_km" type="number" min="0" required className={FIELD_CLASSES} />
|
||
</FormField>
|
||
{PFLICHT_FOTO_POSITIONEN.map((position) => (
|
||
<FormField key={position} label={position.replaceAll("_", " ")} htmlFor={`foto_${position}`}>
|
||
<input
|
||
id={`foto_${position}`}
|
||
name={`foto_${position}`}
|
||
type="file"
|
||
accept="image/*"
|
||
required
|
||
className={FIELD_CLASSES}
|
||
/>
|
||
</FormField>
|
||
))}
|
||
<FormField label="Schadensfotos (optional, mehrere möglich)" htmlFor="foto_schaden">
|
||
<input
|
||
id="foto_schaden"
|
||
name="foto_schaden"
|
||
type="file"
|
||
accept="image/*"
|
||
multiple
|
||
className={FIELD_CLASSES}
|
||
/>
|
||
</FormField>
|
||
<Button type="submit">Fahrt beginnen</Button>
|
||
</form>
|
||
</Card>
|
||
)}
|
||
|
||
{auftrag.status === "unterwegs" && istEigenerAuftrag && (
|
||
<Card className="mb-6">
|
||
<form action={fahrtBeendenAction}>
|
||
<h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Fahrt beenden</h2>
|
||
<FormField label="End-KM-Stand" htmlFor="end_km">
|
||
<input id="end_km" name="end_km" type="number" min="0" required className={FIELD_CLASSES} />
|
||
</FormField>
|
||
<Button type="submit">Übergabe bestätigen</Button>
|
||
</form>
|
||
</Card>
|
||
)}
|
||
|
||
{auftrag.status === "unterwegs" && istEigenerAuftrag && (
|
||
<Card className="mb-6">
|
||
<form action={schadenFotoNachtragenAction} encType="multipart/form-data">
|
||
<h2 className="mb-4 text-lg font-semibold text-asphalt-grey">Schadensfoto nachtragen</h2>
|
||
<FormField label="Schadensfotos (mehrere möglich)" htmlFor="foto_schaden_nachtrag">
|
||
<input
|
||
id="foto_schaden_nachtrag"
|
||
name="foto_schaden"
|
||
type="file"
|
||
accept="image/*"
|
||
multiple
|
||
required
|
||
className={FIELD_CLASSES}
|
||
/>
|
||
</FormField>
|
||
<Button type="submit">Foto nachtragen</Button>
|
||
</form>
|
||
</Card>
|
||
)}
|
||
|
||
{auftrag.status === "abgeschlossen" && folgeauftrag && (
|
||
<Card className="mb-6">
|
||
<p className="text-asphalt-grey">
|
||
Anschlussauftrag verfügbar:{" "}
|
||
<Link href={`/auftraege/${folgeauftrag.id}`} className={buttonClasses("primary", false)}>
|
||
Jetzt übernehmen
|
||
</Link>
|
||
</p>
|
||
</Card>
|
||
)}
|
||
|
||
{kannStornieren && auftrag.status !== "abgeschlossen" && auftrag.status !== "storniert" && (
|
||
<Card>
|
||
<form action={stornierenAction}>
|
||
<Button type="submit" variant="destructive">
|
||
Auftrag stornieren
|
||
</Button>
|
||
</form>
|
||
</Card>
|
||
)}
|
||
</main>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 2: Verify the build and tests**
|
||
|
||
```bash
|
||
cd web
|
||
npm run build
|
||
npm test
|
||
```
|
||
|
||
Expected: build exit code 0; `Tests 17 passed (17)`.
|
||
|
||
- [ ] **Step 3: Manually verify against a real order**
|
||
|
||
This page's forms are status-conditional, so a meaningful check needs at least one real `auftraege` row. Reuse the seed-data approach already used for this project's local dev/master-stack verification (insert a row directly via `docker exec -i <db-container> psql`, or use the existing `orte`/`fahrzeuge` sample rows if present from prior manual testing) — then:
|
||
|
||
```bash
|
||
cd web
|
||
npm run dev -- -p 3111 &
|
||
sleep 3
|
||
curl -s -c /tmp/cookies.txt -d "email=admin@aushilfsfahrer.local" -d "password=Admin123!" -X POST http://localhost:3111/login -L -o /dev/null
|
||
curl -s -b /tmp/cookies.txt "http://localhost:3111/auftraege/<a-real-auftrag-id>" | grep -o 'Auftrag übernehmen\|Fahrt beginnen\|Fahrt beenden\|Auftrag stornieren' | sort -u
|
||
kill %1
|
||
rm /tmp/cookies.txt
|
||
```
|
||
|
||
Expected: exactly the form(s) matching that order's current `status` appear (e.g. an `offen` order shows only `Auftrag übernehmen`; do not expect all four to appear simultaneously — they are mutually exclusive by status).
|
||
|
||
- [ ] **Step 4: Commit**
|
||
|
||
```bash
|
||
git add "web/app/auftraege/[id]/page.tsx"
|
||
git commit -m "feat: restyle Auftrag detail page"
|
||
```
|
||
|
||
---
|
||
|
||
### Task 7: Auftrag-anlegen page
|
||
|
||
**Files:**
|
||
- Modify: `web/app/auftraege/neu/page.tsx` (full rewrite)
|
||
|
||
**Interfaces:**
|
||
- Consumes: `Card`, `Button`, `Alert` from Task 2, `FormField`/`FIELD_CLASSES` from Task 2. Does not touch `web/app/auftraege/neu/actions.ts`.
|
||
|
||
- [ ] **Step 1: Rewrite the Auftrag-anlegen page**
|
||
|
||
Replace the entire contents of `web/app/auftraege/neu/page.tsx` with:
|
||
|
||
```tsx
|
||
import { redirect } from "next/navigation";
|
||
import { createAuftrag } from "./actions";
|
||
import { listOrte, listFahrzeuge } from "@/lib/auftraege/queries";
|
||
import { loadProfile } from "@/lib/auth/profile";
|
||
import { Card } from "@/components/ui/Card";
|
||
import { Button } from "@/components/ui/Button";
|
||
import { Alert } from "@/components/ui/Alert";
|
||
import { FormField, FIELD_CLASSES } from "@/components/ui/FormField";
|
||
|
||
export default async function NeuerAuftragPage({
|
||
searchParams,
|
||
}: {
|
||
searchParams: Promise<{ error?: string; vorgaenger_auftrag_id?: string }>;
|
||
}) {
|
||
const profileResult = await loadProfile();
|
||
// Seitenebenen-Gate zusaetzlich zur INSERT-RLS-Policy auf `auftraege`
|
||
// (admin/disponent-only): ohne diesen Check wuerde die Seite das Formular
|
||
// auch Fahrern/Readonly anzeigen, obwohl ein Submit dann ohnehin an der
|
||
// RLS-Policy scheitern wuerde -- das ist verwirrende UX statt eines echten
|
||
// Sicherheitslecks, aber ein frueher Redirect ist die klarere Loesung.
|
||
if (
|
||
profileResult.status !== "ok" ||
|
||
(profileResult.profile.role !== "admin" && profileResult.profile.role !== "disponent")
|
||
) {
|
||
redirect(`/auftraege?error=${encodeURIComponent("Nur Disponent/Admin duerfen Auftraege anlegen.")}`);
|
||
}
|
||
|
||
const { error, vorgaenger_auftrag_id } = await searchParams;
|
||
const [orte, fahrzeuge] = await Promise.all([listOrte(), listFahrzeuge()]);
|
||
|
||
return (
|
||
<main className="mx-auto max-w-xl p-4 md:p-8">
|
||
<h1 className="mb-6 text-xl font-semibold text-asphalt-grey">Neuen Auftrag anlegen</h1>
|
||
{error && (
|
||
<div className="mb-6">
|
||
<Alert>{error}</Alert>
|
||
</div>
|
||
)}
|
||
<Card>
|
||
<form action={createAuftrag}>
|
||
{vorgaenger_auftrag_id && (
|
||
<input type="hidden" name="vorgaenger_auftrag_id" value={vorgaenger_auftrag_id} />
|
||
)}
|
||
<FormField label="Abholort" htmlFor="abholort_id">
|
||
<select id="abholort_id" name="abholort_id" required defaultValue="" className={FIELD_CLASSES}>
|
||
<option value="" disabled>
|
||
Bitte waehlen
|
||
</option>
|
||
{orte.map((ort) => (
|
||
<option key={ort.id} value={ort.id}>
|
||
{ort.adresse} ({ort.ansprechpartner})
|
||
</option>
|
||
))}
|
||
</select>
|
||
</FormField>
|
||
<FormField label="Zielort" htmlFor="zielort_id">
|
||
<select id="zielort_id" name="zielort_id" required defaultValue="" className={FIELD_CLASSES}>
|
||
<option value="" disabled>
|
||
Bitte waehlen
|
||
</option>
|
||
{orte.map((ort) => (
|
||
<option key={ort.id} value={ort.id}>
|
||
{ort.adresse} ({ort.ansprechpartner})
|
||
</option>
|
||
))}
|
||
</select>
|
||
</FormField>
|
||
<FormField label="Fahrzeug" htmlFor="fahrzeug_id">
|
||
<select id="fahrzeug_id" name="fahrzeug_id" required defaultValue="" className={FIELD_CLASSES}>
|
||
<option value="" disabled>
|
||
Bitte waehlen
|
||
</option>
|
||
{fahrzeuge.map((fahrzeug) => (
|
||
<option key={fahrzeug.id} value={fahrzeug.id}>
|
||
{fahrzeug.kennzeichen}
|
||
</option>
|
||
))}
|
||
</select>
|
||
</FormField>
|
||
<Button type="submit">Auftrag anlegen</Button>
|
||
</form>
|
||
</Card>
|
||
</main>
|
||
);
|
||
}
|
||
```
|
||
|
||
- [ ] **Step 2: Verify the build and tests**
|
||
|
||
```bash
|
||
cd web
|
||
npm run build
|
||
npm test
|
||
```
|
||
|
||
Expected: build exit code 0; `Tests 17 passed (17)`.
|
||
|
||
- [ ] **Step 3: Manually verify**
|
||
|
||
```bash
|
||
cd web
|
||
npm run dev -- -p 3111 &
|
||
sleep 3
|
||
curl -s -c /tmp/cookies.txt -d "email=admin@aushilfsfahrer.local" -d "password=Admin123!" -X POST http://localhost:3111/login -L -o /dev/null
|
||
curl -s -b /tmp/cookies.txt http://localhost:3111/auftraege/neu | grep -o 'Abholort\|Zielort\|Fahrzeug\|Auftrag anlegen'
|
||
kill %1
|
||
rm /tmp/cookies.txt
|
||
```
|
||
|
||
Expected: all four labels appear.
|
||
|
||
- [ ] **Step 4: Commit**
|
||
|
||
```bash
|
||
git add web/app/auftraege/neu/page.tsx
|
||
git commit -m "feat: restyle Auftrag-anlegen page"
|
||
```
|
||
|
||
---
|
||
|
||
## After all tasks
|
||
|
||
Once all 7 tasks are committed and reviewed, this branch is a pure presentation-layer change with no schema/RLS/Server-Action modifications — the final whole-branch review can be lighter-weight than the Auftragsverwaltung branch's (no new attack surface to probe), focused on: visual/structural consistency across pages, no accidental logic changes in any `actions.ts` or `lib/` file (diff those files first — they should show zero changes), and `npm run build`/`npm test` green on the full accumulated diff. The project owner will do the final cross-breakpoint visual check themselves in the rebuilt Docker container (`docker compose build web && docker compose up -d web`, per the existing project convention already used after the Auftragsverwaltung merge).
|