- Substitui header fixo por topbar com backdrop blur e navegação agrupada em 5 seções - Adiciona FerramentasDropdown consolidando calculadora e modo privacidade - NotificationBell expandida com orçamentos e pré-lançamentos - Remove logout-button, header-dashboard e privacy-mode-toggle como componentes separados - Logo refatorado com variante compact; topbar com links em lowercase - Adiciona dependência radix-ui ^1.4.3 - Atualiza CHANGELOG para v1.7.0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { FontProvider } from "@/components/font-provider";
|
|
import { PrivacyProvider } from "@/components/privacy-provider";
|
|
import { AppTopbar } from "@/components/topbar/app-topbar";
|
|
import { getUserSession } from "@/lib/auth/server";
|
|
import { fetchDashboardNotifications } from "@/lib/dashboard/notifications";
|
|
import { fetchPagadoresWithAccess } from "@/lib/pagadores/access";
|
|
import { PAGADOR_ROLE_ADMIN } from "@/lib/pagadores/constants";
|
|
import { fetchUserFontPreferences } from "@/lib/preferences/fonts";
|
|
import { parsePeriodParam } from "@/lib/utils/period";
|
|
import { fetchPendingInboxCount } from "./pre-lancamentos/data";
|
|
|
|
export default async function DashboardLayout({
|
|
children,
|
|
searchParams,
|
|
}: Readonly<{
|
|
children: React.ReactNode;
|
|
searchParams?: Promise<Record<string, string | string[] | undefined>>;
|
|
}>) {
|
|
const session = await getUserSession();
|
|
const pagadoresList = await fetchPagadoresWithAccess(session.user.id);
|
|
|
|
// Encontrar o pagador admin do usuário
|
|
const adminPagador = pagadoresList.find(
|
|
(p) => p.role === PAGADOR_ROLE_ADMIN && p.userId === session.user.id,
|
|
);
|
|
|
|
// Buscar notificações para o período atual
|
|
const resolvedSearchParams = searchParams ? await searchParams : undefined;
|
|
const periodoParam = resolvedSearchParams?.periodo;
|
|
const singlePeriodoParam =
|
|
typeof periodoParam === "string"
|
|
? periodoParam
|
|
: Array.isArray(periodoParam)
|
|
? periodoParam[0]
|
|
: null;
|
|
const { period: currentPeriod } = parsePeriodParam(
|
|
singlePeriodoParam ?? null,
|
|
);
|
|
const notificationsSnapshot = await fetchDashboardNotifications(
|
|
session.user.id,
|
|
currentPeriod,
|
|
);
|
|
|
|
// Buscar contagem de pré-lançamentos pendentes e preferências de fonte
|
|
const [preLancamentosCount, fontPrefs] = await Promise.all([
|
|
fetchPendingInboxCount(session.user.id),
|
|
fetchUserFontPreferences(session.user.id),
|
|
]);
|
|
|
|
return (
|
|
<FontProvider
|
|
systemFont={fontPrefs.systemFont}
|
|
moneyFont={fontPrefs.moneyFont}
|
|
>
|
|
<PrivacyProvider>
|
|
<AppTopbar
|
|
user={{ ...session.user, image: session.user.image ?? null }}
|
|
pagadorAvatarUrl={adminPagador?.avatarUrl ?? null}
|
|
preLancamentosCount={preLancamentosCount}
|
|
notificationsSnapshot={notificationsSnapshot}
|
|
/>
|
|
<div className="flex flex-1 flex-col pt-14">
|
|
<div className="@container/main flex flex-1 flex-col gap-2">
|
|
<div className="flex flex-col gap-4 py-5 md:gap-6 w-full max-w-8xl mx-auto px-4">
|
|
{children}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</PrivacyProvider>
|
|
</FontProvider>
|
|
);
|
|
}
|