Archived
UI/Routing - Tab + Route: /puls → /dashboard, Heading „Unternehmens-Puls" → „Dashboard" - Shortcut: g p → g d (Cheatsheet entsprechend) - Breadcrumbs, 404-Hinweistext, alle internen Links angepasst Code-Layout - apps/web/src/routes/puls.tsx → dashboard.tsx (Komponente DashboardRoute) - apps/api/src/routers/puls.ts → dashboard.ts (dashboardRouter) - tRPC-Aufrufe: trpc.puls.* / utils.puls.* → trpc.dashboard.* / utils.dashboard.* - Auth-Redirects (/api/auth/login, /callback, dev-login) zeigen jetzt auf /dashboard Projekt-Beschreibung - Migration 0007_project_description: project.description text (nullable) - Shared Zod: ProjectSchemas.createProjectInput.description (max 2000, optional) - Backend: project.create mappt input.description - Frontend Dialog „Neues Projekt": Textarea (3 Zeilen, optional) - Projekt-Detail: zeigt Beschreibung als whitespace-pre-wrap unter Subtitle README - Routen-Tabelle, Shortcut-Liste, Verzeichnis-Baum, DB-Tabellen, Migration-Range, Frontend-Routenliste aktualisiert Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
237 lines
8.7 KiB
TypeScript
237 lines
8.7 KiB
TypeScript
import { useState } from 'react';
|
||
import { useParams, Link, useNavigate } from 'react-router';
|
||
import { ArrowLeft } from 'lucide-react';
|
||
import { trpc } from '../lib/trpc';
|
||
import { Card } from '../components/ui/Card';
|
||
import { Button } from '../components/ui/Button';
|
||
import { SkeletonCard } from '../components/ui/SkeletonCard';
|
||
import { useCurrentUser } from '../hooks/useCurrentUser';
|
||
import { voice } from '../lib/voice';
|
||
import { toast } from 'sonner';
|
||
import { clsx } from 'clsx';
|
||
|
||
export function ProjektRoute() {
|
||
const { id = '' } = useParams<{ id: string }>();
|
||
const me = useCurrentUser();
|
||
const navigate = useNavigate();
|
||
const q = trpc.project.byId.useQuery({ id });
|
||
const [abschlussOpen, setAbschlussOpen] = useState(false);
|
||
if (q.isPending) return <SkeletonCard lines={6} />;
|
||
if (!q.data) return null;
|
||
const { project: p, area: a, milestones } = q.data;
|
||
const isP1 = me?.id === p.verantwortlicheUserId;
|
||
const pflichtKeys: Array<{ key: string; label: string }> = [
|
||
{ key: 'steckbrief_freigegeben', label: 'Steckbrief in Outline freigegeben' },
|
||
{ key: 'verantwortlicher', label: 'Projektverantwortliche/r gesetzt' },
|
||
{ key: 'plane_board', label: 'Plane-Board verlinkt' },
|
||
{ key: 'meilensteine', label: 'Meilensteine vorhanden' },
|
||
{ key: 'status_aktuell', label: 'Status-Ampel aktuell (≤ 7 Werktage)' },
|
||
{ key: 'retrospektive', label: 'Abschluss-Retrospektive (bei beendeten Projekten)' },
|
||
];
|
||
|
||
function goBack() {
|
||
// Wenn der History-Stack einen Vorgänger hat, dorthin; sonst auf den Bereich.
|
||
if (window.history.length > 1) navigate(-1);
|
||
else navigate(`/bereich/${a.slug}`);
|
||
}
|
||
|
||
return (
|
||
<div className="space-y-6">
|
||
<header>
|
||
<div className="flex items-center gap-3">
|
||
<button
|
||
type="button"
|
||
onClick={goBack}
|
||
aria-label="Zurück"
|
||
className="inline-flex h-8 w-8 items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] text-[var(--color-ink-muted)] hover:border-[var(--color-ink)] hover:text-[var(--color-ink)]"
|
||
>
|
||
<ArrowLeft size={16} />
|
||
</button>
|
||
<p className="text-sm text-[var(--color-ink-muted)]">
|
||
<Link to="/dashboard" className="hover:underline">
|
||
Dashboard
|
||
</Link>
|
||
{' › '}
|
||
<Link to={`/bereich/${a.slug}`} className="hover:underline">
|
||
{a.name}
|
||
</Link>
|
||
</p>
|
||
</div>
|
||
<div className="mt-2 flex items-start justify-between gap-4">
|
||
<h1 className="text-3xl font-bold">{p.name}</h1>
|
||
{isP1 && !p.archiviert && (
|
||
<Button variant="secondary" onClick={() => setAbschlussOpen(true)}>
|
||
Projekt abschließen
|
||
</Button>
|
||
)}
|
||
{p.archiviert && (
|
||
<span className="rounded-full bg-black/5 px-2.5 py-1 text-xs">archiviert</span>
|
||
)}
|
||
</div>
|
||
<p className="text-[var(--color-ink-muted)]">
|
||
{p.kind === 'kundenprojekt' ? 'Kundenprojekt' : 'Internes Projekt'} ·{' '}
|
||
{p.arbeitsmodus ?? '—'} · {p.deadline ? `Deadline ${p.deadline}` : 'kein Deadline'}
|
||
</p>
|
||
{p.description && (
|
||
<p className="mt-3 max-w-2xl whitespace-pre-wrap text-sm text-[var(--color-ink)]">
|
||
{p.description}
|
||
</p>
|
||
)}
|
||
</header>
|
||
|
||
{abschlussOpen && (
|
||
<AbschlussDialog projectId={p.id} onClose={() => setAbschlussOpen(false)} />
|
||
)}
|
||
|
||
<section className="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||
<Card.Root>
|
||
<Card.Header>
|
||
<h2 className="text-lg font-semibold">Verlinkungen</h2>
|
||
</Card.Header>
|
||
<Card.Body className="space-y-2 text-sm">
|
||
<LinkRow label="Outline-Steckbrief" url={p.outlineSteckbriefUrl} />
|
||
<LinkRow label="Plane-Board" url={p.planeProjectUrl} />
|
||
<LinkRow label="Risikoliste" url={p.risikolisteUrl} />
|
||
<LinkRow label="Lessons Learned" url={p.lessonsLearnedUrl} />
|
||
</Card.Body>
|
||
</Card.Root>
|
||
|
||
<Card.Root>
|
||
<Card.Header>
|
||
<h2 className="text-lg font-semibold">Pflicht-Minimum</h2>
|
||
</Card.Header>
|
||
<Card.Body>
|
||
<ul className="space-y-2 text-sm">
|
||
{pflichtKeys.map(({ key, label }) => {
|
||
const ok = p.pflichtMinimumState[key] === true;
|
||
return (
|
||
<li key={key} className="flex items-center gap-2">
|
||
<span
|
||
className={clsx(
|
||
'inline-block h-2.5 w-2.5 rounded-full',
|
||
ok ? 'bg-[var(--color-ampel-green-fg)]' : 'bg-[var(--color-border-strong)]',
|
||
)}
|
||
/>
|
||
<span className={ok ? '' : 'text-[var(--color-ink-muted)]'}>{label}</span>
|
||
</li>
|
||
);
|
||
})}
|
||
</ul>
|
||
</Card.Body>
|
||
</Card.Root>
|
||
</section>
|
||
|
||
<section>
|
||
<h2 className="mb-2 text-lg font-semibold">Meilensteine</h2>
|
||
{milestones.length === 0 ? (
|
||
<Card.Root>
|
||
<Card.Body>
|
||
<p className="text-sm text-[var(--color-ink-muted)]">Noch keine Meilensteine.</p>
|
||
</Card.Body>
|
||
</Card.Root>
|
||
) : (
|
||
<Card.Root>
|
||
<Card.Body>
|
||
<ul className="space-y-2 text-sm">
|
||
{milestones.map((m) => (
|
||
<li key={m.id} className="flex items-center justify-between">
|
||
<span
|
||
className={clsx(
|
||
m.status === 'done' && 'line-through text-[var(--color-ink-muted)]',
|
||
)}
|
||
>
|
||
{m.title}
|
||
</span>
|
||
<span className="text-xs text-[var(--color-ink-muted)]">
|
||
{m.due ?? '—'} · {m.status}
|
||
</span>
|
||
</li>
|
||
))}
|
||
</ul>
|
||
</Card.Body>
|
||
</Card.Root>
|
||
)}
|
||
</section>
|
||
|
||
{p.dodText && (
|
||
<Card.Root>
|
||
<Card.Header>
|
||
<h2 className="text-lg font-semibold">Definition of Done</h2>
|
||
</Card.Header>
|
||
<Card.Body>
|
||
<p className="whitespace-pre-wrap text-sm">{p.dodText}</p>
|
||
</Card.Body>
|
||
</Card.Root>
|
||
)}
|
||
</div>
|
||
);
|
||
}
|
||
|
||
function AbschlussDialog({ projectId, onClose }: { projectId: string; onClose: () => void }) {
|
||
const [url, setUrl] = useState('');
|
||
const navigate = useNavigate();
|
||
const utils = trpc.useUtils();
|
||
const mutation = trpc.project.archive.useMutation({
|
||
onSuccess: async () => {
|
||
toast(voice.toast.projectArchived);
|
||
await utils.project.byId.invalidate({ id: projectId });
|
||
await utils.project.listArchived.invalidate();
|
||
await utils.dashboard.overview.invalidate();
|
||
navigate('/archiv');
|
||
},
|
||
});
|
||
function submit(e: React.FormEvent) {
|
||
e.preventDefault();
|
||
mutation.mutate({ projectId, lessonsLearnedUrl: url });
|
||
}
|
||
return (
|
||
<div
|
||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/30"
|
||
onClick={onClose}
|
||
>
|
||
<div
|
||
className="w-full max-w-md rounded-[var(--radius-xl)] bg-[var(--color-bg)] p-6 shadow-[var(--shadow-lg)]"
|
||
onClick={(e) => e.stopPropagation()}
|
||
>
|
||
<h2 className="text-xl font-semibold">Projekt abschließen</h2>
|
||
<p className="mt-1 text-sm text-[var(--color-ink-muted)]">
|
||
Lessons-Learned-URL ist Pflicht (Leitfaden §9 Punkt 6).
|
||
</p>
|
||
<form onSubmit={submit} className="mt-4 space-y-3">
|
||
<input
|
||
required
|
||
type="url"
|
||
value={url}
|
||
onChange={(e) => setUrl(e.target.value)}
|
||
placeholder="https://outline.tool-ctrl.de/lessons-learned/..."
|
||
className="w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-white px-3 py-2 text-sm"
|
||
/>
|
||
<div className="flex justify-end gap-2">
|
||
<Button type="button" variant="ghost" onClick={onClose}>
|
||
Abbrechen
|
||
</Button>
|
||
<Button type="submit" disabled={mutation.isPending}>
|
||
Abschließen
|
||
</Button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
function LinkRow({ label, url }: { label: string; url: string | null }) {
|
||
return (
|
||
<p className="flex items-center justify-between">
|
||
<span className="text-[var(--color-ink-muted)]">{label}</span>
|
||
{url ? (
|
||
<a href={url} target="_blank" rel="noreferrer" className="truncate hover:underline">
|
||
{url}
|
||
</a>
|
||
) : (
|
||
<span className="text-[var(--color-ink-faint)]">—</span>
|
||
)}
|
||
</p>
|
||
);
|
||
}
|