refactor(core): centraliza hooks, providers e base compartilhada

This commit is contained in:
Felipe Coutinho
2026-03-09 17:11:55 +00:00
parent 2de5101058
commit 3e06a1d056
76 changed files with 3271 additions and 709 deletions

View File

@@ -1,6 +1,6 @@
"use client";
import * as React from "react";
import { Logo } from "@/components/logo";
import { Logo } from "@/components/shared/logo";
import { NavMain } from "@/components/navigation/sidebar/nav-main";
import { NavSecondary } from "@/components/navigation/sidebar/nav-secondary";
import { NavUser } from "@/components/navigation/sidebar/nav-user";

View File

@@ -3,7 +3,7 @@
import type { RemixiconComponentType } from "@remixicon/react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import * as React from "react";
import type * as React from "react";
import {
SidebarGroup,
SidebarGroupContent,
@@ -24,30 +24,22 @@ export function NavSecondary({
} & React.ComponentPropsWithoutRef<typeof SidebarGroup>) {
const pathname = usePathname();
const isLinkActive = React.useCallback(
(url: string) => {
const normalizedPathname =
pathname.endsWith("/") && pathname !== "/"
? pathname.slice(0, -1)
: pathname;
const normalizedUrl =
url.endsWith("/") && url !== "/" ? url.slice(0, -1) : url;
// Verifica se é exatamente igual ou se o pathname começa com a URL
return (
normalizedPathname === normalizedUrl ||
normalizedPathname.startsWith(`${normalizedUrl}/`)
);
},
[pathname],
);
return (
<SidebarGroup {...props}>
<SidebarGroupContent>
<SidebarMenu>
{items.map((item) => {
const itemIsActive = isLinkActive(item.url);
const normalizedPathname =
pathname.endsWith("/") && pathname !== "/"
? pathname.slice(0, -1)
: pathname;
const normalizedUrl =
item.url.endsWith("/") && item.url !== "/"
? item.url.slice(0, -1)
: item.url;
const itemIsActive =
normalizedPathname === normalizedUrl ||
normalizedPathname.startsWith(`${normalizedUrl}/`);
return (
<SidebarMenuItem key={item.title}>
<SidebarMenuButton

View File

@@ -1,12 +1,10 @@
"use client";
import Image from "next/image";
import { useMemo } from "react";
import {
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from "@/components/ui/sidebar";
import { getAvatarSrc } from "@/lib/pagadores/utils";
@@ -21,19 +19,9 @@ type NavUserProps = {
};
export function NavUser({ user, pagadorAvatarUrl }: NavUserProps) {
useSidebar();
const avatarSrc = useMemo(() => {
// Priorizar o avatar do pagador admin quando disponível
if (pagadorAvatarUrl) {
return getAvatarSrc(pagadorAvatarUrl);
}
// Fallback para a imagem do usuário (Google, etc)
if (user.image) {
return user.image;
}
return getAvatarSrc(null);
}, [user.image, pagadorAvatarUrl]);
const avatarSrc = pagadorAvatarUrl
? getAvatarSrc(pagadorAvatarUrl)
: user.image || getAvatarSrc(null);
return (
<SidebarMenu>