import { Outlet, useParams, useLocation, Link } from "react-router"; import { requireUser } from "@/session.server"; import { Scale, TrendingDown, TrendingUp, Landmark, DollarSign, ChevronRight } from "lucide-react"; import { Card, CardContent } from "@/components/ui/card"; export const handle = { breadcrumbs: (data: { companyId: string; companyName: string }) => [ { label: "Mandanten", href: "/companies" }, { label: data.companyName, href: `/companies/${data.companyId}` }, { label: "Buchhaltung" }, ], }; export async function loader({ request, params }: { request: Request; params: { id: string } }) { const user = await requireUser(request); // Verify company ownership const { PrismaClient } = await import("@prisma/client"); const prisma = new PrismaClient(); const company = await prisma.company.findFirst({ where: { id: params.id, userId: user.id }, select: { id: true, name: true }, }); await prisma.$disconnect(); if (!company) throw new Response("Not Found", { status: 404 }); return { companyId: company.id, companyName: company.name }; } const accountingTabs = [ { id: "bilanzen", label: "Bilanzen", icon: Scale, href: "bilanzen", color: "teal", }, { id: "ausgaben", label: "Ausgaben", icon: TrendingDown, href: "ausgaben", color: "rose", }, { id: "einnahmen", label: "Einnahmen", icon: TrendingUp, href: "einnahmen", color: "emerald", }, { id: "anlagevermoegen", label: "Anlagevermögen", icon: Landmark, href: "anlagevermoegen", color: "violet", }, { id: "money", label: "Finanzmittel", icon: DollarSign, href: "money", color: "cyan", }, ]; export default function BuchhaltungLayout() { const params = useParams(); const location = useLocation(); const companyId = params.id; // Determine which tab is active based on current pathname const pathSegments = location.pathname.split("/"); const activeSegment = pathSegments[pathSegments.length - 1]; const activeTa = accountingTabs.find((tab) => tab.href === activeSegment); return (
Verwaltung von Bilanzen, Ausgaben, Einnahmen und Vermögen