Compare commits
1 Commits
mai/knuth/
...
mai/ritchi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a56d4cf11 |
267
frontend/src/app/(app)/cases/[id]/page.tsx
Normal file
267
frontend/src/app/(app)/cases/[id]/page.tsx
Normal file
@@ -0,0 +1,267 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useParams } from "next/navigation";
|
||||
import { api } from "@/lib/api";
|
||||
import type { Case, CaseEvent, Party, Deadline, Document } from "@/lib/types";
|
||||
import { CaseTimeline } from "@/components/cases/CaseTimeline";
|
||||
import { PartyList } from "@/components/cases/PartyList";
|
||||
import { ArrowLeft, Clock, FileText, Users, Activity } from "lucide-react";
|
||||
import { format } from "date-fns";
|
||||
import { de } from "date-fns/locale";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
|
||||
interface CaseDetail extends Case {
|
||||
parties: Party[];
|
||||
recent_events: CaseEvent[];
|
||||
deadlines_count: number;
|
||||
}
|
||||
|
||||
const STATUS_BADGE: Record<string, string> = {
|
||||
active: "bg-emerald-50 text-emerald-700",
|
||||
pending: "bg-amber-50 text-amber-700",
|
||||
closed: "bg-neutral-100 text-neutral-600",
|
||||
archived: "bg-neutral-100 text-neutral-400",
|
||||
};
|
||||
|
||||
const TABS = [
|
||||
{ key: "timeline", label: "Verlauf", icon: Activity },
|
||||
{ key: "deadlines", label: "Fristen", icon: Clock },
|
||||
{ key: "documents", label: "Dokumente", icon: FileText },
|
||||
{ key: "parties", label: "Parteien", icon: Users },
|
||||
] as const;
|
||||
|
||||
type TabKey = (typeof TABS)[number]["key"];
|
||||
|
||||
export default function CaseDetailPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const [activeTab, setActiveTab] = useState<TabKey>("timeline");
|
||||
|
||||
const { data: caseDetail, isLoading } = useQuery({
|
||||
queryKey: ["case", id],
|
||||
queryFn: () => api.get<CaseDetail>(`/cases/${id}`),
|
||||
});
|
||||
|
||||
const { data: deadlinesData } = useQuery({
|
||||
queryKey: ["case-deadlines", id],
|
||||
queryFn: () =>
|
||||
api.get<{ deadlines: Deadline[]; total: number }>(
|
||||
`/deadlines?case_id=${id}`,
|
||||
),
|
||||
enabled: activeTab === "deadlines",
|
||||
});
|
||||
|
||||
const { data: documentsData } = useQuery({
|
||||
queryKey: ["case-documents", id],
|
||||
queryFn: () => api.get<Document[]>(`/cases/${id}/documents`),
|
||||
enabled: activeTab === "documents",
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="py-12 text-center text-sm text-neutral-400">
|
||||
Laden...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!caseDetail) {
|
||||
return (
|
||||
<div className="py-12 text-center text-sm text-neutral-400">
|
||||
Akte nicht gefunden.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const deadlines = deadlinesData?.deadlines ?? [];
|
||||
const documents = documentsData ?? [];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Link
|
||||
href="/cases"
|
||||
className="mb-4 inline-flex items-center gap-1 text-sm text-neutral-500 hover:text-neutral-700"
|
||||
>
|
||||
<ArrowLeft className="h-3.5 w-3.5" />
|
||||
Zuruck zu Akten
|
||||
</Link>
|
||||
|
||||
<div className="flex items-start justify-between">
|
||||
<div>
|
||||
<div className="flex items-center gap-3">
|
||||
<h1 className="text-lg font-semibold text-neutral-900">
|
||||
{caseDetail.title}
|
||||
</h1>
|
||||
<span
|
||||
className={`inline-block rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_BADGE[caseDetail.status] ?? "bg-neutral-100 text-neutral-500"}`}
|
||||
>
|
||||
{caseDetail.status}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-1 flex gap-4 text-sm text-neutral-500">
|
||||
<span>Az. {caseDetail.case_number}</span>
|
||||
{caseDetail.case_type && <span>{caseDetail.case_type}</span>}
|
||||
{caseDetail.court && <span>{caseDetail.court}</span>}
|
||||
{caseDetail.court_ref && <span>({caseDetail.court_ref})</span>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right text-xs text-neutral-400">
|
||||
<p>
|
||||
Erstellt:{" "}
|
||||
{format(new Date(caseDetail.created_at), "d. MMM yyyy", {
|
||||
locale: de,
|
||||
})}
|
||||
</p>
|
||||
<p>
|
||||
Aktualisiert:{" "}
|
||||
{format(new Date(caseDetail.updated_at), "d. MMM yyyy", {
|
||||
locale: de,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{caseDetail.ai_summary && (
|
||||
<div className="mt-4 rounded-md border border-blue-100 bg-blue-50 px-4 py-3 text-sm text-blue-800">
|
||||
{caseDetail.ai_summary}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="mt-6 border-b border-neutral-200">
|
||||
<nav className="-mb-px flex gap-4">
|
||||
{TABS.map((tab) => (
|
||||
<button
|
||||
key={tab.key}
|
||||
onClick={() => setActiveTab(tab.key)}
|
||||
className={`inline-flex items-center gap-1.5 border-b-2 px-1 pb-2.5 text-sm font-medium transition-colors ${
|
||||
activeTab === tab.key
|
||||
? "border-neutral-900 text-neutral-900"
|
||||
: "border-transparent text-neutral-400 hover:text-neutral-600"
|
||||
}`}
|
||||
>
|
||||
<tab.icon className="h-4 w-4" />
|
||||
{tab.label}
|
||||
{tab.key === "deadlines" && caseDetail.deadlines_count > 0 && (
|
||||
<span className="ml-1 rounded-full bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-500">
|
||||
{caseDetail.deadlines_count}
|
||||
</span>
|
||||
)}
|
||||
{tab.key === "parties" && caseDetail.parties.length > 0 && (
|
||||
<span className="ml-1 rounded-full bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-500">
|
||||
{caseDetail.parties.length}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div className="mt-6">
|
||||
{activeTab === "timeline" && (
|
||||
<CaseTimeline events={caseDetail.recent_events ?? []} />
|
||||
)}
|
||||
|
||||
{activeTab === "deadlines" && (
|
||||
<DeadlinesList deadlines={deadlines} />
|
||||
)}
|
||||
|
||||
{activeTab === "documents" && (
|
||||
<DocumentsList documents={documents} />
|
||||
)}
|
||||
|
||||
{activeTab === "parties" && (
|
||||
<PartyList caseId={id} parties={caseDetail.parties ?? []} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DeadlinesList({ deadlines }: { deadlines: Deadline[] }) {
|
||||
if (deadlines.length === 0) {
|
||||
return (
|
||||
<p className="py-8 text-center text-sm text-neutral-400">
|
||||
Keine Fristen vorhanden.
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
const DEADLINE_STATUS: Record<string, string> = {
|
||||
pending: "bg-amber-50 text-amber-700",
|
||||
completed: "bg-emerald-50 text-emerald-700",
|
||||
overdue: "bg-red-50 text-red-700",
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{deadlines.map((d) => (
|
||||
<div
|
||||
key={d.id}
|
||||
className="flex items-center justify-between rounded-md border border-neutral-200 bg-white px-4 py-3"
|
||||
>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-neutral-900">{d.title}</p>
|
||||
{d.description && (
|
||||
<p className="mt-0.5 text-sm text-neutral-500">
|
||||
{d.description}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<span
|
||||
className={`rounded-full px-2 py-0.5 text-xs font-medium ${DEADLINE_STATUS[d.status] ?? "bg-neutral-100 text-neutral-500"}`}
|
||||
>
|
||||
{d.status}
|
||||
</span>
|
||||
<span className="text-sm text-neutral-500">
|
||||
{format(new Date(d.due_date), "d. MMM yyyy", { locale: de })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DocumentsList({ documents }: { documents: Document[] }) {
|
||||
if (documents.length === 0) {
|
||||
return (
|
||||
<p className="py-8 text-center text-sm text-neutral-400">
|
||||
Keine Dokumente vorhanden.
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{documents.map((doc) => (
|
||||
<div
|
||||
key={doc.id}
|
||||
className="flex items-center justify-between rounded-md border border-neutral-200 bg-white px-4 py-3"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<FileText className="h-4 w-4 text-neutral-400" />
|
||||
<div>
|
||||
<p className="text-sm font-medium text-neutral-900">
|
||||
{doc.title}
|
||||
</p>
|
||||
<div className="flex gap-2 text-xs text-neutral-400">
|
||||
{doc.doc_type && <span>{doc.doc_type}</span>}
|
||||
{doc.file_size && (
|
||||
<span>{(doc.file_size / 1024).toFixed(0)} KB</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a
|
||||
href={`/api/documents/${doc.id}`}
|
||||
className="text-sm text-neutral-500 hover:text-neutral-700"
|
||||
>
|
||||
Herunterladen
|
||||
</a>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
49
frontend/src/app/(app)/cases/new/page.tsx
Normal file
49
frontend/src/app/(app)/cases/new/page.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { toast } from "sonner";
|
||||
import { api } from "@/lib/api";
|
||||
import type { Case } from "@/lib/types";
|
||||
import { CaseForm, type CaseFormData } from "@/components/cases/CaseForm";
|
||||
import { ArrowLeft } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function NewCasePage() {
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: (data: CaseFormData) => api.post<Case>("/cases", data),
|
||||
onSuccess: (created) => {
|
||||
queryClient.invalidateQueries({ queryKey: ["cases"] });
|
||||
toast.success("Akte angelegt");
|
||||
router.push(`/cases/${created.id}`);
|
||||
},
|
||||
onError: () => {
|
||||
toast.error("Fehler beim Anlegen der Akte");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-2xl">
|
||||
<Link
|
||||
href="/cases"
|
||||
className="mb-4 inline-flex items-center gap-1 text-sm text-neutral-500 hover:text-neutral-700"
|
||||
>
|
||||
<ArrowLeft className="h-3.5 w-3.5" />
|
||||
Zuruck zu Akten
|
||||
</Link>
|
||||
<h1 className="text-lg font-semibold text-neutral-900">Neue Akte</h1>
|
||||
<p className="mt-0.5 text-sm text-neutral-500">
|
||||
Neue Akte im System anlegen
|
||||
</p>
|
||||
<div className="mt-6 rounded-md border border-neutral-200 bg-white p-6">
|
||||
<CaseForm
|
||||
onSubmit={(data) => mutation.mutate(data)}
|
||||
isSubmitting={mutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
172
frontend/src/app/(app)/cases/page.tsx
Normal file
172
frontend/src/app/(app)/cases/page.tsx
Normal file
@@ -0,0 +1,172 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { api } from "@/lib/api";
|
||||
import type { Case } from "@/lib/types";
|
||||
import Link from "next/link";
|
||||
import { useSearchParams, useRouter } from "next/navigation";
|
||||
import { Plus, Search } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ value: "", label: "Alle Status" },
|
||||
{ value: "active", label: "Aktiv" },
|
||||
{ value: "pending", label: "Anhangig" },
|
||||
{ value: "closed", label: "Geschlossen" },
|
||||
{ value: "archived", label: "Archiviert" },
|
||||
];
|
||||
|
||||
const TYPE_OPTIONS = [
|
||||
{ value: "", label: "Alle Typen" },
|
||||
{ value: "INF", label: "Verletzungsklage" },
|
||||
{ value: "REV", label: "Widerruf" },
|
||||
{ value: "CCR", label: "Einstweilige Verfugung" },
|
||||
{ value: "APP", label: "Berufung" },
|
||||
{ value: "PI", label: "Vorlaufiger Rechtsschutz" },
|
||||
{ value: "ZPO_CIVIL", label: "ZPO Zivilverfahren" },
|
||||
];
|
||||
|
||||
const STATUS_BADGE: Record<string, string> = {
|
||||
active: "bg-emerald-50 text-emerald-700",
|
||||
pending: "bg-amber-50 text-amber-700",
|
||||
closed: "bg-neutral-100 text-neutral-600",
|
||||
archived: "bg-neutral-100 text-neutral-400",
|
||||
};
|
||||
|
||||
export default function CasesPage() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const [search, setSearch] = useState(searchParams.get("search") ?? "");
|
||||
const [status, setStatus] = useState(searchParams.get("status") ?? "");
|
||||
const [type, setType] = useState(searchParams.get("type") ?? "");
|
||||
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ["cases", { search, status, type }],
|
||||
queryFn: () => {
|
||||
const params = new URLSearchParams();
|
||||
if (search) params.set("search", search);
|
||||
if (status) params.set("status", status);
|
||||
if (type) params.set("type", type);
|
||||
params.set("limit", "50");
|
||||
const qs = params.toString();
|
||||
return api.get<{ cases: Case[]; total: number }>(
|
||||
`/cases${qs ? `?${qs}` : ""}`,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
const cases = data?.cases ?? [];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold text-neutral-900">Akten</h1>
|
||||
<p className="mt-0.5 text-sm text-neutral-500">
|
||||
{data ? `${data.total} Akten` : "Laden..."}
|
||||
</p>
|
||||
</div>
|
||||
<Link
|
||||
href="/cases/new"
|
||||
className="inline-flex items-center gap-1.5 rounded-md bg-neutral-900 px-3 py-1.5 text-sm font-medium text-white hover:bg-neutral-800"
|
||||
>
|
||||
<Plus className="h-4 w-4" />
|
||||
Neue Akte
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 flex items-center gap-3">
|
||||
<div className="relative flex-1">
|
||||
<Search className="absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-neutral-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Suchen nach Aktenzeichen, Titel..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="w-full rounded-md border border-neutral-200 bg-white py-1.5 pl-9 pr-3 text-sm outline-none focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400"
|
||||
/>
|
||||
</div>
|
||||
<select
|
||||
value={status}
|
||||
onChange={(e) => setStatus(e.target.value)}
|
||||
className="rounded-md border border-neutral-200 bg-white px-2.5 py-1.5 text-sm outline-none focus:border-neutral-400"
|
||||
>
|
||||
{STATUS_OPTIONS.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<select
|
||||
value={type}
|
||||
onChange={(e) => setType(e.target.value)}
|
||||
className="rounded-md border border-neutral-200 bg-white px-2.5 py-1.5 text-sm outline-none focus:border-neutral-400"
|
||||
>
|
||||
{TYPE_OPTIONS.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="mt-4">
|
||||
{isLoading ? (
|
||||
<div className="py-12 text-center text-sm text-neutral-400">
|
||||
Laden...
|
||||
</div>
|
||||
) : cases.length === 0 ? (
|
||||
<div className="py-12 text-center text-sm text-neutral-400">
|
||||
Keine Akten gefunden.
|
||||
</div>
|
||||
) : (
|
||||
<div className="overflow-hidden rounded-md border border-neutral-200 bg-white">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-neutral-100 text-left text-xs font-medium uppercase tracking-wider text-neutral-400">
|
||||
<th className="px-4 py-2.5">Aktenzeichen</th>
|
||||
<th className="px-4 py-2.5">Titel</th>
|
||||
<th className="px-4 py-2.5">Typ</th>
|
||||
<th className="px-4 py-2.5">Gericht</th>
|
||||
<th className="px-4 py-2.5">Status</th>
|
||||
<th className="px-4 py-2.5">Erstellt</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-neutral-100">
|
||||
{cases.map((c) => (
|
||||
<tr
|
||||
key={c.id}
|
||||
onClick={() => router.push(`/cases/${c.id}`)}
|
||||
className="cursor-pointer hover:bg-neutral-50"
|
||||
>
|
||||
<td className="px-4 py-2.5 font-medium text-neutral-900">
|
||||
{c.case_number}
|
||||
</td>
|
||||
<td className="px-4 py-2.5 text-neutral-700">{c.title}</td>
|
||||
<td className="px-4 py-2.5 text-neutral-500">
|
||||
{c.case_type ?? "-"}
|
||||
</td>
|
||||
<td className="px-4 py-2.5 text-neutral-500">
|
||||
{c.court ?? "-"}
|
||||
</td>
|
||||
<td className="px-4 py-2.5">
|
||||
<span
|
||||
className={`inline-block rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_BADGE[c.status] ?? "bg-neutral-100 text-neutral-500"}`}
|
||||
>
|
||||
{c.status}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-4 py-2.5 text-neutral-400">
|
||||
{new Date(c.created_at).toLocaleDateString("de-DE")}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { api } from "@/lib/api";
|
||||
import type { DashboardData } from "@/lib/types";
|
||||
import { DeadlineTrafficLights } from "@/components/dashboard/DeadlineTrafficLights";
|
||||
import { CaseOverviewGrid } from "@/components/dashboard/CaseOverviewGrid";
|
||||
import { UpcomingTimeline } from "@/components/dashboard/UpcomingTimeline";
|
||||
import { AISummaryCard } from "@/components/dashboard/AISummaryCard";
|
||||
import { QuickActions } from "@/components/dashboard/QuickActions";
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
export default function DashboardPage() {
|
||||
const { data, isLoading, error } = useQuery({
|
||||
queryKey: ["dashboard"],
|
||||
queryFn: () => api.get<DashboardData>("/dashboard"),
|
||||
refetchInterval: 60_000,
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<Loader2 className="h-6 w-6 animate-spin text-neutral-400" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (error || !data) {
|
||||
return (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<p className="text-sm text-neutral-500">
|
||||
Dashboard konnte nicht geladen werden.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-6xl space-y-6">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold text-neutral-900">Dashboard</h1>
|
||||
<p className="mt-0.5 text-sm text-neutral-500">
|
||||
Fristenübersicht und Kanzlei-Status
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Traffic Lights — the hero section */}
|
||||
<DeadlineTrafficLights data={data.deadline_summary} />
|
||||
|
||||
{/* Main content grid */}
|
||||
<div className="grid grid-cols-1 gap-6 lg:grid-cols-3">
|
||||
{/* Left column: Timeline (takes 2 cols) */}
|
||||
<div className="lg:col-span-2">
|
||||
<UpcomingTimeline
|
||||
deadlines={data.upcoming_deadlines}
|
||||
appointments={data.upcoming_appointments}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Right column: Case overview, AI summary, Quick actions */}
|
||||
<div className="space-y-6">
|
||||
<CaseOverviewGrid data={data.case_summary} />
|
||||
<AISummaryCard data={data} />
|
||||
<QuickActions />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default function RootPage() {
|
||||
redirect("/dashboard");
|
||||
export default function DashboardPage() {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold text-neutral-900">Dashboard</h1>
|
||||
<p className="mt-1 text-sm text-neutral-500">
|
||||
Willkommen bei KanzlAI
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,18 +9,3 @@ body {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
@keyframes count-up {
|
||||
0% {
|
||||
transform: translateY(8px);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.animate-count-up {
|
||||
animation: count-up 0.3s ease-out;
|
||||
}
|
||||
|
||||
165
frontend/src/components/cases/CaseForm.tsx
Normal file
165
frontend/src/components/cases/CaseForm.tsx
Normal file
@@ -0,0 +1,165 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
const TYPE_OPTIONS = [
|
||||
{ value: "", label: "-- Typ wahlen --" },
|
||||
{ value: "INF", label: "Verletzungsklage (INF)" },
|
||||
{ value: "REV", label: "Widerruf (REV)" },
|
||||
{ value: "CCR", label: "Einstweilige Verfugung (CCR)" },
|
||||
{ value: "APP", label: "Berufung (APP)" },
|
||||
{ value: "PI", label: "Vorlaufiger Rechtsschutz (PI)" },
|
||||
{ value: "ZPO_CIVIL", label: "ZPO Zivilverfahren" },
|
||||
];
|
||||
|
||||
export interface CaseFormData {
|
||||
case_number: string;
|
||||
title: string;
|
||||
case_type?: string;
|
||||
court?: string;
|
||||
court_ref?: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
interface CaseFormProps {
|
||||
initialData?: Partial<CaseFormData>;
|
||||
onSubmit: (data: CaseFormData) => void;
|
||||
isSubmitting?: boolean;
|
||||
submitLabel?: string;
|
||||
}
|
||||
|
||||
export function CaseForm({
|
||||
initialData,
|
||||
onSubmit,
|
||||
isSubmitting,
|
||||
submitLabel = "Akte anlegen",
|
||||
}: CaseFormProps) {
|
||||
const [form, setForm] = useState<CaseFormData>({
|
||||
case_number: initialData?.case_number ?? "",
|
||||
title: initialData?.title ?? "",
|
||||
case_type: initialData?.case_type ?? "",
|
||||
court: initialData?.court ?? "",
|
||||
court_ref: initialData?.court_ref ?? "",
|
||||
status: initialData?.status ?? "active",
|
||||
});
|
||||
|
||||
function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
const data: CaseFormData = {
|
||||
...form,
|
||||
case_type: form.case_type || undefined,
|
||||
court: form.court || undefined,
|
||||
court_ref: form.court_ref || undefined,
|
||||
};
|
||||
onSubmit(data);
|
||||
}
|
||||
|
||||
function update(field: keyof CaseFormData, value: string) {
|
||||
setForm((prev) => ({ ...prev, [field]: value }));
|
||||
}
|
||||
|
||||
const inputClass =
|
||||
"w-full rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm outline-none focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400";
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="mb-1 block text-sm font-medium text-neutral-700">
|
||||
Aktenzeichen *
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
value={form.case_number}
|
||||
onChange={(e) => update("case_number", e.target.value)}
|
||||
placeholder="z.B. 2026/001"
|
||||
className={inputClass}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="mb-1 block text-sm font-medium text-neutral-700">
|
||||
Status
|
||||
</label>
|
||||
<select
|
||||
value={form.status}
|
||||
onChange={(e) => update("status", e.target.value)}
|
||||
className={inputClass}
|
||||
>
|
||||
<option value="active">Aktiv</option>
|
||||
<option value="pending">Anhangig</option>
|
||||
<option value="closed">Geschlossen</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="mb-1 block text-sm font-medium text-neutral-700">
|
||||
Titel *
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
value={form.title}
|
||||
onChange={(e) => update("title", e.target.value)}
|
||||
placeholder="Bezeichnung der Akte"
|
||||
className={inputClass}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="mb-1 block text-sm font-medium text-neutral-700">
|
||||
Verfahrensart
|
||||
</label>
|
||||
<select
|
||||
value={form.case_type}
|
||||
onChange={(e) => update("case_type", e.target.value)}
|
||||
className={inputClass}
|
||||
>
|
||||
{TYPE_OPTIONS.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="mb-1 block text-sm font-medium text-neutral-700">
|
||||
Gericht
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={form.court}
|
||||
onChange={(e) => update("court", e.target.value)}
|
||||
placeholder="z.B. UPC Munich Central Division"
|
||||
className={inputClass}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="mb-1 block text-sm font-medium text-neutral-700">
|
||||
Gerichtliches Aktenzeichen
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={form.court_ref}
|
||||
onChange={(e) => update("court_ref", e.target.value)}
|
||||
placeholder="z.B. UPC_CFI_123/2026"
|
||||
className={inputClass}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end pt-2">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isSubmitting}
|
||||
className="rounded-md bg-neutral-900 px-4 py-1.5 text-sm font-medium text-white hover:bg-neutral-800 disabled:opacity-50"
|
||||
>
|
||||
{isSubmitting ? "Speichern..." : submitLabel}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
60
frontend/src/components/cases/CaseTimeline.tsx
Normal file
60
frontend/src/components/cases/CaseTimeline.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
"use client";
|
||||
|
||||
import type { CaseEvent } from "@/lib/types";
|
||||
import { format } from "date-fns";
|
||||
import { de } from "date-fns/locale";
|
||||
|
||||
const EVENT_ICONS: Record<string, string> = {
|
||||
case_created: "bg-emerald-500",
|
||||
status_changed: "bg-amber-500",
|
||||
party_added: "bg-blue-500",
|
||||
case_archived: "bg-neutral-400",
|
||||
document_uploaded: "bg-violet-500",
|
||||
deadline_created: "bg-red-500",
|
||||
};
|
||||
|
||||
interface CaseTimelineProps {
|
||||
events: CaseEvent[];
|
||||
}
|
||||
|
||||
export function CaseTimeline({ events }: CaseTimelineProps) {
|
||||
if (events.length === 0) {
|
||||
return (
|
||||
<p className="py-8 text-center text-sm text-neutral-400">
|
||||
Keine Ereignisse vorhanden.
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative space-y-0">
|
||||
{events.map((event, i) => (
|
||||
<div key={event.id} className="relative flex gap-3 pb-6">
|
||||
{i < events.length - 1 && (
|
||||
<div className="absolute left-[7px] top-4 h-full w-px bg-neutral-200" />
|
||||
)}
|
||||
<div
|
||||
className={`mt-1 h-[15px] w-[15px] shrink-0 rounded-full border-2 border-white ${EVENT_ICONS[event.event_type ?? ""] ?? "bg-neutral-300"}`}
|
||||
/>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-medium text-neutral-900">
|
||||
{event.title}
|
||||
</p>
|
||||
{event.description && (
|
||||
<p className="mt-0.5 text-sm text-neutral-500">
|
||||
{event.description}
|
||||
</p>
|
||||
)}
|
||||
<p className="mt-1 text-xs text-neutral-400">
|
||||
{format(
|
||||
new Date(event.event_date ?? event.created_at),
|
||||
"d. MMM yyyy, HH:mm",
|
||||
{ locale: de },
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
182
frontend/src/components/cases/PartyList.tsx
Normal file
182
frontend/src/components/cases/PartyList.tsx
Normal file
@@ -0,0 +1,182 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { api } from "@/lib/api";
|
||||
import type { Party } from "@/lib/types";
|
||||
import { Plus, Trash2, X } from "lucide-react";
|
||||
|
||||
interface PartyListProps {
|
||||
caseId: string;
|
||||
parties: Party[];
|
||||
}
|
||||
|
||||
interface PartyFormData {
|
||||
name: string;
|
||||
role: string;
|
||||
representative: string;
|
||||
}
|
||||
|
||||
const ROLE_OPTIONS = [
|
||||
"Klager",
|
||||
"Beklagter",
|
||||
"Nebenintervenient",
|
||||
"Patentinhaber",
|
||||
"Streithelfer",
|
||||
];
|
||||
|
||||
export function PartyList({ caseId, parties }: PartyListProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [form, setForm] = useState<PartyFormData>({
|
||||
name: "",
|
||||
role: "",
|
||||
representative: "",
|
||||
});
|
||||
|
||||
const addMutation = useMutation({
|
||||
mutationFn: (data: PartyFormData) =>
|
||||
api.post<Party>(`/cases/${caseId}/parties`, {
|
||||
name: data.name,
|
||||
role: data.role || undefined,
|
||||
representative: data.representative || undefined,
|
||||
}),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["case", caseId] });
|
||||
toast.success("Partei hinzugefugt");
|
||||
setShowForm(false);
|
||||
setForm({ name: "", role: "", representative: "" });
|
||||
},
|
||||
onError: () => toast.error("Fehler beim Hinzufugen"),
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (partyId: string) => api.delete(`/parties/${partyId}`),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["case", caseId] });
|
||||
toast.success("Partei entfernt");
|
||||
},
|
||||
onError: () => toast.error("Fehler beim Entfernen"),
|
||||
});
|
||||
|
||||
const inputClass =
|
||||
"w-full rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm outline-none focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400";
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-medium text-neutral-700">
|
||||
Parteien ({parties.length})
|
||||
</h3>
|
||||
{!showForm && (
|
||||
<button
|
||||
onClick={() => setShowForm(true)}
|
||||
className="inline-flex items-center gap-1 text-sm text-neutral-500 hover:text-neutral-700"
|
||||
>
|
||||
<Plus className="h-3.5 w-3.5" />
|
||||
Hinzufugen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{parties.length === 0 && !showForm && (
|
||||
<p className="mt-4 py-4 text-center text-sm text-neutral-400">
|
||||
Keine Parteien vorhanden.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-3 space-y-2">
|
||||
{parties.map((party) => (
|
||||
<div
|
||||
key={party.id}
|
||||
className="flex items-center justify-between rounded-md border border-neutral-200 bg-white px-4 py-2.5"
|
||||
>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-neutral-900">
|
||||
{party.name}
|
||||
</p>
|
||||
<div className="mt-0.5 flex gap-3 text-xs text-neutral-500">
|
||||
{party.role && <span>{party.role}</span>}
|
||||
{party.representative && (
|
||||
<span>Vertreter: {party.representative}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => deleteMutation.mutate(party.id)}
|
||||
className="rounded p-1 text-neutral-300 hover:bg-neutral-100 hover:text-red-500"
|
||||
title="Partei entfernen"
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{showForm && (
|
||||
<div className="mt-3 rounded-md border border-neutral-200 bg-neutral-50 p-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm font-medium text-neutral-700">
|
||||
Neue Partei
|
||||
</span>
|
||||
<button
|
||||
onClick={() => setShowForm(false)}
|
||||
className="text-neutral-400 hover:text-neutral-600"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
addMutation.mutate(form);
|
||||
}}
|
||||
className="mt-3 space-y-3"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
placeholder="Name der Partei"
|
||||
value={form.name}
|
||||
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
||||
className={inputClass}
|
||||
/>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<select
|
||||
value={form.role}
|
||||
onChange={(e) => setForm({ ...form, role: e.target.value })}
|
||||
className={inputClass}
|
||||
>
|
||||
<option value="">-- Rolle --</option>
|
||||
{ROLE_OPTIONS.map((r) => (
|
||||
<option key={r} value={r}>
|
||||
{r}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Vertreter / Anwalt"
|
||||
value={form.representative}
|
||||
onChange={(e) =>
|
||||
setForm({ ...form, representative: e.target.value })
|
||||
}
|
||||
className={inputClass}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-end">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={addMutation.isPending}
|
||||
className="rounded-md bg-neutral-900 px-3 py-1.5 text-sm font-medium text-white hover:bg-neutral-800 disabled:opacity-50"
|
||||
>
|
||||
{addMutation.isPending ? "..." : "Hinzufugen"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Sparkles } from "lucide-react";
|
||||
import type { DashboardData } from "@/lib/types";
|
||||
|
||||
interface Props {
|
||||
data: DashboardData;
|
||||
}
|
||||
|
||||
function generateSummary(data: DashboardData): string {
|
||||
const parts: string[] = [];
|
||||
const { deadline_summary: ds, case_summary: cs, upcoming_deadlines: ud } = data;
|
||||
|
||||
// Deadline urgency
|
||||
if (ds.overdue_count > 0) {
|
||||
parts.push(
|
||||
`${ds.overdue_count} Frist${ds.overdue_count > 1 ? "en" : ""} ${ds.overdue_count > 1 ? "sind" : "ist"} überfällig und ${ds.overdue_count > 1 ? "erfordern" : "erfordert"} sofortige Aufmerksamkeit.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (ds.due_this_week > 0) {
|
||||
parts.push(
|
||||
`${ds.due_this_week} Frist${ds.due_this_week > 1 ? "en laufen" : " läuft"} diese Woche ab.`,
|
||||
);
|
||||
}
|
||||
|
||||
// Highlight most critical upcoming deadline
|
||||
if (ud.length > 0) {
|
||||
const next = ud[0];
|
||||
parts.push(
|
||||
`Die nächste Frist ist "${next.title}" in Akte ${next.case_number}.`,
|
||||
);
|
||||
}
|
||||
|
||||
// Case activity
|
||||
if (cs.new_this_month > 0) {
|
||||
parts.push(
|
||||
`${cs.new_this_month} neue Akte${cs.new_this_month > 1 ? "n" : ""} diesen Monat bei ${cs.active_count} aktiven Verfahren.`,
|
||||
);
|
||||
} else {
|
||||
parts.push(`${cs.active_count} aktive Verfahren.`);
|
||||
}
|
||||
|
||||
// All good
|
||||
if (ds.overdue_count === 0 && ds.due_this_week === 0) {
|
||||
parts.unshift("Alle Fristen sind im Zeitplan.");
|
||||
}
|
||||
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
export function AISummaryCard({ data }: Props) {
|
||||
const summary = generateSummary(data);
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="rounded-md bg-violet-50 p-1.5">
|
||||
<Sparkles className="h-4 w-4 text-violet-500" />
|
||||
</div>
|
||||
<h2 className="text-sm font-semibold text-neutral-900">
|
||||
KI-Zusammenfassung
|
||||
</h2>
|
||||
</div>
|
||||
<p className="mt-3 text-sm leading-relaxed text-neutral-700">
|
||||
{summary}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { FolderOpen, FolderPlus, Archive } from "lucide-react";
|
||||
import type { CaseSummary } from "@/lib/types";
|
||||
|
||||
interface Props {
|
||||
data: CaseSummary;
|
||||
}
|
||||
|
||||
export function CaseOverviewGrid({ data }: Props) {
|
||||
const items = [
|
||||
{
|
||||
label: "Aktive Akten",
|
||||
value: data.active_count,
|
||||
icon: FolderOpen,
|
||||
color: "text-blue-600",
|
||||
bg: "bg-blue-50",
|
||||
},
|
||||
{
|
||||
label: "Neu (Monat)",
|
||||
value: data.new_this_month,
|
||||
icon: FolderPlus,
|
||||
color: "text-violet-600",
|
||||
bg: "bg-violet-50",
|
||||
},
|
||||
{
|
||||
label: "Abgeschlossen",
|
||||
value: data.closed_count,
|
||||
icon: Archive,
|
||||
color: "text-neutral-500",
|
||||
bg: "bg-neutral-50",
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
||||
<h2 className="text-sm font-semibold text-neutral-900">Aktenübersicht</h2>
|
||||
<div className="mt-4 space-y-3">
|
||||
{items.map((item) => (
|
||||
<div key={item.label} className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2.5">
|
||||
<div className={`rounded-md p-1.5 ${item.bg}`}>
|
||||
<item.icon className={`h-4 w-4 ${item.color}`} />
|
||||
</div>
|
||||
<span className="text-sm text-neutral-600">{item.label}</span>
|
||||
</div>
|
||||
<span className="text-lg font-semibold tabular-nums text-neutral-900">
|
||||
{item.value}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { AlertTriangle, Clock, CheckCircle } from "lucide-react";
|
||||
import type { DeadlineSummary } from "@/lib/types";
|
||||
|
||||
function AnimatedCount({ value }: { value: number }) {
|
||||
const ref = useRef<HTMLSpanElement>(null);
|
||||
const prevValue = useRef(value);
|
||||
|
||||
useEffect(() => {
|
||||
const el = ref.current;
|
||||
if (!el || prevValue.current === value) return;
|
||||
|
||||
el.classList.remove("animate-count-up");
|
||||
void el.offsetWidth;
|
||||
el.classList.add("animate-count-up");
|
||||
prevValue.current = value;
|
||||
}, [value]);
|
||||
|
||||
return (
|
||||
<span ref={ref} className="inline-block tabular-nums">
|
||||
{value}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
interface Props {
|
||||
data: DeadlineSummary;
|
||||
onFilter?: (filter: "overdue" | "this_week" | "ok") => void;
|
||||
}
|
||||
|
||||
export function DeadlineTrafficLights({ data, onFilter }: Props) {
|
||||
const cards = [
|
||||
{
|
||||
key: "overdue" as const,
|
||||
label: "Überfällig",
|
||||
count: data.overdue_count,
|
||||
icon: AlertTriangle,
|
||||
bg: "bg-red-50",
|
||||
border: "border-red-200",
|
||||
iconColor: "text-red-500",
|
||||
countColor: "text-red-700",
|
||||
labelColor: "text-red-600",
|
||||
ring: data.overdue_count > 0 ? "ring-2 ring-red-300 ring-offset-1" : "",
|
||||
pulse: data.overdue_count > 0,
|
||||
},
|
||||
{
|
||||
key: "this_week" as const,
|
||||
label: "Diese Woche",
|
||||
count: data.due_this_week,
|
||||
icon: Clock,
|
||||
bg: "bg-amber-50",
|
||||
border: "border-amber-200",
|
||||
iconColor: "text-amber-500",
|
||||
countColor: "text-amber-700",
|
||||
labelColor: "text-amber-600",
|
||||
ring: "",
|
||||
pulse: false,
|
||||
},
|
||||
{
|
||||
key: "ok" as const,
|
||||
label: "Im Zeitplan",
|
||||
count: data.ok_count + data.due_next_week,
|
||||
icon: CheckCircle,
|
||||
bg: "bg-emerald-50",
|
||||
border: "border-emerald-200",
|
||||
iconColor: "text-emerald-500",
|
||||
countColor: "text-emerald-700",
|
||||
labelColor: "text-emerald-600",
|
||||
ring: "",
|
||||
pulse: false,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
||||
{cards.map((card) => (
|
||||
<button
|
||||
key={card.key}
|
||||
onClick={() => onFilter?.(card.key)}
|
||||
className={`group relative overflow-hidden rounded-xl border ${card.border} ${card.bg} ${card.ring} p-6 text-left transition-all hover:shadow-md active:scale-[0.98]`}
|
||||
>
|
||||
{card.pulse && (
|
||||
<span className="absolute right-4 top-4 flex h-3 w-3">
|
||||
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-red-400 opacity-75" />
|
||||
<span className="relative inline-flex h-3 w-3 rounded-full bg-red-500" />
|
||||
</span>
|
||||
)}
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={`rounded-lg p-2 ${card.bg}`}>
|
||||
<card.icon className={`h-5 w-5 ${card.iconColor}`} />
|
||||
</div>
|
||||
<span className={`text-sm font-medium ${card.labelColor}`}>
|
||||
{card.label}
|
||||
</span>
|
||||
</div>
|
||||
<div className={`mt-4 text-4xl font-bold tracking-tight ${card.countColor}`}>
|
||||
<AnimatedCount value={card.count} />
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { FolderPlus, Clock, Sparkles, CalendarSync } from "lucide-react";
|
||||
|
||||
const actions = [
|
||||
{
|
||||
label: "Neue Akte",
|
||||
href: "/akten?new=1",
|
||||
icon: FolderPlus,
|
||||
color: "text-blue-600 bg-blue-50 hover:bg-blue-100",
|
||||
},
|
||||
{
|
||||
label: "Frist eintragen",
|
||||
href: "/fristen?new=1",
|
||||
icon: Clock,
|
||||
color: "text-amber-600 bg-amber-50 hover:bg-amber-100",
|
||||
},
|
||||
{
|
||||
label: "AI Analyse",
|
||||
href: "/ai",
|
||||
icon: Sparkles,
|
||||
color: "text-violet-600 bg-violet-50 hover:bg-violet-100",
|
||||
},
|
||||
{
|
||||
label: "CalDAV Sync",
|
||||
href: "/einstellungen",
|
||||
icon: CalendarSync,
|
||||
color: "text-emerald-600 bg-emerald-50 hover:bg-emerald-100",
|
||||
},
|
||||
];
|
||||
|
||||
export function QuickActions() {
|
||||
return (
|
||||
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
||||
<h2 className="text-sm font-semibold text-neutral-900">
|
||||
Schnellzugriff
|
||||
</h2>
|
||||
<div className="mt-3 grid grid-cols-2 gap-2">
|
||||
{actions.map((action) => (
|
||||
<Link
|
||||
key={action.label}
|
||||
href={action.href}
|
||||
className={`flex items-center gap-2 rounded-lg px-3 py-2.5 text-sm font-medium transition-colors ${action.color}`}
|
||||
>
|
||||
<action.icon className="h-4 w-4" />
|
||||
{action.label}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { format, parseISO, isToday, isTomorrow } from "date-fns";
|
||||
import { de } from "date-fns/locale";
|
||||
import { Clock, Calendar, MapPin } from "lucide-react";
|
||||
import type { UpcomingDeadline, UpcomingAppointment } from "@/lib/types";
|
||||
|
||||
interface Props {
|
||||
deadlines: UpcomingDeadline[];
|
||||
appointments: UpcomingAppointment[];
|
||||
}
|
||||
|
||||
type TimelineItem =
|
||||
| { type: "deadline"; date: Date; data: UpcomingDeadline }
|
||||
| { type: "appointment"; date: Date; data: UpcomingAppointment };
|
||||
|
||||
function formatDayLabel(date: Date): string {
|
||||
if (isToday(date)) return "Heute";
|
||||
if (isTomorrow(date)) return "Morgen";
|
||||
return format(date, "EEEE, d. MMM", { locale: de });
|
||||
}
|
||||
|
||||
export function UpcomingTimeline({ deadlines, appointments }: Props) {
|
||||
const items: TimelineItem[] = [
|
||||
...deadlines.map((d) => ({
|
||||
type: "deadline" as const,
|
||||
date: parseISO(d.due_date),
|
||||
data: d,
|
||||
})),
|
||||
...appointments.map((a) => ({
|
||||
type: "appointment" as const,
|
||||
date: parseISO(a.start_at),
|
||||
data: a,
|
||||
})),
|
||||
].sort((a, b) => a.date.getTime() - b.date.getTime());
|
||||
|
||||
// Group by day
|
||||
const grouped = new Map<string, TimelineItem[]>();
|
||||
for (const item of items) {
|
||||
const key = format(item.date, "yyyy-MM-dd");
|
||||
const group = grouped.get(key) ?? [];
|
||||
group.push(item);
|
||||
grouped.set(key, group);
|
||||
}
|
||||
|
||||
const empty = items.length === 0;
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border border-neutral-200 bg-white p-5">
|
||||
<h2 className="text-sm font-semibold text-neutral-900">
|
||||
Nächste 7 Tage
|
||||
</h2>
|
||||
{empty ? (
|
||||
<p className="mt-6 text-center text-sm text-neutral-400">
|
||||
Keine anstehenden Termine oder Fristen
|
||||
</p>
|
||||
) : (
|
||||
<div className="mt-4 space-y-5">
|
||||
{Array.from(grouped.entries()).map(([dateKey, dayItems]) => (
|
||||
<div key={dateKey}>
|
||||
<p className="text-xs font-medium uppercase tracking-wider text-neutral-400">
|
||||
{formatDayLabel(dayItems[0].date)}
|
||||
</p>
|
||||
<div className="mt-2 space-y-2">
|
||||
{dayItems.map((item, i) => (
|
||||
<TimelineEntry key={`${item.type}-${i}`} item={item} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TimelineEntry({ item }: { item: TimelineItem }) {
|
||||
if (item.type === "deadline") {
|
||||
const d = item.data;
|
||||
return (
|
||||
<div className="flex items-start gap-3 rounded-lg border border-neutral-100 bg-neutral-50/50 px-3 py-2.5">
|
||||
<div className="mt-0.5 rounded-md bg-amber-50 p-1">
|
||||
<Clock className="h-3.5 w-3.5 text-amber-500" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm font-medium text-neutral-900">
|
||||
{d.title}
|
||||
</p>
|
||||
<p className="mt-0.5 truncate text-xs text-neutral-500">
|
||||
{d.case_number} · {d.case_title}
|
||||
</p>
|
||||
</div>
|
||||
<span className="shrink-0 text-xs font-medium text-amber-600">
|
||||
Frist
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const a = item.data;
|
||||
return (
|
||||
<div className="flex items-start gap-3 rounded-lg border border-neutral-100 bg-neutral-50/50 px-3 py-2.5">
|
||||
<div className="mt-0.5 rounded-md bg-blue-50 p-1">
|
||||
<Calendar className="h-3.5 w-3.5 text-blue-500" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm font-medium text-neutral-900">
|
||||
{a.title}
|
||||
</p>
|
||||
<div className="mt-0.5 flex items-center gap-2 text-xs text-neutral-500">
|
||||
<span>{format(item.date, "HH:mm")} Uhr</span>
|
||||
{a.location && (
|
||||
<>
|
||||
<span className="text-neutral-300">·</span>
|
||||
<span className="flex items-center gap-0.5 truncate">
|
||||
<MapPin className="h-3 w-3" />
|
||||
{a.location}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
{a.case_number && (
|
||||
<>
|
||||
<span className="text-neutral-300">·</span>
|
||||
<span>{a.case_number}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<span className="shrink-0 text-xs font-medium text-blue-600">
|
||||
Termin
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
} from "lucide-react";
|
||||
|
||||
const navigation = [
|
||||
{ name: "Dashboard", href: "/dashboard", icon: LayoutDashboard },
|
||||
{ name: "Akten", href: "/akten", icon: FolderOpen },
|
||||
{ name: "Dashboard", href: "/", icon: LayoutDashboard },
|
||||
{ name: "Akten", href: "/cases", icon: FolderOpen },
|
||||
{ name: "Fristen", href: "/fristen", icon: Clock },
|
||||
{ name: "Termine", href: "/termine", icon: Calendar },
|
||||
{ name: "AI Analyse", href: "/ai", icon: Brain },
|
||||
@@ -30,7 +30,10 @@ export function Sidebar() {
|
||||
</div>
|
||||
<nav className="flex-1 space-y-0.5 p-2">
|
||||
{navigation.map((item) => {
|
||||
const isActive = pathname.startsWith(item.href);
|
||||
const isActive =
|
||||
item.href === "/"
|
||||
? pathname === "/"
|
||||
: pathname.startsWith(item.href);
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
|
||||
@@ -104,51 +104,6 @@ export interface Document {
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface DeadlineSummary {
|
||||
overdue_count: number;
|
||||
due_this_week: number;
|
||||
due_next_week: number;
|
||||
ok_count: number;
|
||||
}
|
||||
|
||||
export interface CaseSummary {
|
||||
active_count: number;
|
||||
new_this_month: number;
|
||||
closed_count: number;
|
||||
}
|
||||
|
||||
export interface UpcomingDeadline {
|
||||
id: string;
|
||||
title: string;
|
||||
due_date: string;
|
||||
case_number: string;
|
||||
case_title: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface UpcomingAppointment {
|
||||
id: string;
|
||||
title: string;
|
||||
start_at: string;
|
||||
case_number: string | null;
|
||||
location: string | null;
|
||||
}
|
||||
|
||||
export interface RecentActivityItem {
|
||||
event_type: string | null;
|
||||
title: string;
|
||||
case_number: string;
|
||||
event_date: string | null;
|
||||
}
|
||||
|
||||
export interface DashboardData {
|
||||
deadline_summary: DeadlineSummary;
|
||||
case_summary: CaseSummary;
|
||||
upcoming_deadlines: UpcomingDeadline[];
|
||||
upcoming_appointments: UpcomingAppointment[];
|
||||
recent_activity: RecentActivityItem[];
|
||||
}
|
||||
|
||||
export interface ApiError {
|
||||
error: string;
|
||||
status: number;
|
||||
|
||||
Reference in New Issue
Block a user