refactor(top-estabelecimentos): atualiza layout e usa componente Progress

- Cria layout.tsx com PageDescription
- Substitui barras de progresso customizadas por Progress
- Remove label 'Período:' do filtro
- Ajusta espaçamento do filtro na página
This commit is contained in:
Felipe Coutinho
2026-01-20 15:21:52 +00:00
parent c185c7be42
commit 54ffd7f914
5 changed files with 39 additions and 30 deletions

View File

@@ -0,0 +1,23 @@
import PageDescription from "@/components/page-description";
import { RiStore2Line } from "@remixicon/react";
export const metadata = {
title: "Top Estabelecimentos | Opensheets",
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<section className="space-y-6 px-6">
<PageDescription
icon={<RiStore2Line />}
title="Top Estabelecimentos"
subtitle="Análise dos locais onde você mais compra e gasta"
/>
{children}
</section>
);
}

View File

@@ -3,6 +3,7 @@ import { HighlightsCards } from "@/components/top-estabelecimentos/highlights-ca
import { PeriodFilterButtons } from "@/components/top-estabelecimentos/period-filter";
import { SummaryCards } from "@/components/top-estabelecimentos/summary-cards";
import { TopCategories } from "@/components/top-estabelecimentos/top-categories";
import { Card } from "@/components/ui/card";
import { getUser } from "@/lib/auth/server";
import {
fetchTopEstabelecimentosData,
@@ -50,18 +51,13 @@ export default async function TopEstabelecimentosPage({
);
return (
<main className="@container/main flex flex-col gap-4 px-6">
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<div className="flex flex-col gap-1">
<h1 className="text-2xl font-semibold tracking-tight">
Top Estabelecimentos
</h1>
<p className="text-sm text-muted-foreground">
Análise dos locais onde você mais compra {data.periodLabel}
</p>
</div>
<main className="flex flex-col gap-4">
<Card className="p-3 flex-row justify-between items-center">
<span className="text-sm text-muted-foreground">
Selecione o período
</span>
<PeriodFilterButtons currentFilter={periodFilter} />
</div>
</Card>
<SummaryCards summary={data.summary} />

View File

@@ -1,12 +1,13 @@
"use client";
import MoneyValues from "@/components/money-values";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import MoneyValues from "@/components/money-values";
import { WidgetEmptyState } from "@/components/widget-empty-state";
import type { TopEstabelecimentosData } from "@/lib/top-estabelecimentos/fetch-data";
import { title_font } from "@/public/fonts/font_index";
import { RiStore2Line } from "@remixicon/react";
import { Progress } from "../ui/progress";
type EstablishmentsListProps = {
establishments: TopEstabelecimentosData["establishments"];
@@ -119,14 +120,10 @@ export function EstablishmentsList({
{/* Progress bar */}
<div className="ml-12 mt-1.5">
<div className="h-1.5 bg-muted rounded-full overflow-hidden">
<div
className="h-full bg-primary/50 rounded-full"
style={{
width: `${(establishment.count / maxCount) * 100}%`,
}}
/>
</div>
<Progress
className="h-1.5"
value={(establishment.count / maxCount) * 100}
/>
</div>
</div>
);

View File

@@ -27,7 +27,7 @@ export function PeriodFilterButtons({ currentFilter }: PeriodFilterProps) {
return (
<div className="flex items-center gap-2">
<span className="text-sm text-muted-foreground">Período:</span>
<div className="flex items-center gap-1">
{filterOptions.map((option) => (
<Button

View File

@@ -12,6 +12,7 @@ import {
import { getIconComponent } from "@/lib/utils/icons";
import { title_font } from "@/public/fonts/font_index";
import { RiPriceTag3Line } from "@remixicon/react";
import { Progress } from "../ui/progress";
type TopCategoriesProps = {
categories: TopEstabelecimentosData["topCategories"];
@@ -110,15 +111,7 @@ export function TopCategories({ categories }: TopCategoriesProps) {
{/* Progress bar */}
<div className="ml-12 mt-1.5">
<div className="h-1.5 bg-muted rounded-full overflow-hidden">
<div
className="h-full rounded-full"
style={{
width: `${percent}%`,
backgroundColor: color,
}}
/>
</div>
<Progress className="h-1.5" value={percent} />
</div>
</div>
);