Files
openmonetis/components/top-estabelecimentos/period-filter.tsx
Felipe Coutinho a7f63fb77a refactor: migrate from ESLint to Biome and extract SQL queries to data.ts
- Replace ESLint with Biome for linting and formatting
- Configure Biome with tabs, double quotes, and organized imports
- Move all SQL/Drizzle queries from page.tsx files to data.ts files
- Create new data.ts files for: ajustes, dashboard, relatorios/categorias
- Update existing data.ts files: extrato, fatura (add lancamentos queries)
- Remove all drizzle-orm imports from page.tsx files
- Update README.md with new tooling info

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 13:15:37 +00:00

49 lines
1.3 KiB
TypeScript

"use client";
import { useRouter, useSearchParams } from "next/navigation";
import { Button } from "@/components/ui/button";
import type { PeriodFilter } from "@/lib/top-estabelecimentos/fetch-data";
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">
<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>
);
}