refactor: substituir topbar por navbar componentizada
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { FontProvider } from "@/components/font-provider";
|
import { FontProvider } from "@/components/font-provider";
|
||||||
|
import { AppNavbar } from "@/components/navbar/app-navbar";
|
||||||
import { PrivacyProvider } from "@/components/privacy-provider";
|
import { PrivacyProvider } from "@/components/privacy-provider";
|
||||||
import { AppTopbar } from "@/components/topbar/app-topbar";
|
|
||||||
import { getUserSession } from "@/lib/auth/server";
|
import { getUserSession } from "@/lib/auth/server";
|
||||||
import { fetchDashboardNotifications } from "@/lib/dashboard/notifications";
|
import { fetchDashboardNotifications } from "@/lib/dashboard/notifications";
|
||||||
import { fetchPagadoresWithAccess } from "@/lib/pagadores/access";
|
import { fetchPagadoresWithAccess } from "@/lib/pagadores/access";
|
||||||
@@ -53,7 +53,7 @@ export default async function DashboardLayout({
|
|||||||
moneyFont={fontPrefs.moneyFont}
|
moneyFont={fontPrefs.moneyFont}
|
||||||
>
|
>
|
||||||
<PrivacyProvider>
|
<PrivacyProvider>
|
||||||
<AppTopbar
|
<AppNavbar
|
||||||
user={{ ...session.user, image: session.user.image ?? null }}
|
user={{ ...session.user, image: session.user.image ?? null }}
|
||||||
pagadorAvatarUrl={adminPagador?.avatarUrl ?? null}
|
pagadorAvatarUrl={adminPagador?.avatarUrl ?? null}
|
||||||
preLancamentosCount={preLancamentosCount}
|
preLancamentosCount={preLancamentosCount}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import { NotificationBell } from "@/components/notificacoes/notification-bell";
|
|||||||
import { RefreshPageButton } from "@/components/refresh-page-button";
|
import { RefreshPageButton } from "@/components/refresh-page-button";
|
||||||
import type { DashboardNotificationsSnapshot } from "@/lib/dashboard/notifications";
|
import type { DashboardNotificationsSnapshot } from "@/lib/dashboard/notifications";
|
||||||
import { Logo } from "../logo";
|
import { Logo } from "../logo";
|
||||||
import { TopNavMenu } from "./top-nav-menu";
|
import { NavMenu } from "./nav-menu";
|
||||||
import { TopbarUser } from "./topbar-user";
|
import { NavbarUser } from "./navbar-user";
|
||||||
|
|
||||||
type AppTopbarProps = {
|
type AppNavbarProps = {
|
||||||
user: {
|
user: {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -19,14 +19,14 @@ type AppTopbarProps = {
|
|||||||
notificationsSnapshot: DashboardNotificationsSnapshot;
|
notificationsSnapshot: DashboardNotificationsSnapshot;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function AppTopbar({
|
export function AppNavbar({
|
||||||
user,
|
user,
|
||||||
pagadorAvatarUrl,
|
pagadorAvatarUrl,
|
||||||
preLancamentosCount = 0,
|
preLancamentosCount = 0,
|
||||||
notificationsSnapshot,
|
notificationsSnapshot,
|
||||||
}: AppTopbarProps) {
|
}: AppNavbarProps) {
|
||||||
return (
|
return (
|
||||||
<header className="fixed top-0 left-0 right-0 z-50 h-15 shrink-0 flex items-center bg-card/80 backdrop-blur-md supports-backdrop-filter:bg-card/70">
|
<header className="fixed top-0 left-0 right-0 z-50 h-15 shrink-0 flex items-center bg-card backdrop-blur-lg supports-backdrop-filter:bg-card/60">
|
||||||
<div className="w-full max-w-8xl mx-auto px-4 flex items-center gap-4 h-full">
|
<div className="w-full max-w-8xl mx-auto px-4 flex items-center gap-4 h-full">
|
||||||
{/* Logo */}
|
{/* Logo */}
|
||||||
<Link href="/dashboard" className="shrink-0 mr-1">
|
<Link href="/dashboard" className="shrink-0 mr-1">
|
||||||
@@ -34,7 +34,7 @@ export function AppTopbar({
|
|||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
{/* Navigation */}
|
{/* Navigation */}
|
||||||
<TopNavMenu />
|
<NavMenu />
|
||||||
|
|
||||||
{/* Right-side actions */}
|
{/* Right-side actions */}
|
||||||
<div className="ml-auto flex items-center gap-2">
|
<div className="ml-auto flex items-center gap-2">
|
||||||
@@ -49,7 +49,7 @@ export function AppTopbar({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* User avatar */}
|
{/* User avatar */}
|
||||||
<TopbarUser user={user} pagadorAvatarUrl={pagadorAvatarUrl} />
|
<NavbarUser user={user} pagadorAvatarUrl={pagadorAvatarUrl} />
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
@@ -1,34 +1,38 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Link from "next/link";
|
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { cn } from "@/lib/utils/ui";
|
import { cn } from "@/lib/utils/ui";
|
||||||
|
import { NavLink } from "./nav-link";
|
||||||
|
|
||||||
type MobileNavLinkProps = {
|
type MobileLinkProps = {
|
||||||
href: string;
|
href: string;
|
||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
badge?: number;
|
badge?: number;
|
||||||
|
preservePeriod?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function MobileNavLink({
|
export function MobileLink({
|
||||||
href,
|
href,
|
||||||
icon,
|
icon,
|
||||||
children,
|
children,
|
||||||
onClick,
|
onClick,
|
||||||
badge,
|
badge,
|
||||||
}: MobileNavLinkProps) {
|
preservePeriod,
|
||||||
|
}: MobileLinkProps) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
||||||
const isActive =
|
const isActive =
|
||||||
href === "/dashboard"
|
href === "/dashboard"
|
||||||
? pathname === href
|
? pathname === href
|
||||||
: pathname === href || pathname.startsWith(`${href}/`);
|
: pathname === href || pathname.startsWith(`${href}/`);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<NavLink
|
||||||
href={href}
|
href={href}
|
||||||
|
preservePeriod={preservePeriod}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors",
|
"flex items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors",
|
||||||
@@ -43,7 +47,7 @@ export function MobileNavLink({
|
|||||||
{badge}
|
{badge}
|
||||||
</Badge>
|
</Badge>
|
||||||
) : null}
|
) : null}
|
||||||
</Link>
|
</NavLink>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,24 +1,21 @@
|
|||||||
import Link from "next/link";
|
"use client";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import type { NavItem } from "./nav-items";
|
||||||
|
import { NavLink } from "./nav-link";
|
||||||
|
|
||||||
export type DropdownLinkItem = {
|
type NavDropdownProps = {
|
||||||
href: string;
|
items: NavItem[];
|
||||||
label: string;
|
|
||||||
icon: React.ReactNode;
|
|
||||||
badge?: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type DropdownLinkListProps = {
|
export function NavDropdown({ items }: NavDropdownProps) {
|
||||||
items: DropdownLinkItem[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export function DropdownLinkList({ items }: DropdownLinkListProps) {
|
|
||||||
return (
|
return (
|
||||||
<ul className="grid w-48 gap-0.5 p-2">
|
<ul className="grid w-48 gap-0.5 p-2">
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<li key={item.href}>
|
<li key={item.href}>
|
||||||
<Link
|
<NavLink
|
||||||
href={item.href}
|
href={item.href}
|
||||||
|
preservePeriod={item.preservePeriod}
|
||||||
className="flex items-center gap-2.5 rounded-sm px-2 py-2 text-sm text-foreground hover:bg-accent transition-colors"
|
className="flex items-center gap-2.5 rounded-sm px-2 py-2 text-sm text-foreground hover:bg-accent transition-colors"
|
||||||
>
|
>
|
||||||
<span className="text-muted-foreground shrink-0">{item.icon}</span>
|
<span className="text-muted-foreground shrink-0">{item.icon}</span>
|
||||||
@@ -31,7 +28,7 @@ export function DropdownLinkList({ items }: DropdownLinkListProps) {
|
|||||||
{item.badge}
|
{item.badge}
|
||||||
</Badge>
|
</Badge>
|
||||||
) : null}
|
) : null}
|
||||||
</Link>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
113
components/navbar/nav-items.tsx
Normal file
113
components/navbar/nav-items.tsx
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
import {
|
||||||
|
RiArrowLeftRightLine,
|
||||||
|
RiBankCard2Line,
|
||||||
|
RiBankLine,
|
||||||
|
RiCalendarEventLine,
|
||||||
|
RiFileChartLine,
|
||||||
|
RiFundsLine,
|
||||||
|
RiGroupLine,
|
||||||
|
RiInboxLine,
|
||||||
|
RiPriceTag3Line,
|
||||||
|
RiSparklingLine,
|
||||||
|
RiTodoLine,
|
||||||
|
} from "@remixicon/react";
|
||||||
|
|
||||||
|
export type NavItem = {
|
||||||
|
href: string;
|
||||||
|
label: string;
|
||||||
|
icon: React.ReactNode;
|
||||||
|
badge?: number;
|
||||||
|
preservePeriod?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type NavSection = {
|
||||||
|
label: string;
|
||||||
|
items: NavItem[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const NAV_SECTIONS: NavSection[] = [
|
||||||
|
{
|
||||||
|
label: "Lançamentos",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
href: "/lancamentos",
|
||||||
|
label: "lançamentos",
|
||||||
|
icon: <RiArrowLeftRightLine className="size-4" />,
|
||||||
|
preservePeriod: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "/pre-lancamentos",
|
||||||
|
label: "pré-lançamentos",
|
||||||
|
icon: <RiInboxLine className="size-4" />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "/calendario",
|
||||||
|
label: "calendário",
|
||||||
|
icon: <RiCalendarEventLine className="size-4" />,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Finanças",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
href: "/cartoes",
|
||||||
|
label: "cartões",
|
||||||
|
icon: <RiBankCard2Line className="size-4" />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "/contas",
|
||||||
|
label: "contas",
|
||||||
|
icon: <RiBankLine className="size-4" />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "/orcamentos",
|
||||||
|
label: "orçamentos",
|
||||||
|
icon: <RiFundsLine className="size-4" />,
|
||||||
|
preservePeriod: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Organização",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
href: "/pagadores",
|
||||||
|
label: "pagadores",
|
||||||
|
icon: <RiGroupLine className="size-4" />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "/categorias",
|
||||||
|
label: "categorias",
|
||||||
|
icon: <RiPriceTag3Line className="size-4" />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "/anotacoes",
|
||||||
|
label: "anotações",
|
||||||
|
icon: <RiTodoLine className="size-4" />,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Relatórios",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
href: "/insights",
|
||||||
|
label: "insights",
|
||||||
|
icon: <RiSparklingLine className="size-4" />,
|
||||||
|
preservePeriod: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "/relatorios/tendencias",
|
||||||
|
label: "tendências",
|
||||||
|
icon: <RiFileChartLine className="size-4" />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: "/relatorios/uso-cartoes",
|
||||||
|
label: "uso de cartões",
|
||||||
|
icon: <RiBankCard2Line className="size-4" />,
|
||||||
|
preservePeriod: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
30
components/navbar/nav-link.tsx
Normal file
30
components/navbar/nav-link.tsx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import Link from "next/link";
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
|
||||||
|
const PERIOD_PARAM = "periodo";
|
||||||
|
|
||||||
|
type NavLinkProps = Omit<React.ComponentProps<typeof Link>, "href"> & {
|
||||||
|
href: string;
|
||||||
|
preservePeriod?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function NavLink({
|
||||||
|
href,
|
||||||
|
preservePeriod = false,
|
||||||
|
...props
|
||||||
|
}: NavLinkProps) {
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
|
const resolvedHref = useMemo(() => {
|
||||||
|
if (!preservePeriod) return href;
|
||||||
|
const periodo = searchParams.get(PERIOD_PARAM);
|
||||||
|
if (!periodo) return href;
|
||||||
|
const separator = href.includes("?") ? "&" : "?";
|
||||||
|
return `${href}${separator}${PERIOD_PARAM}=${encodeURIComponent(periodo)}`;
|
||||||
|
}, [href, preservePeriod, searchParams]);
|
||||||
|
|
||||||
|
return <Link href={resolvedHref} {...props} />;
|
||||||
|
}
|
||||||
117
components/navbar/nav-menu.tsx
Normal file
117
components/navbar/nav-menu.tsx
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { RiDashboardLine, RiMenuLine } from "@remixicon/react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
NavigationMenu,
|
||||||
|
NavigationMenuContent,
|
||||||
|
NavigationMenuItem,
|
||||||
|
NavigationMenuList,
|
||||||
|
NavigationMenuTrigger,
|
||||||
|
} from "@/components/ui/navigation-menu";
|
||||||
|
import {
|
||||||
|
Sheet,
|
||||||
|
SheetContent,
|
||||||
|
SheetHeader,
|
||||||
|
SheetTitle,
|
||||||
|
SheetTrigger,
|
||||||
|
} from "@/components/ui/sheet";
|
||||||
|
import { MobileLink, MobileSectionLabel } from "./mobile-link";
|
||||||
|
import { NavDropdown } from "./nav-dropdown";
|
||||||
|
import { NAV_SECTIONS } from "./nav-items";
|
||||||
|
import { NavPill } from "./nav-pill";
|
||||||
|
import { triggerClass } from "./nav-styles";
|
||||||
|
import { MobileTools, NavToolsDropdown } from "./nav-tools";
|
||||||
|
|
||||||
|
export function NavMenu() {
|
||||||
|
const [sheetOpen, setSheetOpen] = useState(false);
|
||||||
|
const close = () => setSheetOpen(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{/* Desktop */}
|
||||||
|
<nav className="hidden md:flex items-center flex-1">
|
||||||
|
<NavigationMenu viewport={false}>
|
||||||
|
<NavigationMenuList className="gap-0">
|
||||||
|
<NavigationMenuItem>
|
||||||
|
<NavPill href="/dashboard" preservePeriod>
|
||||||
|
Dashboard
|
||||||
|
</NavPill>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
{NAV_SECTIONS.map((section) => (
|
||||||
|
<NavigationMenuItem key={section.label}>
|
||||||
|
<NavigationMenuTrigger className={triggerClass}>
|
||||||
|
{section.label}
|
||||||
|
</NavigationMenuTrigger>
|
||||||
|
<NavigationMenuContent>
|
||||||
|
<NavDropdown items={section.items} />
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<NavigationMenuItem>
|
||||||
|
<NavigationMenuTrigger className={triggerClass}>
|
||||||
|
Ferramentas
|
||||||
|
</NavigationMenuTrigger>
|
||||||
|
<NavigationMenuContent>
|
||||||
|
<NavToolsDropdown />
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
</NavigationMenuList>
|
||||||
|
</NavigationMenu>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
{/* Mobile */}
|
||||||
|
<Sheet open={sheetOpen} onOpenChange={setSheetOpen}>
|
||||||
|
<SheetTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="md:hidden text-foreground hover:bg-foreground/10 hover:text-foreground"
|
||||||
|
>
|
||||||
|
<RiMenuLine className="size-5" />
|
||||||
|
<span className="sr-only">Abrir menu</span>
|
||||||
|
</Button>
|
||||||
|
</SheetTrigger>
|
||||||
|
<SheetContent side="left" className="w-72 p-0">
|
||||||
|
<SheetHeader className="p-4 border-b">
|
||||||
|
<SheetTitle>Menu</SheetTitle>
|
||||||
|
</SheetHeader>
|
||||||
|
<nav className="p-3 overflow-y-auto">
|
||||||
|
<MobileLink
|
||||||
|
href="/dashboard"
|
||||||
|
icon={<RiDashboardLine className="size-4" />}
|
||||||
|
onClick={close}
|
||||||
|
preservePeriod
|
||||||
|
>
|
||||||
|
Dashboard
|
||||||
|
</MobileLink>
|
||||||
|
|
||||||
|
{NAV_SECTIONS.map((section) => (
|
||||||
|
<div key={section.label}>
|
||||||
|
<MobileSectionLabel label={section.label} />
|
||||||
|
{section.items.map((item) => (
|
||||||
|
<MobileLink
|
||||||
|
key={item.href}
|
||||||
|
href={item.href}
|
||||||
|
icon={item.icon}
|
||||||
|
onClick={close}
|
||||||
|
badge={item.badge}
|
||||||
|
preservePeriod={item.preservePeriod}
|
||||||
|
>
|
||||||
|
{item.label}
|
||||||
|
</MobileLink>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<MobileSectionLabel label="Ferramentas" />
|
||||||
|
<MobileTools onClose={close} />
|
||||||
|
</nav>
|
||||||
|
</SheetContent>
|
||||||
|
</Sheet>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,28 +1,31 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Link from "next/link";
|
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { cn } from "@/lib/utils/ui";
|
import { cn } from "@/lib/utils/ui";
|
||||||
|
import { NavLink } from "./nav-link";
|
||||||
import { linkActive, linkBase, linkIdle } from "./nav-styles";
|
import { linkActive, linkBase, linkIdle } from "./nav-styles";
|
||||||
|
|
||||||
type SimpleNavLinkProps = {
|
type NavPillProps = {
|
||||||
href: string;
|
href: string;
|
||||||
|
preservePeriod?: boolean;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function SimpleNavLink({ href, children }: SimpleNavLinkProps) {
|
export function NavPill({ href, preservePeriod, children }: NavPillProps) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
||||||
const isActive =
|
const isActive =
|
||||||
href === "/dashboard"
|
href === "/dashboard"
|
||||||
? pathname === href
|
? pathname === href
|
||||||
: pathname === href || pathname.startsWith(`${href}/`);
|
: pathname === href || pathname.startsWith(`${href}/`);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<NavLink
|
||||||
href={href}
|
href={href}
|
||||||
|
preservePeriod={preservePeriod}
|
||||||
className={cn(linkBase, isActive ? linkActive : linkIdle)}
|
className={cn(linkBase, isActive ? linkActive : linkIdle)}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Link>
|
</NavLink>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ import { cn } from "@/lib/utils/ui";
|
|||||||
const itemClass =
|
const itemClass =
|
||||||
"flex w-full items-center gap-2.5 rounded-sm px-2 py-2 text-sm text-foreground hover:bg-accent transition-colors cursor-pointer";
|
"flex w-full items-center gap-2.5 rounded-sm px-2 py-2 text-sm text-foreground hover:bg-accent transition-colors cursor-pointer";
|
||||||
|
|
||||||
export function FerramentasDropdownContent() {
|
export function NavToolsDropdown() {
|
||||||
const { privacyMode, toggle } = usePrivacyMode();
|
const { privacyMode, toggle } = usePrivacyMode();
|
||||||
const [calcOpen, setCalcOpen] = useState(false);
|
const [calcOpen, setCalcOpen] = useState(false);
|
||||||
|
|
||||||
@@ -54,13 +54,11 @@ export function FerramentasDropdownContent() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
type MobileFerramentasItemsProps = {
|
type MobileToolsProps = {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function MobileFerramentasItems({
|
export function MobileTools({ onClose }: MobileToolsProps) {
|
||||||
onClose,
|
|
||||||
}: MobileFerramentasItemsProps) {
|
|
||||||
const { privacyMode, toggle } = usePrivacyMode();
|
const { privacyMode, toggle } = usePrivacyMode();
|
||||||
const [calcOpen, setCalcOpen] = useState(false);
|
const [calcOpen, setCalcOpen] = useState(false);
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ import { Badge } from "../ui/badge";
|
|||||||
const itemClass =
|
const itemClass =
|
||||||
"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors hover:bg-accent";
|
"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm transition-colors hover:bg-accent";
|
||||||
|
|
||||||
type TopbarUserProps = {
|
type NavbarUserProps = {
|
||||||
user: {
|
user: {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -39,7 +39,7 @@ type TopbarUserProps = {
|
|||||||
pagadorAvatarUrl: string | null;
|
pagadorAvatarUrl: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function TopbarUser({ user, pagadorAvatarUrl }: TopbarUserProps) {
|
export function NavbarUser({ user, pagadorAvatarUrl }: NavbarUserProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [logoutLoading, setLogoutLoading] = useState(false);
|
const [logoutLoading, setLogoutLoading] = useState(false);
|
||||||
const [feedbackOpen, setFeedbackOpen] = useState(false);
|
const [feedbackOpen, setFeedbackOpen] = useState(false);
|
||||||
@@ -1,302 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import {
|
|
||||||
RiArrowLeftRightLine,
|
|
||||||
RiBankCard2Line,
|
|
||||||
RiBankLine,
|
|
||||||
RiCalendarEventLine,
|
|
||||||
RiDashboardLine,
|
|
||||||
RiFileChartLine,
|
|
||||||
RiFundsLine,
|
|
||||||
RiGroupLine,
|
|
||||||
RiInboxLine,
|
|
||||||
RiMenuLine,
|
|
||||||
RiPriceTag3Line,
|
|
||||||
RiSparklingLine,
|
|
||||||
RiTodoLine,
|
|
||||||
} from "@remixicon/react";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
NavigationMenu,
|
|
||||||
NavigationMenuContent,
|
|
||||||
NavigationMenuItem,
|
|
||||||
NavigationMenuList,
|
|
||||||
NavigationMenuTrigger,
|
|
||||||
} from "@/components/ui/navigation-menu";
|
|
||||||
import {
|
|
||||||
Sheet,
|
|
||||||
SheetContent,
|
|
||||||
SheetHeader,
|
|
||||||
SheetTitle,
|
|
||||||
SheetTrigger,
|
|
||||||
} from "@/components/ui/sheet";
|
|
||||||
import type { DropdownLinkItem } from "./dropdown-link-list";
|
|
||||||
import { DropdownLinkList } from "./dropdown-link-list";
|
|
||||||
import {
|
|
||||||
FerramentasDropdownContent,
|
|
||||||
MobileFerramentasItems,
|
|
||||||
} from "./ferramentas-dropdown";
|
|
||||||
import { MobileNavLink, MobileSectionLabel } from "./mobile-nav-link";
|
|
||||||
import { triggerClass } from "./nav-styles";
|
|
||||||
import { SimpleNavLink } from "./simple-nav-link";
|
|
||||||
|
|
||||||
export function TopNavMenu() {
|
|
||||||
const [sheetOpen, setSheetOpen] = useState(false);
|
|
||||||
const close = () => setSheetOpen(false);
|
|
||||||
|
|
||||||
const lancamentosItems: DropdownLinkItem[] = [
|
|
||||||
{
|
|
||||||
href: "/lancamentos",
|
|
||||||
label: "lançamentos",
|
|
||||||
icon: <RiArrowLeftRightLine className="size-4" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: "/pre-lancamentos",
|
|
||||||
label: "pré-lançamentos",
|
|
||||||
icon: <RiInboxLine className="size-4" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: "/calendario",
|
|
||||||
label: "calendário",
|
|
||||||
icon: <RiCalendarEventLine className="size-4" />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const financasItems: DropdownLinkItem[] = [
|
|
||||||
{
|
|
||||||
href: "/cartoes",
|
|
||||||
label: "cartões",
|
|
||||||
icon: <RiBankCard2Line className="size-4" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: "/contas",
|
|
||||||
label: "contas",
|
|
||||||
icon: <RiBankLine className="size-4" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: "/orcamentos",
|
|
||||||
label: "orçamentos",
|
|
||||||
icon: <RiFundsLine className="size-4" />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const organizacaoItems: DropdownLinkItem[] = [
|
|
||||||
{
|
|
||||||
href: "/pagadores",
|
|
||||||
label: "pagadores",
|
|
||||||
icon: <RiGroupLine className="size-4" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: "/categorias",
|
|
||||||
label: "categorias",
|
|
||||||
icon: <RiPriceTag3Line className="size-4" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: "/anotacoes",
|
|
||||||
label: "anotações",
|
|
||||||
icon: <RiTodoLine className="size-4" />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const analiseItems: DropdownLinkItem[] = [
|
|
||||||
{
|
|
||||||
href: "/insights",
|
|
||||||
label: "insights",
|
|
||||||
icon: <RiSparklingLine className="size-4" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: "/relatorios/tendencias",
|
|
||||||
label: "tendências",
|
|
||||||
icon: <RiFileChartLine className="size-4" />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: "/relatorios/uso-cartoes",
|
|
||||||
label: "uso de cartões",
|
|
||||||
icon: <RiBankCard2Line className="size-4" />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{/* Desktop nav */}
|
|
||||||
<nav className="hidden md:flex items-center flex-1">
|
|
||||||
<NavigationMenu viewport={false}>
|
|
||||||
<NavigationMenuList className="gap-0">
|
|
||||||
<NavigationMenuItem>
|
|
||||||
<SimpleNavLink href="/dashboard">Dashboard</SimpleNavLink>
|
|
||||||
</NavigationMenuItem>
|
|
||||||
|
|
||||||
<NavigationMenuItem>
|
|
||||||
<NavigationMenuTrigger className={triggerClass}>
|
|
||||||
Lançamentos
|
|
||||||
</NavigationMenuTrigger>
|
|
||||||
<NavigationMenuContent>
|
|
||||||
<DropdownLinkList items={lancamentosItems} />
|
|
||||||
</NavigationMenuContent>
|
|
||||||
</NavigationMenuItem>
|
|
||||||
|
|
||||||
<NavigationMenuItem>
|
|
||||||
<NavigationMenuTrigger className={triggerClass}>
|
|
||||||
Finanças
|
|
||||||
</NavigationMenuTrigger>
|
|
||||||
<NavigationMenuContent>
|
|
||||||
<DropdownLinkList items={financasItems} />
|
|
||||||
</NavigationMenuContent>
|
|
||||||
</NavigationMenuItem>
|
|
||||||
|
|
||||||
<NavigationMenuItem>
|
|
||||||
<NavigationMenuTrigger className={triggerClass}>
|
|
||||||
Organização
|
|
||||||
</NavigationMenuTrigger>
|
|
||||||
<NavigationMenuContent>
|
|
||||||
<DropdownLinkList items={organizacaoItems} />
|
|
||||||
</NavigationMenuContent>
|
|
||||||
</NavigationMenuItem>
|
|
||||||
|
|
||||||
<NavigationMenuItem>
|
|
||||||
<NavigationMenuTrigger className={triggerClass}>
|
|
||||||
Relatórios
|
|
||||||
</NavigationMenuTrigger>
|
|
||||||
<NavigationMenuContent>
|
|
||||||
<DropdownLinkList items={analiseItems} />
|
|
||||||
</NavigationMenuContent>
|
|
||||||
</NavigationMenuItem>
|
|
||||||
|
|
||||||
<NavigationMenuItem>
|
|
||||||
<NavigationMenuTrigger className={triggerClass}>
|
|
||||||
Ferramentas
|
|
||||||
</NavigationMenuTrigger>
|
|
||||||
<NavigationMenuContent>
|
|
||||||
<FerramentasDropdownContent />
|
|
||||||
</NavigationMenuContent>
|
|
||||||
</NavigationMenuItem>
|
|
||||||
</NavigationMenuList>
|
|
||||||
</NavigationMenu>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
{/* Mobile hamburger */}
|
|
||||||
<Sheet open={sheetOpen} onOpenChange={setSheetOpen}>
|
|
||||||
<SheetTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="md:hidden text-foreground hover:bg-foreground/10 hover:text-foreground"
|
|
||||||
>
|
|
||||||
<RiMenuLine className="size-5" />
|
|
||||||
<span className="sr-only">Abrir menu</span>
|
|
||||||
</Button>
|
|
||||||
</SheetTrigger>
|
|
||||||
<SheetContent side="left" className="w-72 p-0">
|
|
||||||
<SheetHeader className="p-4 border-b">
|
|
||||||
<SheetTitle>Menu</SheetTitle>
|
|
||||||
</SheetHeader>
|
|
||||||
<nav className="p-3 overflow-y-auto">
|
|
||||||
<MobileNavLink
|
|
||||||
href="/dashboard"
|
|
||||||
icon={<RiDashboardLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
Dashboard
|
|
||||||
</MobileNavLink>
|
|
||||||
|
|
||||||
<MobileSectionLabel label="Lançamentos" />
|
|
||||||
<MobileNavLink
|
|
||||||
href="/lancamentos"
|
|
||||||
icon={<RiArrowLeftRightLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
lançamentos
|
|
||||||
</MobileNavLink>
|
|
||||||
<MobileNavLink
|
|
||||||
href="/pre-lancamentos"
|
|
||||||
icon={<RiInboxLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
pré-lançamentos
|
|
||||||
</MobileNavLink>
|
|
||||||
<MobileNavLink
|
|
||||||
href="/calendario"
|
|
||||||
icon={<RiCalendarEventLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
calendário
|
|
||||||
</MobileNavLink>
|
|
||||||
|
|
||||||
<MobileSectionLabel label="Finanças" />
|
|
||||||
<MobileNavLink
|
|
||||||
href="/cartoes"
|
|
||||||
icon={<RiBankCard2Line className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
cartões
|
|
||||||
</MobileNavLink>
|
|
||||||
<MobileNavLink
|
|
||||||
href="/contas"
|
|
||||||
icon={<RiBankLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
contas
|
|
||||||
</MobileNavLink>
|
|
||||||
<MobileNavLink
|
|
||||||
href="/orcamentos"
|
|
||||||
icon={<RiFundsLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
orçamentos
|
|
||||||
</MobileNavLink>
|
|
||||||
|
|
||||||
<MobileSectionLabel label="Organização" />
|
|
||||||
<MobileNavLink
|
|
||||||
href="/pagadores"
|
|
||||||
icon={<RiGroupLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
pagadores
|
|
||||||
</MobileNavLink>
|
|
||||||
<MobileNavLink
|
|
||||||
href="/categorias"
|
|
||||||
icon={<RiPriceTag3Line className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
categorias
|
|
||||||
</MobileNavLink>
|
|
||||||
<MobileNavLink
|
|
||||||
href="/anotacoes"
|
|
||||||
icon={<RiTodoLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
anotações
|
|
||||||
</MobileNavLink>
|
|
||||||
|
|
||||||
<MobileSectionLabel label="Análise" />
|
|
||||||
<MobileNavLink
|
|
||||||
href="/insights"
|
|
||||||
icon={<RiSparklingLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
insights
|
|
||||||
</MobileNavLink>
|
|
||||||
<MobileNavLink
|
|
||||||
href="/relatorios/tendencias"
|
|
||||||
icon={<RiFileChartLine className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
tendências
|
|
||||||
</MobileNavLink>
|
|
||||||
<MobileNavLink
|
|
||||||
href="/relatorios/uso-cartoes"
|
|
||||||
icon={<RiBankCard2Line className="size-4" />}
|
|
||||||
onClick={close}
|
|
||||||
>
|
|
||||||
uso de cartões
|
|
||||||
</MobileNavLink>
|
|
||||||
|
|
||||||
<MobileSectionLabel label="Ferramentas" />
|
|
||||||
<MobileFerramentasItems onClose={close} />
|
|
||||||
</nav>
|
|
||||||
</SheetContent>
|
|
||||||
</Sheet>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user