mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-03-10 04:51:47 +00:00
feat: adicionar página Top Estabelecimentos
- Criar página /top-estabelecimentos com análise de gastos por local - Adicionar componentes: establishments-list, highlights-cards, summary-cards - Adicionar filtro de período personalizado - Criar função de busca de dados para top estabelecimentos Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
49
components/top-estabelecimentos/period-filter.tsx
Normal file
49
components/top-estabelecimentos/period-filter.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { PeriodFilter } from "@/lib/top-estabelecimentos/fetch-data";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type PeriodFilterProps = {
|
||||
currentFilter: PeriodFilter;
|
||||
};
|
||||
|
||||
const filterOptions: { value: PeriodFilter; label: string }[] = [
|
||||
{ value: "3", label: "3 meses" },
|
||||
{ value: "6", label: "6 meses" },
|
||||
{ value: "12", label: "12 meses" },
|
||||
];
|
||||
|
||||
export function PeriodFilterButtons({ currentFilter }: PeriodFilterProps) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const handleFilterChange = (filter: PeriodFilter) => {
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
params.set("meses", filter);
|
||||
router.push(`/top-estabelecimentos?${params.toString()}`);
|
||||
};
|
||||
|
||||
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
|
||||
key={option.value}
|
||||
variant={currentFilter === option.value ? "default" : "outline"}
|
||||
size="sm"
|
||||
onClick={() => handleFilterChange(option.value)}
|
||||
className={cn(
|
||||
"h-8",
|
||||
currentFilter === option.value && "pointer-events-none"
|
||||
)}
|
||||
>
|
||||
{option.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user