"use client"; import { useQuery } from "@tanstack/react-query"; import { api } from "@/lib/api"; import type { DocumentTemplate } from "@/lib/types"; import { TEMPLATE_CATEGORY_LABELS } from "@/lib/types"; import { Breadcrumb } from "@/components/layout/Breadcrumb"; import Link from "next/link"; import { FileText, Plus, Loader2, Lock } from "lucide-react"; import { useState } from "react"; const CATEGORIES = ["", "schriftsatz", "vertrag", "korrespondenz", "intern"]; export default function VorlagenPage() { const [category, setCategory] = useState(""); const { data, isLoading } = useQuery({ queryKey: ["templates", category], queryFn: () => api.get<{ data: DocumentTemplate[]; total: number }>( `/templates${category ? `?category=${category}` : ""}`, ), }); const templates = data?.data ?? []; return (

Vorlagen

Dokumentvorlagen mit automatischer Befüllung

Neue Vorlage
{/* Category filter */}
{CATEGORIES.map((cat) => ( ))}
{isLoading ? (
) : templates.length === 0 ? (

Keine Vorlagen gefunden

) : (
{templates.map((t) => (

{t.name}

{t.is_system && ( )}
{t.description && (

{t.description}

)}
{TEMPLATE_CATEGORY_LABELS[t.category] ?? t.category} {t.is_system && ( System )}
))}
)}
); }