Compare commits
1 Commits
mai/linus/
...
mai/pike/p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7094212dcf |
@@ -1,35 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useParams } from "next/navigation";
|
|
||||||
import { api } from "@/lib/api";
|
|
||||||
import type { Document } from "@/lib/types";
|
|
||||||
import { DocumentList } from "@/components/documents/DocumentList";
|
|
||||||
import { DocumentUpload } from "@/components/documents/DocumentUpload";
|
|
||||||
import { Loader2 } from "lucide-react";
|
|
||||||
|
|
||||||
export default function DokumentePage() {
|
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
|
|
||||||
const { data, isLoading } = useQuery({
|
|
||||||
queryKey: ["case-documents", id],
|
|
||||||
queryFn: () => api.get<Document[]>(`/cases/${id}/documents`),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center py-8">
|
|
||||||
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const documents = Array.isArray(data) ? data : [];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-6">
|
|
||||||
<DocumentUpload caseId={id} />
|
|
||||||
<DocumentList documents={documents} caseId={id} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
230
frontend/src/app/(app)/cases/[id]/ereignisse/[eventId]/page.tsx
Normal file
230
frontend/src/app/(app)/cases/[id]/ereignisse/[eventId]/page.tsx
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { CaseEvent, Case } from "@/lib/types";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
|
import { NotesList } from "@/components/notes/NotesList";
|
||||||
|
import { Skeleton } from "@/components/ui/Skeleton";
|
||||||
|
import { format, parseISO } from "date-fns";
|
||||||
|
import { de } from "date-fns/locale";
|
||||||
|
import {
|
||||||
|
AlertTriangle,
|
||||||
|
FileText,
|
||||||
|
Scale,
|
||||||
|
ArrowRightLeft,
|
||||||
|
Calendar,
|
||||||
|
MessageSquare,
|
||||||
|
Gavel,
|
||||||
|
Info,
|
||||||
|
} from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
const EVENT_TYPE_CONFIG: Record<
|
||||||
|
string,
|
||||||
|
{ label: string; icon: typeof Info; color: string }
|
||||||
|
> = {
|
||||||
|
status_changed: {
|
||||||
|
label: "Statusaenderung",
|
||||||
|
icon: ArrowRightLeft,
|
||||||
|
color: "bg-blue-50 text-blue-700",
|
||||||
|
},
|
||||||
|
deadline_created: {
|
||||||
|
label: "Frist erstellt",
|
||||||
|
icon: Calendar,
|
||||||
|
color: "bg-amber-50 text-amber-700",
|
||||||
|
},
|
||||||
|
deadline_completed: {
|
||||||
|
label: "Frist erledigt",
|
||||||
|
icon: Calendar,
|
||||||
|
color: "bg-emerald-50 text-emerald-700",
|
||||||
|
},
|
||||||
|
document_uploaded: {
|
||||||
|
label: "Dokument hochgeladen",
|
||||||
|
icon: FileText,
|
||||||
|
color: "bg-violet-50 text-violet-700",
|
||||||
|
},
|
||||||
|
hearing_scheduled: {
|
||||||
|
label: "Verhandlung angesetzt",
|
||||||
|
icon: Gavel,
|
||||||
|
color: "bg-rose-50 text-rose-700",
|
||||||
|
},
|
||||||
|
note_added: {
|
||||||
|
label: "Notiz hinzugefuegt",
|
||||||
|
icon: MessageSquare,
|
||||||
|
color: "bg-neutral-100 text-neutral-700",
|
||||||
|
},
|
||||||
|
case_created: {
|
||||||
|
label: "Akte erstellt",
|
||||||
|
icon: Scale,
|
||||||
|
color: "bg-emerald-50 text-emerald-700",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const DEFAULT_EVENT_CONFIG = {
|
||||||
|
label: "Ereignis",
|
||||||
|
icon: Info,
|
||||||
|
color: "bg-neutral-100 text-neutral-600",
|
||||||
|
};
|
||||||
|
|
||||||
|
function DetailSkeleton() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Skeleton className="h-4 w-64" />
|
||||||
|
<div className="mt-6 space-y-4">
|
||||||
|
<Skeleton className="h-8 w-48" />
|
||||||
|
<Skeleton className="h-4 w-32" />
|
||||||
|
<Skeleton className="h-32 rounded-lg" />
|
||||||
|
<Skeleton className="h-48 rounded-lg" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CaseEventDetailPage() {
|
||||||
|
const { id: caseId, eventId } = useParams<{
|
||||||
|
id: string;
|
||||||
|
eventId: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const { data: caseData } = useQuery({
|
||||||
|
queryKey: ["case", caseId],
|
||||||
|
queryFn: () => api.get<Case>(`/cases/${caseId}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: event,
|
||||||
|
isLoading,
|
||||||
|
error,
|
||||||
|
} = useQuery({
|
||||||
|
queryKey: ["case-event", eventId],
|
||||||
|
queryFn: () => api.get<CaseEvent>(`/case-events/${eventId}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading) return <DetailSkeleton />;
|
||||||
|
|
||||||
|
if (error || !event) {
|
||||||
|
return (
|
||||||
|
<div className="py-12 text-center">
|
||||||
|
<div className="mx-auto mb-3 w-fit rounded-xl bg-red-50 p-3">
|
||||||
|
<AlertTriangle className="h-6 w-6 text-red-500" />
|
||||||
|
</div>
|
||||||
|
<p className="text-sm font-medium text-neutral-900">
|
||||||
|
Ereignis nicht gefunden
|
||||||
|
</p>
|
||||||
|
<p className="mt-1 text-sm text-neutral-500">
|
||||||
|
Das Ereignis existiert nicht oder Sie haben keine Berechtigung.
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
href={`/cases/${caseId}`}
|
||||||
|
className="mt-4 inline-block text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
Zurueck zur Akte
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const typeConfig =
|
||||||
|
EVENT_TYPE_CONFIG[event.event_type ?? ""] ?? DEFAULT_EVENT_CONFIG;
|
||||||
|
const TypeIcon = typeConfig.icon;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="animate-fade-in">
|
||||||
|
<Breadcrumb
|
||||||
|
items={[
|
||||||
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
|
{ label: "Akten", href: "/cases" },
|
||||||
|
{
|
||||||
|
label: caseData?.case_number
|
||||||
|
? `Az. ${caseData.case_number}`
|
||||||
|
: "Akte",
|
||||||
|
href: `/cases/${caseId}`,
|
||||||
|
},
|
||||||
|
{ label: "Verlauf", href: `/cases/${caseId}` },
|
||||||
|
{ label: event.title },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Header */}
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<div className={`rounded-lg p-2 ${typeConfig.color}`}>
|
||||||
|
<TypeIcon className="h-5 w-5" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1 className="text-lg font-semibold text-neutral-900">
|
||||||
|
{event.title}
|
||||||
|
</h1>
|
||||||
|
<p className="text-sm text-neutral-500">
|
||||||
|
{event.event_date
|
||||||
|
? format(parseISO(event.event_date), "d. MMMM yyyy, HH:mm", {
|
||||||
|
locale: de,
|
||||||
|
})
|
||||||
|
: format(parseISO(event.created_at), "d. MMMM yyyy, HH:mm", {
|
||||||
|
locale: de,
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
{event.description && (
|
||||||
|
<div className="mt-4 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<p className="text-xs font-medium uppercase tracking-wide text-neutral-400">
|
||||||
|
Beschreibung
|
||||||
|
</p>
|
||||||
|
<p className="mt-1 whitespace-pre-wrap text-sm text-neutral-700">
|
||||||
|
{event.description}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Metadata */}
|
||||||
|
<div className="mt-3 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<p className="text-xs font-medium uppercase tracking-wide text-neutral-400">
|
||||||
|
Metadaten
|
||||||
|
</p>
|
||||||
|
<dl className="mt-2 space-y-1.5">
|
||||||
|
<div className="flex gap-2 text-sm">
|
||||||
|
<dt className="text-neutral-500">Typ:</dt>
|
||||||
|
<dd>
|
||||||
|
<span
|
||||||
|
className={`inline-block rounded-full px-2 py-0.5 text-xs font-medium ${typeConfig.color}`}
|
||||||
|
>
|
||||||
|
{typeConfig.label}
|
||||||
|
</span>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
{event.created_by && (
|
||||||
|
<div className="flex gap-2 text-sm">
|
||||||
|
<dt className="text-neutral-500">Erstellt von:</dt>
|
||||||
|
<dd className="text-neutral-900">{event.created_by}</dd>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex gap-2 text-sm">
|
||||||
|
<dt className="text-neutral-500">Erstellt am:</dt>
|
||||||
|
<dd className="text-neutral-900">
|
||||||
|
{format(parseISO(event.created_at), "d. MMMM yyyy, HH:mm", {
|
||||||
|
locale: de,
|
||||||
|
})}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
{event.metadata &&
|
||||||
|
Object.keys(event.metadata).length > 0 &&
|
||||||
|
Object.entries(event.metadata).map(([key, value]) => (
|
||||||
|
<div key={key} className="flex gap-2 text-sm">
|
||||||
|
<dt className="text-neutral-500">{key}:</dt>
|
||||||
|
<dd className="text-neutral-900">{String(value)}</dd>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Notes */}
|
||||||
|
<div className="mt-6">
|
||||||
|
<NotesList parentType="case_event" parentId={eventId} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useParams } from "next/navigation";
|
|
||||||
import { api } from "@/lib/api";
|
|
||||||
import type { Deadline } from "@/lib/types";
|
|
||||||
import { format } from "date-fns";
|
|
||||||
import { de } from "date-fns/locale";
|
|
||||||
import { Clock, Loader2 } from "lucide-react";
|
|
||||||
|
|
||||||
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",
|
|
||||||
};
|
|
||||||
|
|
||||||
const DEADLINE_STATUS_LABEL: Record<string, string> = {
|
|
||||||
pending: "Offen",
|
|
||||||
completed: "Erledigt",
|
|
||||||
overdue: "Ueberfaellig",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function FristenPage() {
|
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
|
|
||||||
const { data, isLoading } = useQuery({
|
|
||||||
queryKey: ["case-deadlines", id],
|
|
||||||
queryFn: () =>
|
|
||||||
api.get<{ deadlines: Deadline[]; total: number }>(
|
|
||||||
`/deadlines?case_id=${id}`,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center py-8">
|
|
||||||
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const deadlines = Array.isArray(data?.deadlines) ? data.deadlines : [];
|
|
||||||
|
|
||||||
if (deadlines.length === 0) {
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center py-8 text-center">
|
|
||||||
<div className="rounded-xl bg-neutral-100 p-3">
|
|
||||||
<Clock className="h-5 w-5 text-neutral-400" />
|
|
||||||
</div>
|
|
||||||
<p className="mt-2 text-sm text-neutral-500">
|
|
||||||
Keine Fristen vorhanden.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-2">
|
|
||||||
{deadlines.map((d) => (
|
|
||||||
<div
|
|
||||||
key={d.id}
|
|
||||||
className="flex flex-col gap-2 rounded-md border border-neutral-200 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between"
|
|
||||||
>
|
|
||||||
<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"}`}
|
|
||||||
>
|
|
||||||
{DEADLINE_STATUS_LABEL[d.status] ?? d.status}
|
|
||||||
</span>
|
|
||||||
<span className="whitespace-nowrap text-sm text-neutral-500">
|
|
||||||
{format(new Date(d.due_date), "d. MMM yyyy", { locale: de })}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,226 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useParams, usePathname } from "next/navigation";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { api } from "@/lib/api";
|
|
||||||
import type { Case } from "@/lib/types";
|
|
||||||
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
|
||||||
import { Skeleton } from "@/components/ui/Skeleton";
|
|
||||||
import {
|
|
||||||
ArrowLeft,
|
|
||||||
Activity,
|
|
||||||
Clock,
|
|
||||||
FileText,
|
|
||||||
Users,
|
|
||||||
StickyNote,
|
|
||||||
AlertTriangle,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { format } from "date-fns";
|
|
||||||
import { de } from "date-fns/locale";
|
|
||||||
|
|
||||||
interface CaseDetail extends Case {
|
|
||||||
parties: unknown[];
|
|
||||||
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 STATUS_LABEL: Record<string, string> = {
|
|
||||||
active: "Aktiv",
|
|
||||||
pending: "Anhaengig",
|
|
||||||
closed: "Geschlossen",
|
|
||||||
archived: "Archiviert",
|
|
||||||
};
|
|
||||||
|
|
||||||
const TABS = [
|
|
||||||
{ segment: "verlauf", label: "Verlauf", icon: Activity },
|
|
||||||
{ segment: "fristen", label: "Fristen", icon: Clock },
|
|
||||||
{ segment: "dokumente", label: "Dokumente", icon: FileText },
|
|
||||||
{ segment: "parteien", label: "Parteien", icon: Users },
|
|
||||||
{ segment: "notizen", label: "Notizen", icon: StickyNote },
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
const TAB_LABELS: Record<string, string> = {
|
|
||||||
verlauf: "Verlauf",
|
|
||||||
fristen: "Fristen",
|
|
||||||
dokumente: "Dokumente",
|
|
||||||
parteien: "Parteien",
|
|
||||||
notizen: "Notizen",
|
|
||||||
};
|
|
||||||
|
|
||||||
function CaseDetailSkeleton() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Skeleton className="h-4 w-28" />
|
|
||||||
<div className="mt-4 flex items-start justify-between">
|
|
||||||
<div>
|
|
||||||
<Skeleton className="h-6 w-48" />
|
|
||||||
<Skeleton className="mt-2 h-4 w-64" />
|
|
||||||
</div>
|
|
||||||
<div className="space-y-1">
|
|
||||||
<Skeleton className="h-3 w-24" />
|
|
||||||
<Skeleton className="h-3 w-24" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-6 flex gap-4 border-b border-neutral-200 pb-2.5">
|
|
||||||
{[1, 2, 3, 4, 5].map((i) => (
|
|
||||||
<Skeleton key={i} className="h-4 w-20" />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<div className="mt-6 space-y-3">
|
|
||||||
{[1, 2, 3].map((i) => (
|
|
||||||
<Skeleton key={i} className="h-14 rounded-md" />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function CaseDetailLayout({
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
const pathname = usePathname();
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: caseDetail,
|
|
||||||
isLoading,
|
|
||||||
error,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["case", id],
|
|
||||||
queryFn: () => api.get<CaseDetail>(`/cases/${id}`),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Determine active tab from pathname
|
|
||||||
const segments = pathname.split("/");
|
|
||||||
const activeSegment = segments[segments.length - 1] || "verlauf";
|
|
||||||
const activeTabLabel = TAB_LABELS[activeSegment];
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <CaseDetailSkeleton />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error || !caseDetail) {
|
|
||||||
return (
|
|
||||||
<div className="py-12 text-center">
|
|
||||||
<div className="mx-auto mb-3 w-fit rounded-xl bg-red-50 p-3">
|
|
||||||
<AlertTriangle className="h-6 w-6 text-red-500" />
|
|
||||||
</div>
|
|
||||||
<p className="text-sm font-medium text-neutral-900">
|
|
||||||
Akte nicht gefunden
|
|
||||||
</p>
|
|
||||||
<p className="mt-1 text-sm text-neutral-500">
|
|
||||||
Die Akte existiert nicht oder Sie haben keine Berechtigung.
|
|
||||||
</p>
|
|
||||||
<Link
|
|
||||||
href="/cases"
|
|
||||||
className="mt-4 inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
|
||||||
>
|
|
||||||
<ArrowLeft className="h-3.5 w-3.5" />
|
|
||||||
Zurueck zu Akten
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const breadcrumbItems = [
|
|
||||||
{ label: "Dashboard", href: "/dashboard" },
|
|
||||||
{ label: "Akten", href: "/cases" },
|
|
||||||
{ label: caseDetail.case_number, href: `/cases/${id}/verlauf` },
|
|
||||||
...(activeTabLabel ? [{ label: activeTabLabel }] : []),
|
|
||||||
];
|
|
||||||
|
|
||||||
const partiesCount = Array.isArray(caseDetail.parties)
|
|
||||||
? caseDetail.parties.length
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="animate-fade-in">
|
|
||||||
<Breadcrumb items={breadcrumbItems} />
|
|
||||||
|
|
||||||
<div className="mt-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
|
||||||
<div>
|
|
||||||
<div className="flex flex-wrap 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"}`}
|
|
||||||
>
|
|
||||||
{STATUS_LABEL[caseDetail.status] ?? caseDetail.status}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="mt-1 flex flex-wrap gap-x-4 gap-y-1 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-1 overflow-x-auto sm:gap-4">
|
|
||||||
{TABS.map((tab) => {
|
|
||||||
const isActive = activeSegment === tab.segment;
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
key={tab.segment}
|
|
||||||
href={`/cases/${id}/${tab.segment}`}
|
|
||||||
className={`inline-flex shrink-0 items-center gap-1.5 border-b-2 px-1 pb-2.5 text-sm font-medium transition-colors ${
|
|
||||||
isActive
|
|
||||||
? "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.segment === "fristen" &&
|
|
||||||
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.segment === "parteien" && partiesCount > 0 && (
|
|
||||||
<span className="ml-1 rounded-full bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-500">
|
|
||||||
{partiesCount}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6">{children}</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useParams } from "next/navigation";
|
|
||||||
import { NotesList } from "@/components/notes/NotesList";
|
|
||||||
|
|
||||||
export default function NotizenPage() {
|
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
|
|
||||||
return <NotesList parentType="case" parentId={id} />;
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,341 @@
|
|||||||
import { redirect } from "next/navigation";
|
"use client";
|
||||||
|
|
||||||
export default async function CaseDetailPage({
|
import { useQuery } from "@tanstack/react-query";
|
||||||
params,
|
import { useParams } from "next/navigation";
|
||||||
}: {
|
import { api } from "@/lib/api";
|
||||||
params: Promise<{ id: string }>;
|
import type { Case, CaseEvent, Party, Deadline, Document } from "@/lib/types";
|
||||||
}) {
|
import { CaseTimeline } from "@/components/cases/CaseTimeline";
|
||||||
const { id } = await params;
|
import { PartyList } from "@/components/cases/PartyList";
|
||||||
redirect(`/cases/${id}/verlauf`);
|
import {
|
||||||
|
ArrowLeft,
|
||||||
|
Clock,
|
||||||
|
FileText,
|
||||||
|
Users,
|
||||||
|
Activity,
|
||||||
|
AlertTriangle,
|
||||||
|
} from "lucide-react";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
import { de } from "date-fns/locale";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Skeleton } from "@/components/ui/Skeleton";
|
||||||
|
|
||||||
|
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 STATUS_LABEL: Record<string, string> = {
|
||||||
|
active: "Aktiv",
|
||||||
|
pending: "Anhängig",
|
||||||
|
closed: "Geschlossen",
|
||||||
|
archived: "Archiviert",
|
||||||
|
};
|
||||||
|
|
||||||
|
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"];
|
||||||
|
|
||||||
|
function CaseDetailSkeleton() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Skeleton className="h-4 w-28" />
|
||||||
|
<div className="mt-4 flex items-start justify-between">
|
||||||
|
<div>
|
||||||
|
<Skeleton className="h-6 w-48" />
|
||||||
|
<Skeleton className="mt-2 h-4 w-64" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Skeleton className="h-3 w-24" />
|
||||||
|
<Skeleton className="h-3 w-24" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-6 flex gap-4 border-b border-neutral-200 pb-2.5">
|
||||||
|
{[1, 2, 3, 4].map((i) => (
|
||||||
|
<Skeleton key={i} className="h-4 w-20" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="mt-6 space-y-3">
|
||||||
|
{[1, 2, 3].map((i) => (
|
||||||
|
<Skeleton key={i} className="h-14 rounded-md" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CaseDetailPage() {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
const [activeTab, setActiveTab] = useState<TabKey>("timeline");
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: caseDetail,
|
||||||
|
isLoading,
|
||||||
|
error,
|
||||||
|
} = 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 <CaseDetailSkeleton />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error || !caseDetail) {
|
||||||
|
return (
|
||||||
|
<div className="py-12 text-center">
|
||||||
|
<div className="mx-auto mb-3 w-fit rounded-xl bg-red-50 p-3">
|
||||||
|
<AlertTriangle className="h-6 w-6 text-red-500" />
|
||||||
|
</div>
|
||||||
|
<p className="text-sm font-medium text-neutral-900">
|
||||||
|
Akte nicht gefunden
|
||||||
|
</p>
|
||||||
|
<p className="mt-1 text-sm text-neutral-500">
|
||||||
|
Die Akte existiert nicht oder Sie haben keine Berechtigung.
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
href="/cases"
|
||||||
|
className="mt-4 inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
<ArrowLeft className="h-3.5 w-3.5" />
|
||||||
|
Zurück zu Akten
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const deadlines = Array.isArray(deadlinesData?.deadlines) ? deadlinesData.deadlines : [];
|
||||||
|
const documents = Array.isArray(documentsData) ? documentsData : [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="animate-fade-in">
|
||||||
|
<Link
|
||||||
|
href="/cases"
|
||||||
|
className="mb-4 inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
<ArrowLeft className="h-3.5 w-3.5" />
|
||||||
|
Zurück zu Akten
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
||||||
|
<div>
|
||||||
|
<div className="flex flex-wrap 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"}`}
|
||||||
|
>
|
||||||
|
{STATUS_LABEL[caseDetail.status] ?? caseDetail.status}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="mt-1 flex flex-wrap gap-x-4 gap-y-1 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-1 overflow-x-auto sm:gap-4">
|
||||||
|
{TABS.map((tab) => (
|
||||||
|
<button
|
||||||
|
key={tab.key}
|
||||||
|
onClick={() => setActiveTab(tab.key)}
|
||||||
|
className={`inline-flex shrink-0 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" && Array.isArray(caseDetail.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={Array.isArray(caseDetail.recent_events) ? caseDetail.recent_events : []} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{activeTab === "deadlines" && (
|
||||||
|
<DeadlinesList deadlines={deadlines} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{activeTab === "documents" && (
|
||||||
|
<DocumentsList documents={documents} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{activeTab === "parties" && (
|
||||||
|
<PartyList caseId={id} parties={Array.isArray(caseDetail.parties) ? caseDetail.parties : []} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DeadlinesList({ deadlines }: { deadlines: Deadline[] }) {
|
||||||
|
if (deadlines.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col items-center py-8 text-center">
|
||||||
|
<div className="rounded-xl bg-neutral-100 p-3">
|
||||||
|
<Clock className="h-5 w-5 text-neutral-400" />
|
||||||
|
</div>
|
||||||
|
<p className="mt-2 text-sm text-neutral-500">
|
||||||
|
Keine Fristen vorhanden.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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",
|
||||||
|
};
|
||||||
|
|
||||||
|
const DEADLINE_STATUS_LABEL: Record<string, string> = {
|
||||||
|
pending: "Offen",
|
||||||
|
completed: "Erledigt",
|
||||||
|
overdue: "Überfällig",
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-2">
|
||||||
|
{deadlines.map((d) => (
|
||||||
|
<div
|
||||||
|
key={d.id}
|
||||||
|
className="flex flex-col gap-2 rounded-md border border-neutral-200 bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between"
|
||||||
|
>
|
||||||
|
<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"}`}
|
||||||
|
>
|
||||||
|
{DEADLINE_STATUS_LABEL[d.status] ?? d.status}
|
||||||
|
</span>
|
||||||
|
<span className="whitespace-nowrap 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 (
|
||||||
|
<div className="flex flex-col items-center py-8 text-center">
|
||||||
|
<div className="rounded-xl bg-neutral-100 p-3">
|
||||||
|
<FileText className="h-5 w-5 text-neutral-400" />
|
||||||
|
</div>
|
||||||
|
<p className="mt-2 text-sm text-neutral-500">
|
||||||
|
Keine Dokumente vorhanden.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
Herunterladen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useParams } from "next/navigation";
|
|
||||||
import { api } from "@/lib/api";
|
|
||||||
import type { Case, Party } from "@/lib/types";
|
|
||||||
import { PartyList } from "@/components/cases/PartyList";
|
|
||||||
import { Loader2 } from "lucide-react";
|
|
||||||
|
|
||||||
interface CaseDetail extends Case {
|
|
||||||
parties: Party[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ParteienPage() {
|
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
|
|
||||||
const { data: caseDetail, isLoading } = useQuery({
|
|
||||||
queryKey: ["case", id],
|
|
||||||
queryFn: () => api.get<CaseDetail>(`/cases/${id}`),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center py-8">
|
|
||||||
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const parties = Array.isArray(caseDetail?.parties)
|
|
||||||
? caseDetail.parties
|
|
||||||
: [];
|
|
||||||
|
|
||||||
return <PartyList caseId={id} parties={parties} />;
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { useParams } from "next/navigation";
|
|
||||||
import { api } from "@/lib/api";
|
|
||||||
import type { Case, CaseEvent } from "@/lib/types";
|
|
||||||
import { CaseTimeline } from "@/components/cases/CaseTimeline";
|
|
||||||
import { Loader2 } from "lucide-react";
|
|
||||||
|
|
||||||
interface CaseDetail extends Case {
|
|
||||||
recent_events: CaseEvent[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function VerlaufPage() {
|
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
|
|
||||||
const { data: caseDetail, isLoading } = useQuery({
|
|
||||||
queryKey: ["case", id],
|
|
||||||
queryFn: () => api.get<CaseDetail>(`/cases/${id}`),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center py-8">
|
|
||||||
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const events = Array.isArray(caseDetail?.recent_events)
|
|
||||||
? caseDetail.recent_events
|
|
||||||
: [];
|
|
||||||
|
|
||||||
return <CaseTimeline events={events} />;
|
|
||||||
}
|
|
||||||
250
frontend/src/app/(app)/fristen/[id]/page.tsx
Normal file
250
frontend/src/app/(app)/fristen/[id]/page.tsx
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useParams, useRouter } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Deadline } from "@/lib/types";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
|
import { NotesList } from "@/components/notes/NotesList";
|
||||||
|
import { Skeleton } from "@/components/ui/Skeleton";
|
||||||
|
import { format, parseISO, formatDistanceToNow, isPast } from "date-fns";
|
||||||
|
import { de } from "date-fns/locale";
|
||||||
|
import {
|
||||||
|
AlertTriangle,
|
||||||
|
CheckCircle2,
|
||||||
|
Clock,
|
||||||
|
ExternalLink,
|
||||||
|
} from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
interface DeadlineDetail extends Deadline {
|
||||||
|
case_number?: string;
|
||||||
|
case_title?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const STATUS_CONFIG: Record<
|
||||||
|
string,
|
||||||
|
{ label: string; bg: string; icon: typeof Clock }
|
||||||
|
> = {
|
||||||
|
pending: { label: "Offen", bg: "bg-amber-50 text-amber-700", icon: Clock },
|
||||||
|
completed: {
|
||||||
|
label: "Erledigt",
|
||||||
|
bg: "bg-emerald-50 text-emerald-700",
|
||||||
|
icon: CheckCircle2,
|
||||||
|
},
|
||||||
|
overdue: {
|
||||||
|
label: "Ueberfaellig",
|
||||||
|
bg: "bg-red-50 text-red-700",
|
||||||
|
icon: AlertTriangle,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
function getEffectiveStatus(d: DeadlineDetail): string {
|
||||||
|
if (d.status === "completed") return "completed";
|
||||||
|
if (isPast(parseISO(d.due_date))) return "overdue";
|
||||||
|
return "pending";
|
||||||
|
}
|
||||||
|
|
||||||
|
function DetailSkeleton() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Skeleton className="h-4 w-48" />
|
||||||
|
<div className="mt-6 space-y-4">
|
||||||
|
<Skeleton className="h-8 w-64" />
|
||||||
|
<Skeleton className="h-4 w-40" />
|
||||||
|
<Skeleton className="h-32 rounded-lg" />
|
||||||
|
<Skeleton className="h-48 rounded-lg" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function DeadlineDetailPage() {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
const router = useRouter();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: deadline,
|
||||||
|
isLoading,
|
||||||
|
error,
|
||||||
|
} = useQuery({
|
||||||
|
queryKey: ["deadline", id],
|
||||||
|
queryFn: () => api.get<DeadlineDetail>(`/deadlines/${id}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
const completeMutation = useMutation({
|
||||||
|
mutationFn: () => api.patch<Deadline>(`/deadlines/${id}/complete`),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["deadline", id] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["deadlines"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["dashboard"] });
|
||||||
|
toast.success("Frist als erledigt markiert");
|
||||||
|
},
|
||||||
|
onError: () => toast.error("Fehler beim Abschliessen der Frist"),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading) return <DetailSkeleton />;
|
||||||
|
|
||||||
|
if (error || !deadline) {
|
||||||
|
return (
|
||||||
|
<div className="py-12 text-center">
|
||||||
|
<div className="mx-auto mb-3 w-fit rounded-xl bg-red-50 p-3">
|
||||||
|
<AlertTriangle className="h-6 w-6 text-red-500" />
|
||||||
|
</div>
|
||||||
|
<p className="text-sm font-medium text-neutral-900">
|
||||||
|
Frist nicht gefunden
|
||||||
|
</p>
|
||||||
|
<p className="mt-1 text-sm text-neutral-500">
|
||||||
|
Die Frist existiert nicht oder Sie haben keine Berechtigung.
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
href="/fristen"
|
||||||
|
className="mt-4 inline-block text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
Zurueck zu Fristen
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const status = getEffectiveStatus(deadline);
|
||||||
|
const config = STATUS_CONFIG[status] ?? STATUS_CONFIG.pending;
|
||||||
|
const StatusIcon = config.icon;
|
||||||
|
const dueDate = parseISO(deadline.due_date);
|
||||||
|
const relativeTime = formatDistanceToNow(dueDate, {
|
||||||
|
addSuffix: true,
|
||||||
|
locale: de,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="animate-fade-in">
|
||||||
|
<Breadcrumb
|
||||||
|
items={[
|
||||||
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
|
{ label: "Fristen", href: "/fristen" },
|
||||||
|
{ label: deadline.title },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Header */}
|
||||||
|
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
||||||
|
<div>
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<span
|
||||||
|
className={`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium ${config.bg}`}
|
||||||
|
>
|
||||||
|
<StatusIcon className="h-3 w-3" />
|
||||||
|
{config.label}
|
||||||
|
</span>
|
||||||
|
<h1 className="text-lg font-semibold text-neutral-900">
|
||||||
|
{deadline.title}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
{deadline.description && (
|
||||||
|
<p className="mt-1 text-sm text-neutral-500">
|
||||||
|
{deadline.description}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{deadline.status !== "completed" && (
|
||||||
|
<button
|
||||||
|
onClick={() => completeMutation.mutate()}
|
||||||
|
disabled={completeMutation.isPending}
|
||||||
|
className="shrink-0 rounded-md bg-emerald-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-emerald-700 disabled:opacity-50"
|
||||||
|
>
|
||||||
|
{completeMutation.isPending ? "Wird erledigt..." : "Erledigen"}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Due date */}
|
||||||
|
<div className="mt-4 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<div className="flex items-baseline gap-2">
|
||||||
|
<span className="text-sm font-medium text-neutral-900">
|
||||||
|
Faellig: {format(dueDate, "d. MMMM yyyy", { locale: de })}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
className={`text-xs ${status === "overdue" ? "font-medium text-red-600" : "text-neutral-500"}`}
|
||||||
|
>
|
||||||
|
({relativeTime})
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{deadline.warning_date && (
|
||||||
|
<p className="mt-1 text-xs text-neutral-500">
|
||||||
|
Warnung am:{" "}
|
||||||
|
{format(parseISO(deadline.warning_date), "d. MMMM yyyy", {
|
||||||
|
locale: de,
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{deadline.original_due_date &&
|
||||||
|
deadline.original_due_date !== deadline.due_date && (
|
||||||
|
<p className="mt-1 text-xs text-neutral-500">
|
||||||
|
Urspruengliches Datum:{" "}
|
||||||
|
{format(parseISO(deadline.original_due_date), "d. MMMM yyyy", {
|
||||||
|
locale: de,
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{deadline.completed_at && (
|
||||||
|
<p className="mt-1 text-xs text-emerald-600">
|
||||||
|
Erledigt am:{" "}
|
||||||
|
{format(parseISO(deadline.completed_at), "d. MMMM yyyy, HH:mm", {
|
||||||
|
locale: de,
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Case context */}
|
||||||
|
{deadline.case_id && (
|
||||||
|
<div className="mt-3 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<p className="text-xs font-medium uppercase tracking-wide text-neutral-400">
|
||||||
|
Akte
|
||||||
|
</p>
|
||||||
|
<p className="mt-0.5 text-sm text-neutral-900">
|
||||||
|
{deadline.case_number
|
||||||
|
? `Az. ${deadline.case_number}`
|
||||||
|
: "Verknuepfte Akte"}
|
||||||
|
{deadline.case_title && ` — ${deadline.case_title}`}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Link
|
||||||
|
href={`/cases/${deadline.case_id}`}
|
||||||
|
className="flex items-center gap-1 text-xs text-neutral-500 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
Zur Akte
|
||||||
|
<ExternalLink className="h-3 w-3" />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Source info */}
|
||||||
|
{deadline.source && deadline.source !== "manual" && (
|
||||||
|
<div className="mt-3 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<p className="text-xs font-medium uppercase tracking-wide text-neutral-400">
|
||||||
|
Quelle
|
||||||
|
</p>
|
||||||
|
<p className="mt-0.5 text-sm text-neutral-700">
|
||||||
|
{deadline.source === "calculated"
|
||||||
|
? "Berechnet"
|
||||||
|
: deadline.source === "caldav"
|
||||||
|
? "CalDAV Sync"
|
||||||
|
: deadline.source}
|
||||||
|
{deadline.rule_id && ` (Regel: ${deadline.rule_id})`}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Notes */}
|
||||||
|
<div className="mt-6">
|
||||||
|
<NotesList parentType="deadline" parentId={id} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
180
frontend/src/app/(app)/fristen/neu/page.tsx
Normal file
180
frontend/src/app/(app)/fristen/neu/page.tsx
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Case, Deadline } from "@/lib/types";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
const inputClass =
|
||||||
|
"w-full rounded-md border border-neutral-200 px-3 py-1.5 text-sm outline-none focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400";
|
||||||
|
const labelClass = "mb-1 block text-xs font-medium text-neutral-600";
|
||||||
|
|
||||||
|
export default function NewDeadlinePage() {
|
||||||
|
const router = useRouter();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
const [caseId, setCaseId] = useState("");
|
||||||
|
const [title, setTitle] = useState("");
|
||||||
|
const [description, setDescription] = useState("");
|
||||||
|
const [dueDate, setDueDate] = useState("");
|
||||||
|
const [warningDate, setWarningDate] = useState("");
|
||||||
|
const [notes, setNotes] = useState("");
|
||||||
|
|
||||||
|
const { data: casesData } = useQuery({
|
||||||
|
queryKey: ["cases"],
|
||||||
|
queryFn: () => api.get<{ cases: Case[]; total: number } | Case[]>("/cases"),
|
||||||
|
});
|
||||||
|
|
||||||
|
const cases = Array.isArray(casesData)
|
||||||
|
? casesData
|
||||||
|
: Array.isArray(casesData?.cases)
|
||||||
|
? casesData.cases
|
||||||
|
: [];
|
||||||
|
|
||||||
|
const createMutation = useMutation({
|
||||||
|
mutationFn: (body: Record<string, unknown>) =>
|
||||||
|
api.post<Deadline>(`/cases/${caseId}/deadlines`, body),
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["deadlines"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["dashboard"] });
|
||||||
|
toast.success("Frist erstellt");
|
||||||
|
router.push(`/fristen/${data.id}`);
|
||||||
|
},
|
||||||
|
onError: () => toast.error("Fehler beim Erstellen der Frist"),
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleSubmit(e: React.FormEvent) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!caseId || !title.trim() || !dueDate) return;
|
||||||
|
|
||||||
|
const body: Record<string, unknown> = {
|
||||||
|
title: title.trim(),
|
||||||
|
due_date: new Date(dueDate).toISOString(),
|
||||||
|
source: "manual",
|
||||||
|
};
|
||||||
|
if (description.trim()) body.description = description.trim();
|
||||||
|
if (warningDate) body.warning_date = new Date(warningDate).toISOString();
|
||||||
|
if (notes.trim()) body.notes = notes.trim();
|
||||||
|
|
||||||
|
createMutation.mutate(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="animate-fade-in">
|
||||||
|
<Breadcrumb
|
||||||
|
items={[
|
||||||
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
|
{ label: "Fristen", href: "/fristen" },
|
||||||
|
{ label: "Neue Frist" },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<h1 className="text-lg font-semibold text-neutral-900">
|
||||||
|
Neue Frist anlegen
|
||||||
|
</h1>
|
||||||
|
<p className="mt-0.5 text-sm text-neutral-500">
|
||||||
|
Erstellen Sie eine neue Frist fuer eine Akte.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
className="mt-6 max-w-lg space-y-4 rounded-lg border border-neutral-200 bg-white p-5"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Akte *</label>
|
||||||
|
<select
|
||||||
|
value={caseId}
|
||||||
|
onChange={(e) => setCaseId(e.target.value)}
|
||||||
|
required
|
||||||
|
className={inputClass}
|
||||||
|
>
|
||||||
|
<option value="">Akte auswaehlen...</option>
|
||||||
|
{cases.map((c) => (
|
||||||
|
<option key={c.id} value={c.id}>
|
||||||
|
{c.case_number} — {c.title}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Bezeichnung *</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
required
|
||||||
|
className={inputClass}
|
||||||
|
placeholder="z.B. Klageschrift einreichen"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Beschreibung</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={description}
|
||||||
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
|
className={inputClass}
|
||||||
|
placeholder="Optionale Beschreibung"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Faellig am *</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
value={dueDate}
|
||||||
|
onChange={(e) => setDueDate(e.target.value)}
|
||||||
|
required
|
||||||
|
className={inputClass}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Warnung am</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
value={warningDate}
|
||||||
|
onChange={(e) => setWarningDate(e.target.value)}
|
||||||
|
className={inputClass}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Notizen</label>
|
||||||
|
<textarea
|
||||||
|
value={notes}
|
||||||
|
onChange={(e) => setNotes(e.target.value)}
|
||||||
|
rows={3}
|
||||||
|
className={inputClass}
|
||||||
|
placeholder="Optionale Notizen zur Frist"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-end gap-2 pt-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => router.push("/fristen")}
|
||||||
|
className="rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm text-neutral-700 hover:bg-neutral-50"
|
||||||
|
>
|
||||||
|
Abbrechen
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={
|
||||||
|
createMutation.isPending || !caseId || !title.trim() || !dueDate
|
||||||
|
}
|
||||||
|
className="rounded-md bg-neutral-900 px-3 py-1.5 text-sm font-medium text-white hover:bg-neutral-800 disabled:opacity-50"
|
||||||
|
>
|
||||||
|
{createMutation.isPending ? "Erstellen..." : "Frist anlegen"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
201
frontend/src/app/(app)/termine/[id]/page.tsx
Normal file
201
frontend/src/app/(app)/termine/[id]/page.tsx
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Appointment } from "@/lib/types";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
|
import { NotesList } from "@/components/notes/NotesList";
|
||||||
|
import { Skeleton } from "@/components/ui/Skeleton";
|
||||||
|
import { format, parseISO } from "date-fns";
|
||||||
|
import { de } from "date-fns/locale";
|
||||||
|
import {
|
||||||
|
AlertTriangle,
|
||||||
|
Calendar,
|
||||||
|
ExternalLink,
|
||||||
|
MapPin,
|
||||||
|
} from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
interface AppointmentDetail extends Appointment {
|
||||||
|
case_number?: string;
|
||||||
|
case_title?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TYPE_LABELS: Record<string, string> = {
|
||||||
|
hearing: "Verhandlung",
|
||||||
|
meeting: "Besprechung",
|
||||||
|
consultation: "Beratung",
|
||||||
|
deadline_hearing: "Fristanhoerung",
|
||||||
|
other: "Sonstiges",
|
||||||
|
};
|
||||||
|
|
||||||
|
const TYPE_COLORS: Record<string, string> = {
|
||||||
|
hearing: "bg-blue-50 text-blue-700",
|
||||||
|
meeting: "bg-violet-50 text-violet-700",
|
||||||
|
consultation: "bg-emerald-50 text-emerald-700",
|
||||||
|
deadline_hearing: "bg-amber-50 text-amber-700",
|
||||||
|
other: "bg-neutral-100 text-neutral-600",
|
||||||
|
};
|
||||||
|
|
||||||
|
function DetailSkeleton() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Skeleton className="h-4 w-48" />
|
||||||
|
<div className="mt-6 space-y-4">
|
||||||
|
<Skeleton className="h-8 w-64" />
|
||||||
|
<Skeleton className="h-4 w-40" />
|
||||||
|
<Skeleton className="h-32 rounded-lg" />
|
||||||
|
<Skeleton className="h-48 rounded-lg" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AppointmentDetailPage() {
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: appointment,
|
||||||
|
isLoading,
|
||||||
|
error,
|
||||||
|
} = useQuery({
|
||||||
|
queryKey: ["appointment", id],
|
||||||
|
queryFn: () => api.get<AppointmentDetail>(`/appointments/${id}`),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading) return <DetailSkeleton />;
|
||||||
|
|
||||||
|
if (error || !appointment) {
|
||||||
|
return (
|
||||||
|
<div className="py-12 text-center">
|
||||||
|
<div className="mx-auto mb-3 w-fit rounded-xl bg-red-50 p-3">
|
||||||
|
<AlertTriangle className="h-6 w-6 text-red-500" />
|
||||||
|
</div>
|
||||||
|
<p className="text-sm font-medium text-neutral-900">
|
||||||
|
Termin nicht gefunden
|
||||||
|
</p>
|
||||||
|
<p className="mt-1 text-sm text-neutral-500">
|
||||||
|
Der Termin existiert nicht oder Sie haben keine Berechtigung.
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
href="/termine"
|
||||||
|
className="mt-4 inline-block text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
Zurueck zu Termine
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const startDate = parseISO(appointment.start_at);
|
||||||
|
const typeBadge = appointment.appointment_type
|
||||||
|
? TYPE_COLORS[appointment.appointment_type] ?? TYPE_COLORS.other
|
||||||
|
: null;
|
||||||
|
const typeLabel = appointment.appointment_type
|
||||||
|
? TYPE_LABELS[appointment.appointment_type] ?? appointment.appointment_type
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="animate-fade-in">
|
||||||
|
<Breadcrumb
|
||||||
|
items={[
|
||||||
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
|
{ label: "Termine", href: "/termine" },
|
||||||
|
{ label: appointment.title },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Header */}
|
||||||
|
<div>
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<h1 className="text-lg font-semibold text-neutral-900">
|
||||||
|
{appointment.title}
|
||||||
|
</h1>
|
||||||
|
{typeBadge && typeLabel && (
|
||||||
|
<span
|
||||||
|
className={`inline-block rounded-full px-2.5 py-0.5 text-xs font-medium ${typeBadge}`}
|
||||||
|
>
|
||||||
|
{typeLabel}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Date & Time */}
|
||||||
|
<div className="mt-4 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Calendar className="h-4 w-4 text-neutral-400" />
|
||||||
|
<span className="text-sm font-medium text-neutral-900">
|
||||||
|
{format(startDate, "EEEE, d. MMMM yyyy", { locale: de })}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p className="mt-1 pl-6 text-sm text-neutral-600">
|
||||||
|
{format(startDate, "HH:mm", { locale: de })} Uhr
|
||||||
|
{appointment.end_at && (
|
||||||
|
<>
|
||||||
|
{" "}
|
||||||
|
– {format(parseISO(appointment.end_at), "HH:mm", { locale: de })}{" "}
|
||||||
|
Uhr
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Location */}
|
||||||
|
{appointment.location && (
|
||||||
|
<div className="mt-3 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<MapPin className="h-4 w-4 text-neutral-400" />
|
||||||
|
<span className="text-sm text-neutral-900">
|
||||||
|
{appointment.location}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Case context */}
|
||||||
|
{appointment.case_id && (
|
||||||
|
<div className="mt-3 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<p className="text-xs font-medium uppercase tracking-wide text-neutral-400">
|
||||||
|
Akte
|
||||||
|
</p>
|
||||||
|
<p className="mt-0.5 text-sm text-neutral-900">
|
||||||
|
{appointment.case_number
|
||||||
|
? `Az. ${appointment.case_number}`
|
||||||
|
: "Verknuepfte Akte"}
|
||||||
|
{appointment.case_title && ` — ${appointment.case_title}`}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Link
|
||||||
|
href={`/cases/${appointment.case_id}`}
|
||||||
|
className="flex items-center gap-1 text-xs text-neutral-500 transition-colors hover:text-neutral-700"
|
||||||
|
>
|
||||||
|
Zur Akte
|
||||||
|
<ExternalLink className="h-3 w-3" />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
{appointment.description && (
|
||||||
|
<div className="mt-3 rounded-lg border border-neutral-200 bg-white px-4 py-3">
|
||||||
|
<p className="text-xs font-medium uppercase tracking-wide text-neutral-400">
|
||||||
|
Beschreibung
|
||||||
|
</p>
|
||||||
|
<p className="mt-1 whitespace-pre-wrap text-sm text-neutral-700">
|
||||||
|
{appointment.description}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Notes */}
|
||||||
|
<div className="mt-6">
|
||||||
|
<NotesList parentType="appointment" parentId={id} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
206
frontend/src/app/(app)/termine/neu/page.tsx
Normal file
206
frontend/src/app/(app)/termine/neu/page.tsx
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { api } from "@/lib/api";
|
||||||
|
import type { Case, Appointment } from "@/lib/types";
|
||||||
|
import { Breadcrumb } from "@/components/layout/Breadcrumb";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
const APPOINTMENT_TYPES = [
|
||||||
|
{ value: "hearing", label: "Verhandlung" },
|
||||||
|
{ value: "meeting", label: "Besprechung" },
|
||||||
|
{ value: "consultation", label: "Beratung" },
|
||||||
|
{ value: "deadline_hearing", label: "Fristanhoerung" },
|
||||||
|
{ value: "other", label: "Sonstiges" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const inputClass =
|
||||||
|
"w-full rounded-md border border-neutral-200 px-3 py-1.5 text-sm outline-none focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400";
|
||||||
|
const labelClass = "mb-1 block text-xs font-medium text-neutral-600";
|
||||||
|
|
||||||
|
export default function NewAppointmentPage() {
|
||||||
|
const router = useRouter();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
const [caseId, setCaseId] = useState("");
|
||||||
|
const [title, setTitle] = useState("");
|
||||||
|
const [description, setDescription] = useState("");
|
||||||
|
const [startAt, setStartAt] = useState("");
|
||||||
|
const [endAt, setEndAt] = useState("");
|
||||||
|
const [location, setLocation] = useState("");
|
||||||
|
const [appointmentType, setAppointmentType] = useState("");
|
||||||
|
|
||||||
|
const { data: casesData } = useQuery({
|
||||||
|
queryKey: ["cases"],
|
||||||
|
queryFn: () => api.get<{ cases: Case[]; total: number } | Case[]>("/cases"),
|
||||||
|
});
|
||||||
|
|
||||||
|
const cases = Array.isArray(casesData)
|
||||||
|
? casesData
|
||||||
|
: Array.isArray(casesData?.cases)
|
||||||
|
? casesData.cases
|
||||||
|
: [];
|
||||||
|
|
||||||
|
const createMutation = useMutation({
|
||||||
|
mutationFn: (body: Record<string, unknown>) =>
|
||||||
|
api.post<Appointment>("/appointments", body),
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["appointments"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["dashboard"] });
|
||||||
|
toast.success("Termin erstellt");
|
||||||
|
router.push(`/termine/${data.id}`);
|
||||||
|
},
|
||||||
|
onError: () => toast.error("Fehler beim Erstellen des Termins"),
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleSubmit(e: React.FormEvent) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!title.trim() || !startAt) return;
|
||||||
|
|
||||||
|
const body: Record<string, unknown> = {
|
||||||
|
title: title.trim(),
|
||||||
|
start_at: new Date(startAt).toISOString(),
|
||||||
|
};
|
||||||
|
if (description.trim()) body.description = description.trim();
|
||||||
|
if (endAt) body.end_at = new Date(endAt).toISOString();
|
||||||
|
if (location.trim()) body.location = location.trim();
|
||||||
|
if (appointmentType) body.appointment_type = appointmentType;
|
||||||
|
if (caseId) body.case_id = caseId;
|
||||||
|
|
||||||
|
createMutation.mutate(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="animate-fade-in">
|
||||||
|
<Breadcrumb
|
||||||
|
items={[
|
||||||
|
{ label: "Dashboard", href: "/dashboard" },
|
||||||
|
{ label: "Termine", href: "/termine" },
|
||||||
|
{ label: "Neuer Termin" },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<h1 className="text-lg font-semibold text-neutral-900">
|
||||||
|
Neuer Termin
|
||||||
|
</h1>
|
||||||
|
<p className="mt-0.5 text-sm text-neutral-500">
|
||||||
|
Erstellen Sie einen neuen Termin.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
className="mt-6 max-w-lg space-y-4 rounded-lg border border-neutral-200 bg-white p-5"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Titel *</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
required
|
||||||
|
className={inputClass}
|
||||||
|
placeholder="z.B. Muendliche Verhandlung"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Beginn *</label>
|
||||||
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
value={startAt}
|
||||||
|
onChange={(e) => setStartAt(e.target.value)}
|
||||||
|
required
|
||||||
|
className={inputClass}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Ende</label>
|
||||||
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
value={endAt}
|
||||||
|
onChange={(e) => setEndAt(e.target.value)}
|
||||||
|
className={inputClass}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Typ</label>
|
||||||
|
<select
|
||||||
|
value={appointmentType}
|
||||||
|
onChange={(e) => setAppointmentType(e.target.value)}
|
||||||
|
className={inputClass}
|
||||||
|
>
|
||||||
|
<option value="">Kein Typ</option>
|
||||||
|
{APPOINTMENT_TYPES.map((t) => (
|
||||||
|
<option key={t.value} value={t.value}>
|
||||||
|
{t.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Akte (optional)</label>
|
||||||
|
<select
|
||||||
|
value={caseId}
|
||||||
|
onChange={(e) => setCaseId(e.target.value)}
|
||||||
|
className={inputClass}
|
||||||
|
>
|
||||||
|
<option value="">Keine Akte</option>
|
||||||
|
{cases.map((c) => (
|
||||||
|
<option key={c.id} value={c.id}>
|
||||||
|
{c.case_number} — {c.title}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Ort</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={location}
|
||||||
|
onChange={(e) => setLocation(e.target.value)}
|
||||||
|
className={inputClass}
|
||||||
|
placeholder="z.B. UPC Muenchen, Saal 3"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Beschreibung</label>
|
||||||
|
<textarea
|
||||||
|
value={description}
|
||||||
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
|
rows={3}
|
||||||
|
className={inputClass}
|
||||||
|
placeholder="Optionale Beschreibung zum Termin"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-end gap-2 pt-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => router.push("/termine")}
|
||||||
|
className="rounded-md border border-neutral-200 bg-white px-3 py-1.5 text-sm text-neutral-700 hover:bg-neutral-50"
|
||||||
|
>
|
||||||
|
Abbrechen
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={
|
||||||
|
createMutation.isPending || !title.trim() || !startAt
|
||||||
|
}
|
||||||
|
className="rounded-md bg-neutral-900 px-3 py-1.5 text-sm font-medium text-white hover:bg-neutral-800 disabled:opacity-50"
|
||||||
|
>
|
||||||
|
{createMutation.isPending ? "Erstellen..." : "Termin anlegen"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,16 +6,12 @@ export interface BreadcrumbItem {
|
|||||||
href?: string;
|
href?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BreadcrumbProps {
|
export function Breadcrumb({ items }: { items: BreadcrumbItem[] }) {
|
||||||
items: BreadcrumbItem[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Breadcrumb({ items }: BreadcrumbProps) {
|
|
||||||
return (
|
return (
|
||||||
<nav className="flex items-center gap-1 text-sm text-neutral-400">
|
<nav className="mb-4 flex items-center gap-1 text-sm text-neutral-500">
|
||||||
{items.map((item, i) => (
|
{items.map((item, i) => (
|
||||||
<span key={i} className="flex items-center gap-1">
|
<span key={i} className="flex items-center gap-1">
|
||||||
{i > 0 && <ChevronRight className="h-3.5 w-3.5" />}
|
{i > 0 && <ChevronRight className="h-3.5 w-3.5 text-neutral-300" />}
|
||||||
{item.href ? (
|
{item.href ? (
|
||||||
<Link
|
<Link
|
||||||
href={item.href}
|
href={item.href}
|
||||||
@@ -24,7 +20,7 @@ export function Breadcrumb({ items }: BreadcrumbProps) {
|
|||||||
{item.label}
|
{item.label}
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-neutral-600">{item.label}</span>
|
<span className="font-medium text-neutral-900">{item.label}</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,55 +1,49 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { format } from "date-fns";
|
|
||||||
import { de } from "date-fns/locale";
|
|
||||||
import { Plus, Pencil, Trash2, X, Loader2, StickyNote } from "lucide-react";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { api } from "@/lib/api";
|
import { api } from "@/lib/api";
|
||||||
import type { Note } from "@/lib/types";
|
import type { Note } from "@/lib/types";
|
||||||
|
import { format, parseISO } from "date-fns";
|
||||||
type ParentType = "case" | "deadline" | "appointment" | "case_event";
|
import { de } from "date-fns/locale";
|
||||||
|
import { Plus, Pencil, Trash2, X, Check, MessageSquare } from "lucide-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
interface NotesListProps {
|
interface NotesListProps {
|
||||||
parentType: ParentType;
|
parentType: "case" | "deadline" | "appointment" | "case_event";
|
||||||
parentId: string;
|
parentId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PARENT_PARAM: Record<ParentType, string> = {
|
|
||||||
case: "case_id",
|
|
||||||
deadline: "deadline_id",
|
|
||||||
appointment: "appointment_id",
|
|
||||||
case_event: "case_event_id",
|
|
||||||
};
|
|
||||||
|
|
||||||
export function NotesList({ parentType, parentId }: NotesListProps) {
|
export function NotesList({ parentType, parentId }: NotesListProps) {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const queryKey = ["notes", parentType, parentId];
|
const queryKey = ["notes", parentType, parentId];
|
||||||
const paramKey = PARENT_PARAM[parentType];
|
|
||||||
|
|
||||||
const [showForm, setShowForm] = useState(false);
|
|
||||||
const [newContent, setNewContent] = useState("");
|
const [newContent, setNewContent] = useState("");
|
||||||
|
const [showNew, setShowNew] = useState(false);
|
||||||
const [editingId, setEditingId] = useState<string | null>(null);
|
const [editingId, setEditingId] = useState<string | null>(null);
|
||||||
const [editContent, setEditContent] = useState("");
|
const [editContent, setEditContent] = useState("");
|
||||||
|
|
||||||
const { data, isLoading } = useQuery({
|
const { data: notes, isLoading } = useQuery({
|
||||||
queryKey,
|
queryKey,
|
||||||
queryFn: () => api.get<Note[]>(`/notes?${paramKey}=${parentId}`),
|
queryFn: () =>
|
||||||
|
api.get<Note[]>(`/notes?${parentType}_id=${parentId}`),
|
||||||
});
|
});
|
||||||
|
|
||||||
const notes = Array.isArray(data) ? data : [];
|
|
||||||
|
|
||||||
const createMutation = useMutation({
|
const createMutation = useMutation({
|
||||||
mutationFn: (content: string) =>
|
mutationFn: (content: string) => {
|
||||||
api.post<Note>("/notes", { [paramKey]: parentId, content }),
|
const body: Record<string, string> = {
|
||||||
|
content,
|
||||||
|
[`${parentType}_id`]: parentId,
|
||||||
|
};
|
||||||
|
return api.post<Note>("/notes", body);
|
||||||
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey });
|
queryClient.invalidateQueries({ queryKey });
|
||||||
setNewContent("");
|
setNewContent("");
|
||||||
setShowForm(false);
|
setShowNew(false);
|
||||||
toast.success("Notiz erstellt");
|
toast.success("Notiz erstellt");
|
||||||
},
|
},
|
||||||
onError: () => toast.error("Fehler beim Erstellen"),
|
onError: () => toast.error("Fehler beim Erstellen der Notiz"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateMutation = useMutation({
|
const updateMutation = useMutation({
|
||||||
@@ -60,7 +54,7 @@ export function NotesList({ parentType, parentId }: NotesListProps) {
|
|||||||
setEditingId(null);
|
setEditingId(null);
|
||||||
toast.success("Notiz aktualisiert");
|
toast.success("Notiz aktualisiert");
|
||||||
},
|
},
|
||||||
onError: () => toast.error("Fehler beim Aktualisieren"),
|
onError: () => toast.error("Fehler beim Aktualisieren der Notiz"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
const deleteMutation = useMutation({
|
||||||
@@ -69,32 +63,34 @@ export function NotesList({ parentType, parentId }: NotesListProps) {
|
|||||||
queryClient.invalidateQueries({ queryKey });
|
queryClient.invalidateQueries({ queryKey });
|
||||||
toast.success("Notiz geloescht");
|
toast.success("Notiz geloescht");
|
||||||
},
|
},
|
||||||
onError: () => toast.error("Fehler beim Loeschen"),
|
onError: () => toast.error("Fehler beim Loeschen der Notiz"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function handleCreate() {
|
||||||
|
if (!newContent.trim()) return;
|
||||||
|
createMutation.mutate(newContent.trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleUpdate(id: string) {
|
||||||
|
if (!editContent.trim()) return;
|
||||||
|
updateMutation.mutate({ id, content: editContent.trim() });
|
||||||
|
}
|
||||||
|
|
||||||
function startEdit(note: Note) {
|
function startEdit(note: Note) {
|
||||||
setEditingId(note.id);
|
setEditingId(note.id);
|
||||||
setEditContent(note.content);
|
setEditContent(note.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoading) {
|
const notesList = Array.isArray(notes) ? notes : [];
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center py-8">
|
|
||||||
<Loader2 className="h-5 w-5 animate-spin text-neutral-400" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="rounded-lg border border-neutral-200 bg-white">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between border-b border-neutral-100 px-4 py-3">
|
||||||
<h3 className="text-sm font-medium text-neutral-700">
|
<h3 className="text-sm font-medium text-neutral-900">Notizen</h3>
|
||||||
Notizen ({notes.length})
|
{!showNew && (
|
||||||
</h3>
|
|
||||||
{!showForm && (
|
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowForm(true)}
|
onClick={() => setShowNew(true)}
|
||||||
className="inline-flex items-center gap-1 text-sm text-neutral-500 transition-colors hover:text-neutral-700"
|
className="flex items-center gap-1 rounded-md px-2 py-1 text-xs text-neutral-500 transition-colors hover:bg-neutral-50 hover:text-neutral-700"
|
||||||
>
|
>
|
||||||
<Plus className="h-3.5 w-3.5" />
|
<Plus className="h-3.5 w-3.5" />
|
||||||
Neu
|
Neu
|
||||||
@@ -102,33 +98,30 @@ export function NotesList({ parentType, parentId }: NotesListProps) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{showForm && (
|
{showNew && (
|
||||||
<div className="mt-3 rounded-md border border-neutral-200 bg-neutral-50 p-3">
|
<div className="border-b border-neutral-100 p-4">
|
||||||
<textarea
|
<textarea
|
||||||
value={newContent}
|
value={newContent}
|
||||||
onChange={(e) => setNewContent(e.target.value)}
|
onChange={(e) => setNewContent(e.target.value)}
|
||||||
placeholder="Notiz eingeben..."
|
|
||||||
rows={3}
|
rows={3}
|
||||||
className="w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm outline-none transition-colors focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400"
|
|
||||||
autoFocus
|
autoFocus
|
||||||
|
placeholder="Notiz schreiben..."
|
||||||
|
className="w-full rounded-md border border-neutral-200 px-3 py-2 text-sm outline-none focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400"
|
||||||
/>
|
/>
|
||||||
<div className="mt-2 flex justify-end gap-2">
|
<div className="mt-2 flex justify-end gap-2">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowForm(false);
|
setShowNew(false);
|
||||||
setNewContent("");
|
setNewContent("");
|
||||||
}}
|
}}
|
||||||
className="rounded-md px-3 py-1.5 text-sm text-neutral-500 hover:bg-neutral-200"
|
className="rounded-md px-2.5 py-1 text-xs text-neutral-500 hover:bg-neutral-50"
|
||||||
>
|
>
|
||||||
Abbrechen
|
Abbrechen
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={handleCreate}
|
||||||
if (!newContent.trim()) return;
|
disabled={!newContent.trim() || createMutation.isPending}
|
||||||
createMutation.mutate(newContent.trim());
|
className="rounded-md bg-neutral-900 px-2.5 py-1 text-xs font-medium text-white hover:bg-neutral-800 disabled:opacity-50"
|
||||||
}}
|
|
||||||
disabled={createMutation.isPending || !newContent.trim()}
|
|
||||||
className="rounded-md bg-neutral-900 px-3 py-1.5 text-sm font-medium text-white hover:bg-neutral-800 disabled:opacity-50"
|
|
||||||
>
|
>
|
||||||
{createMutation.isPending ? "Speichern..." : "Speichern"}
|
{createMutation.isPending ? "Speichern..." : "Speichern"}
|
||||||
</button>
|
</button>
|
||||||
@@ -136,88 +129,81 @@ export function NotesList({ parentType, parentId }: NotesListProps) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{notes.length === 0 && !showForm && (
|
{isLoading ? (
|
||||||
<div className="mt-4 flex flex-col items-center py-6 text-center">
|
<div className="space-y-2 p-4">
|
||||||
<div className="rounded-xl bg-neutral-100 p-3">
|
{[1, 2].map((i) => (
|
||||||
<StickyNote className="h-5 w-5 text-neutral-400" />
|
<div key={i} className="h-12 animate-pulse rounded-md bg-neutral-100" />
|
||||||
</div>
|
))}
|
||||||
<p className="mt-2 text-sm text-neutral-500">
|
</div>
|
||||||
|
) : notesList.length === 0 ? (
|
||||||
|
<div className="flex flex-col items-center py-8 text-center">
|
||||||
|
<MessageSquare className="h-5 w-5 text-neutral-300" />
|
||||||
|
<p className="mt-2 text-sm text-neutral-400">
|
||||||
Keine Notizen vorhanden.
|
Keine Notizen vorhanden.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
) : (
|
||||||
|
<div className="divide-y divide-neutral-100">
|
||||||
<div className="mt-3 space-y-2">
|
{notesList.map((note) => (
|
||||||
{notes.map((note) => (
|
<div key={note.id} className="group px-4 py-3">
|
||||||
<div
|
{editingId === note.id ? (
|
||||||
key={note.id}
|
<div>
|
||||||
className="rounded-md border border-neutral-200 bg-white px-4 py-3"
|
<textarea
|
||||||
>
|
value={editContent}
|
||||||
{editingId === note.id ? (
|
onChange={(e) => setEditContent(e.target.value)}
|
||||||
<div>
|
rows={3}
|
||||||
<textarea
|
autoFocus
|
||||||
value={editContent}
|
className="w-full rounded-md border border-neutral-200 px-3 py-2 text-sm outline-none focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400"
|
||||||
onChange={(e) => setEditContent(e.target.value)}
|
/>
|
||||||
rows={3}
|
<div className="mt-2 flex justify-end gap-2">
|
||||||
className="w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm outline-none transition-colors focus:border-neutral-400 focus:ring-1 focus:ring-neutral-400"
|
|
||||||
autoFocus
|
|
||||||
/>
|
|
||||||
<div className="mt-2 flex justify-end gap-2">
|
|
||||||
<button
|
|
||||||
onClick={() => setEditingId(null)}
|
|
||||||
className="rounded-md px-3 py-1.5 text-sm text-neutral-500 hover:bg-neutral-100"
|
|
||||||
>
|
|
||||||
Abbrechen
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
if (!editContent.trim()) return;
|
|
||||||
updateMutation.mutate({
|
|
||||||
id: note.id,
|
|
||||||
content: editContent.trim(),
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
disabled={updateMutation.isPending || !editContent.trim()}
|
|
||||||
className="rounded-md bg-neutral-900 px-3 py-1.5 text-sm font-medium text-white hover:bg-neutral-800 disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{updateMutation.isPending ? "Speichern..." : "Speichern"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div>
|
|
||||||
<div className="flex items-start justify-between">
|
|
||||||
<p className="whitespace-pre-wrap text-sm text-neutral-800">
|
|
||||||
{note.content}
|
|
||||||
</p>
|
|
||||||
<div className="ml-3 flex shrink-0 gap-1">
|
|
||||||
<button
|
<button
|
||||||
onClick={() => startEdit(note)}
|
onClick={() => setEditingId(null)}
|
||||||
className="rounded p-1 text-neutral-300 transition-colors hover:bg-neutral-100 hover:text-neutral-600"
|
className="rounded-md p-1 text-neutral-400 hover:bg-neutral-50 hover:text-neutral-600"
|
||||||
title="Bearbeiten"
|
|
||||||
>
|
>
|
||||||
<Pencil className="h-3.5 w-3.5" />
|
<X className="h-3.5 w-3.5" />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => deleteMutation.mutate(note.id)}
|
onClick={() => handleUpdate(note.id)}
|
||||||
className="rounded p-1 text-neutral-300 transition-colors hover:bg-neutral-100 hover:text-red-500"
|
disabled={!editContent.trim() || updateMutation.isPending}
|
||||||
title="Loeschen"
|
className="rounded-md p-1 text-neutral-400 hover:bg-neutral-50 hover:text-green-600"
|
||||||
>
|
>
|
||||||
<Trash2 className="h-3.5 w-3.5" />
|
<Check className="h-3.5 w-3.5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-1 text-xs text-neutral-400">
|
) : (
|
||||||
{format(new Date(note.created_at), "d. MMM yyyy, HH:mm", {
|
<div>
|
||||||
locale: de,
|
<div className="flex items-start justify-between">
|
||||||
})}
|
<p className="whitespace-pre-wrap text-sm text-neutral-700">
|
||||||
{note.updated_at !== note.created_at && " (bearbeitet)"}
|
{note.content}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
<div className="ml-4 flex shrink-0 gap-1 opacity-0 transition-opacity group-hover:opacity-100">
|
||||||
)}
|
<button
|
||||||
</div>
|
onClick={() => startEdit(note)}
|
||||||
))}
|
className="rounded p-1 text-neutral-400 hover:bg-neutral-50 hover:text-neutral-600"
|
||||||
</div>
|
>
|
||||||
|
<Pencil className="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => deleteMutation.mutate(note.id)}
|
||||||
|
className="rounded p-1 text-neutral-400 hover:bg-red-50 hover:text-red-500"
|
||||||
|
>
|
||||||
|
<Trash2 className="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p className="mt-1 text-xs text-neutral-400">
|
||||||
|
{format(parseISO(note.created_at), "d. MMM yyyy, HH:mm", {
|
||||||
|
locale: de,
|
||||||
|
})}
|
||||||
|
{note.updated_at !== note.created_at && " (bearbeitet)"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,19 +176,6 @@ export interface CalDAVSyncResponse {
|
|||||||
last_sync_at?: null;
|
last_sync_at?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Note {
|
|
||||||
id: string;
|
|
||||||
tenant_id: string;
|
|
||||||
case_id?: string;
|
|
||||||
deadline_id?: string;
|
|
||||||
appointment_id?: string;
|
|
||||||
case_event_id?: string;
|
|
||||||
content: string;
|
|
||||||
created_by?: string;
|
|
||||||
created_at: string;
|
|
||||||
updated_at: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiError {
|
export interface ApiError {
|
||||||
error: string;
|
error: string;
|
||||||
status: number;
|
status: number;
|
||||||
@@ -243,6 +230,31 @@ export interface DashboardData {
|
|||||||
upcoming_appointments: UpcomingAppointment[];
|
upcoming_appointments: UpcomingAppointment[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notes
|
||||||
|
export interface Note {
|
||||||
|
id: string;
|
||||||
|
tenant_id: string;
|
||||||
|
case_id?: string;
|
||||||
|
deadline_id?: string;
|
||||||
|
appointment_id?: string;
|
||||||
|
case_event_id?: string;
|
||||||
|
content: string;
|
||||||
|
created_by?: string;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recent Activity
|
||||||
|
export interface RecentActivity {
|
||||||
|
id: string;
|
||||||
|
event_type?: string;
|
||||||
|
title: string;
|
||||||
|
case_id: string;
|
||||||
|
case_number: string;
|
||||||
|
event_date?: string;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
// AI Extraction types
|
// AI Extraction types
|
||||||
|
|
||||||
export interface ExtractedDeadline {
|
export interface ExtractedDeadline {
|
||||||
|
|||||||
Reference in New Issue
Block a user