import { useQuery } from "@tanstack/react-query" import { useParams, Link } from "@tanstack/react-router" import { api } from "../lib/api" import { Breadcrumb } from "../components/Breadcrumb" import type { Customer, Project, TimeEntry } from "@emberclone/shared" export default function CustomerDetail() { const { customerId } = useParams({ from: "/customers/$customerId" }) const { data: customer, isLoading: customerLoading, isError: customerError } = useQuery({ queryKey: ["customer", customerId], queryFn: () => api.getCustomer(customerId!) }) const { data: projects, isLoading: projectsLoading } = useQuery({ queryKey: ["customerProjects", customerId], queryFn: () => api.getCustomerProjects(customerId!), enabled: !!customerId }) const { data: entries, isLoading: entriesLoading } = useQuery({ queryKey: ["customerEntries", customerId], queryFn: () => api.getCustomerTimeEntries(customerId!), enabled: !!customerId }) if (customerLoading || projectsLoading || entriesLoading) { return
Loading customer details...
} if (customerError || !customer) { return
Customer not found or error loading data.
} return (
← Back to Customers

{customer.name}

Customer ID: {customer.id}

Active

Projects

{projects && projects.length > 0 ? (
    {projects.map((project: Project) => (
  • {project.name}
  • ))}
) : (

No projects assigned to this customer.

)}

Recent Time Entries

Showing the last 20 entries

{entries && entries.length > 0 ? ( entries.map((entry: TimeEntry) => ( )) ) : ( )}
Date Project Hours
{new Date(entry.date).toLocaleDateString()} {entry.projectName || 'Unknown Project'} {entry.hours}h
No time entries found for this customer.
) }