BREAKING CHANGE: Remove feature de seleção de período das preferências do usuário
Alterações principais:
- Adiciona sistema completo de relatórios por categoria
- Cria página /relatorios/categorias com filtros e visualizações
- Implementa tabela e gráfico de evolução mensal
- Adiciona funcionalidade de exportação de dados
- Cria skeleton otimizado para melhor UX de loading
- Remove feature de seleção de período das preferências
- Deleta lib/user-preferences/period.ts
- Remove colunas periodMonthsBefore e periodMonthsAfter do schema
- Remove todas as referências em 16+ arquivos
- Atualiza database schema via Drizzle
- Substitui Select de período por MonthPicker visual
- Implementa componente PeriodPicker reutilizável
- Integra shadcn MonthPicker customizado (português, Remix icons)
- Substitui createMonthOptions em todos os formulários
- Mantém formato "YYYY-MM" no banco de dados
- Melhora design da tabela de relatórios
- Mescla colunas Categoria e Tipo em uma única coluna
- Substitui badge de tipo por dot colorido discreto
- Reduz largura da tabela em ~120px
- Atualiza skeleton para refletir nova estrutura
- Melhorias gerais de UI
- Reduz espaçamento entre títulos da sidebar (p-2 → px-2 py-1)
- Adiciona MonthNavigation para navegação entre períodos
- Otimiza loading states com skeletons detalhados
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
import { DashboardGrid } from "@/components/dashboard/dashboard-grid";
|
|
import { DashboardWelcome } from "@/components/dashboard/dashboard-welcome";
|
|
import { SectionCards } from "@/components/dashboard/section-cards";
|
|
import MonthNavigation from "@/components/month-picker/month-navigation";
|
|
import { getUser } from "@/lib/auth/server";
|
|
import { fetchDashboardData } from "@/lib/dashboard/fetch-dashboard-data";
|
|
import { parsePeriodParam } from "@/lib/utils/period";
|
|
import { db, schema } from "@/lib/db";
|
|
import { eq } from "drizzle-orm";
|
|
|
|
type PageSearchParams = Promise<Record<string, string | string[] | undefined>>;
|
|
|
|
type PageProps = {
|
|
searchParams?: PageSearchParams;
|
|
};
|
|
|
|
const getSingleParam = (
|
|
params: Record<string, string | string[] | undefined> | undefined,
|
|
key: string
|
|
) => {
|
|
const value = params?.[key];
|
|
if (!value) return null;
|
|
return Array.isArray(value) ? value[0] ?? null : value;
|
|
};
|
|
|
|
export default async function Page({ searchParams }: PageProps) {
|
|
const user = await getUser();
|
|
const resolvedSearchParams = searchParams ? await searchParams : undefined;
|
|
const periodoParam = getSingleParam(resolvedSearchParams, "periodo");
|
|
const { period: selectedPeriod } = parsePeriodParam(periodoParam);
|
|
|
|
const data = await fetchDashboardData(user.id, selectedPeriod);
|
|
|
|
// Buscar preferências do usuário
|
|
const preferencesResult = await db
|
|
.select({
|
|
disableMagnetlines: schema.userPreferences.disableMagnetlines,
|
|
})
|
|
.from(schema.userPreferences)
|
|
.where(eq(schema.userPreferences.userId, user.id))
|
|
.limit(1);
|
|
|
|
const disableMagnetlines = preferencesResult[0]?.disableMagnetlines ?? false;
|
|
|
|
return (
|
|
<main className="flex flex-col gap-4 px-6">
|
|
<DashboardWelcome
|
|
name={user.name}
|
|
disableMagnetlines={disableMagnetlines}
|
|
/>
|
|
<MonthNavigation />
|
|
<SectionCards metrics={data.metrics} />
|
|
<DashboardGrid data={data} period={selectedPeriod} />
|
|
</main>
|
|
);
|
|
}
|