diff --git a/src/components/charts/views-charts.tsx b/src/components/charts/views-charts.tsx
index 300109f..ce426e7 100644
--- a/src/components/charts/views-charts.tsx
+++ b/src/components/charts/views-charts.tsx
@@ -17,58 +17,84 @@ import { Skeleton } from "@/components/ui/skeleton"
export function ViewsCharts() {
return (
-
+
)
}
-function CsatPie() {
+function BacklogPriorityPie() {
const [companyId, setCompanyId] = usePersistentCompanyFilter("all")
+ const [timeRange, setTimeRange] = React.useState("30d")
const { session, convexUserId } = useAuth()
const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID
const data = useQuery(
- api.reports.csatOverview,
+ api.reports.backlogOverview,
convexUserId
- ? ({ tenantId, viewerId: convexUserId as Id<"users">, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) })
+ ? ({ tenantId, viewerId: convexUserId as Id<"users">, range: timeRange, companyId: companyId === "all" ? undefined : (companyId as Id<"companies">) })
: "skip"
- ) as { totalSurveys: number; distribution: { score: number; total: number }[] } | undefined
+ ) as { priorityCounts: Record } | undefined
const companies = useQuery(api.companies.list, convexUserId ? { tenantId, viewerId: convexUserId as Id<"users"> } : "skip") as Array<{ id: Id<"companies">; name: string }> | undefined
if (!data) return
- const chartData = (data.distribution ?? []).map((d) => ({ score: `Nota ${d.score}`, total: d.total }))
- const chartConfig: any = { total: { label: "Respostas" } }
+ const PRIORITY_LABELS: Record = { LOW: "Baixa", MEDIUM: "Média", HIGH: "Alta", URGENT: "Crítica" }
+ const keys = ["LOW", "MEDIUM", "HIGH", "URGENT"]
+ const fills = {
+ LOW: "var(--chart-1)",
+ MEDIUM: "var(--chart-2)",
+ HIGH: "var(--chart-3)",
+ URGENT: "var(--chart-4)",
+ } as const
+ const chartData = keys
+ .map((k) => ({ name: PRIORITY_LABELS[k] ?? k, value: data.priorityCounts?.[k] ?? 0, fill: fills[k as keyof typeof fills] }))
+ .filter((d) => d.value > 0)
+ const chartConfig: any = { value: { label: "Tickets" } }
return (
- CSAT - Distribuição
- Frequência de respostas por nota
+ Backlog por prioridade
+ Distribuição de tickets no período
-
+
+
+
+
{chartData.length === 0 ? (
- Sem respostas no período.
+ Sem dados no período selecionado.
) : (
-
+
- } />
-
-
+ } />
+
+
@@ -132,4 +158,3 @@ function QueuesOpenBar() {
)
}
-