diff --git a/src/components/reports/hours-report.tsx b/src/components/reports/hours-report.tsx index 4edc609..7207494 100644 --- a/src/components/reports/hours-report.tsx +++ b/src/components/reports/hours-report.tsx @@ -15,8 +15,9 @@ import { Input } from "@/components/ui/input" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { usePersistentCompanyFilter } from "@/lib/use-company-filter" import { Progress } from "@/components/ui/progress" -import { Bar, BarChart, CartesianGrid, XAxis } from "recharts" -import { ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart" +import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts" +import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart" +import type { ChartConfig } from "@/components/ui/chart" import { formatHoursCompact } from "@/lib/utils" type HoursItem = { @@ -32,11 +33,13 @@ type HoursItem = { const topClientsChartConfig = { internas: { label: "Horas internas", + color: "var(--chart-1)", }, externas: { label: "Horas externas", + color: "var(--chart-2)", }, -} +} satisfies ChartConfig export function HoursReport() { const [timeRange, setTimeRange] = useState("90d") @@ -95,6 +98,19 @@ export function HoursReport() { }), [filtered] ) + const topClientsData = useMemo( + () => + filteredWithComputed + .slice() + .sort((a, b) => b.total - a.total) + .slice(0, 10) + .map((row) => ({ + name: row.name, + internas: row.internal, + externas: row.external, + })), + [filteredWithComputed] + ) return (
@@ -107,24 +123,26 @@ export function HoursReport() { {!filteredWithComputed || filteredWithComputed.length === 0 ? (

Sem dados para o perĂ­odo.

) : ( - + b.total - a.total) - .slice(0, 10) - .map((r) => ({ name: r.name, internas: r.internal, externas: r.external }))} - margin={{ top: 8, left: 20, right: 20, bottom: 56 }} - barCategoryGap={32} + data={topClientsData} + layout="vertical" + margin={{ top: 16, right: 24, bottom: 16, left: 0 }} + barCategoryGap={12} > - - - - + + formatHoursCompact(Number(value))} + /> + {String(value)}} formatter={(value, name) => ( <> @@ -136,6 +154,9 @@ export function HoursReport() { /> } /> + } /> + + )}