fix(ui): remover avisos visuais e destacar atualizações

This commit is contained in:
Felipe Coutinho
2026-04-03 18:11:30 +00:00
parent 5c4995961c
commit f5cdae4853
11 changed files with 190 additions and 80 deletions

Binary file not shown.

View File

@@ -117,6 +117,7 @@ export function AttachmentGridItem({
src={url} src={url}
alt={attachment.fileName} alt={attachment.fileName}
fill fill
sizes="(max-width: 640px) 50vw, (max-width: 1024px) 33vw, (max-width: 1280px) 25vw, 20vw"
unoptimized unoptimized
className="object-cover transition-transform duration-300 group-hover:scale-105" className="object-cover transition-transform duration-300 group-hover:scale-105"
/> />

View File

@@ -14,13 +14,13 @@ const MOCK_INVOICES: MockInvoice[] = [
cardName: "Nubank", cardName: "Nubank",
logo: "nubank.png", logo: "nubank.png",
amount: 1898, amount: 1898,
dueLabel: "Vence em 3 dias", dueLabel: "Vence hoje",
}, },
{ {
cardName: "Itaú", cardName: "Itaú",
logo: "itau.png", logo: "itau.png",
amount: 1923, amount: 1923,
dueLabel: "Vence em 8 dias", dueLabel: "Vence amanhã",
}, },
]; ];

View File

@@ -2,7 +2,7 @@ import { RiCheckLine, RiFileCopyLine } from "@remixicon/react";
import { Button } from "@/shared/components/ui/button"; import { Button } from "@/shared/components/ui/button";
import { cn } from "@/shared/utils/ui"; import { cn } from "@/shared/utils/ui";
export type CalculatorDisplayProps = { type CalculatorDisplayProps = {
history: string | null; history: string | null;
expression: string; expression: string;
resultText: string | null; resultText: string | null;

View File

@@ -21,60 +21,67 @@ export function Logo({
if (variant === "compact") { if (variant === "compact") {
return ( return (
<div className={cn("flex items-center gap-1", className)}> <div className={cn("flex items-center gap-1", className)}>
<Image <div className="relative size-8 shrink-0">
src="/images/logo_small.png" <Image
alt="OpenMonetis" src="/images/logo_small.png"
width={32} alt="OpenMonetis"
height={32} fill
className={cn("object-contain", !colorIcon && iconFilterClass)} sizes="32px"
priority className={cn("object-contain", !colorIcon && iconFilterClass)}
/> priority
<Image />
src="/images/logo_text.png" </div>
alt="OpenMonetis" <div className="relative hidden h-8 w-[110px] shrink-0 sm:block">
width={110} <Image
height={32} src="/images/logo_text.png"
className={cn( alt="OpenMonetis"
"hidden object-contain sm:block", fill
invertTextOnDark && "dark:invert", sizes="110px"
)} className={cn("object-contain", invertTextOnDark && "dark:invert")}
priority priority
/> />
</div>
</div> </div>
); );
} }
if (variant === "small") { if (variant === "small") {
return ( return (
<Image <div className={cn("relative size-8 shrink-0", className)}>
src="/images/logo_small.png" <Image
alt="OpenMonetis" src="/images/logo_small.png"
width={32} alt="OpenMonetis"
height={32} fill
className={cn("object-contain", className)} sizes="32px"
priority className="object-contain"
/> priority
/>
</div>
); );
} }
return ( return (
<div className={cn("flex items-center gap-1.5 py-4", className)}> <div className={cn("flex items-center gap-1.5 py-4", className)}>
<Image <div className="relative size-7 shrink-0">
src="/images/logo_small.png" <Image
alt="OpenMonetis" src="/images/logo_small.png"
width={28} alt="OpenMonetis"
height={28} fill
className={cn("object-contain", !colorIcon && iconFilterClass)} sizes="28px"
priority className={cn("object-contain", !colorIcon && iconFilterClass)}
/> priority
<Image />
src="/images/logo_text.png" </div>
alt="OpenMonetis" <div className="relative h-8 w-[100px] shrink-0">
width={100} <Image
height={32} src="/images/logo_text.png"
className={cn("object-contain", invertTextOnDark && "dark:invert")} alt="OpenMonetis"
priority fill
/> sizes="100px"
className={cn("object-contain", invertTextOnDark && "dark:invert")}
priority
/>
</div>
</div> </div>
); );
} }

View File

@@ -2,6 +2,7 @@ import { AnimatedThemeToggler } from "@/shared/components/animated-theme-toggler
import { NotificationBell } from "@/shared/components/navigation/navbar/notification-bell"; import { NotificationBell } from "@/shared/components/navigation/navbar/notification-bell";
import { RefreshPageButton } from "@/shared/components/refresh-page-button"; import { RefreshPageButton } from "@/shared/components/refresh-page-button";
import type { DashboardNotificationsSnapshot } from "@/shared/lib/types/notifications"; import type { DashboardNotificationsSnapshot } from "@/shared/lib/types/notifications";
import { checkForUpdate } from "@/shared/lib/version/check-update";
import { NavMenu } from "./nav-menu"; import { NavMenu } from "./nav-menu";
import { NavbarShell } from "./navbar-shell"; import { NavbarShell } from "./navbar-shell";
import { NavbarUser } from "./navbar-user"; import { NavbarUser } from "./navbar-user";
@@ -18,12 +19,14 @@ type AppNavbarProps = {
notificationsSnapshot: DashboardNotificationsSnapshot; notificationsSnapshot: DashboardNotificationsSnapshot;
}; };
export function AppNavbar({ export async function AppNavbar({
user, user,
pagadorAvatarUrl, pagadorAvatarUrl,
preLancamentosCount = 0, preLancamentosCount = 0,
notificationsSnapshot, notificationsSnapshot,
}: AppNavbarProps) { }: AppNavbarProps) {
const updateCheck = await checkForUpdate();
return ( return (
<NavbarShell logoHref="/dashboard" fixed> <NavbarShell logoHref="/dashboard" fixed>
<NavMenu /> <NavMenu />
@@ -38,7 +41,11 @@ export function AppNavbar({
<RefreshPageButton variant="navbar" /> <RefreshPageButton variant="navbar" />
<AnimatedThemeToggler variant="navbar" /> <AnimatedThemeToggler variant="navbar" />
</div> </div>
<NavbarUser user={user} pagadorAvatarUrl={pagadorAvatarUrl} /> <NavbarUser
user={user}
pagadorAvatarUrl={pagadorAvatarUrl}
updateCheck={updateCheck}
/>
</NavbarShell> </NavbarShell>
); );
} }

View File

@@ -3,6 +3,7 @@
import { import {
RiHistoryLine, RiHistoryLine,
RiLogoutCircleLine, RiLogoutCircleLine,
RiMegaphoneLine,
RiMessageLine, RiMessageLine,
RiSettings2Line, RiSettings2Line,
} from "@remixicon/react"; } from "@remixicon/react";
@@ -24,6 +25,7 @@ import {
import { Spinner } from "@/shared/components/ui/spinner"; import { Spinner } from "@/shared/components/ui/spinner";
import { authClient } from "@/shared/lib/auth/client"; import { authClient } from "@/shared/lib/auth/client";
import { getAvatarSrc } from "@/shared/lib/payers/utils"; import { getAvatarSrc } from "@/shared/lib/payers/utils";
import type { UpdateCheckResult } from "@/shared/lib/version/check-update";
import { cn } from "@/shared/utils/ui"; import { cn } from "@/shared/utils/ui";
const itemClass = const itemClass =
@@ -37,9 +39,14 @@ type NavbarUserProps = {
image: string | null; image: string | null;
}; };
pagadorAvatarUrl: string | null; pagadorAvatarUrl: string | null;
updateCheck: UpdateCheckResult;
}; };
export function NavbarUser({ user, pagadorAvatarUrl }: NavbarUserProps) { export function NavbarUser({
user,
pagadorAvatarUrl,
updateCheck,
}: 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);
@@ -61,33 +68,42 @@ export function NavbarUser({ user, pagadorAvatarUrl }: NavbarUserProps) {
return ( return (
<Dialog open={feedbackOpen} onOpenChange={setFeedbackOpen}> <Dialog open={feedbackOpen} onOpenChange={setFeedbackOpen}>
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <div className="relative">
<button <DropdownMenuTrigger asChild>
className="relative flex size-9 items-center justify-center overflow-hidden rounded-full transition-colors focus-visible:ring-2 focus-visible:ring-black/20 focus-visible:outline-none" <button
aria-label="Menu do usuário" className="flex size-9 items-center justify-center overflow-hidden rounded-full transition-colors focus-visible:ring-2 focus-visible:ring-black/20 focus-visible:outline-none"
> aria-label="Menu do usuário"
<Image >
src={avatarSrc} <div className="relative size-10 overflow-hidden rounded-full">
alt={`Avatar de ${user.name}`} <Image
width={40} src={avatarSrc}
height={40} alt={`Avatar de ${user.name}`}
className="size-10 rounded-full object-cover" fill
/> sizes="40px"
</button> className="object-cover"
</DropdownMenuTrigger> />
</div>
</button>
</DropdownMenuTrigger>
{updateCheck.hasUpdate && (
<span className="pointer-events-none absolute -top-0.5 -right-0.5 size-2.5 rounded-full bg-success" />
)}
</div>
<DropdownMenuContent <DropdownMenuContent
align="end" align="end"
className="w-60 border-border/60 p-2 shadow-none" className="w-60 border-border/60 p-2 shadow-none"
sideOffset={10} sideOffset={10}
> >
<DropdownMenuLabel className="flex items-center gap-3 px-2 py-2"> <DropdownMenuLabel className="flex items-center gap-3 px-2 py-2">
<Image <div className="relative size-9 shrink-0 overflow-hidden rounded-full">
src={avatarSrc} <Image
alt={user.name} src={avatarSrc}
width={36} alt={user.name}
height={36} fill
className="size-9 rounded-full object-cover shrink-0" sizes="36px"
/> className="object-cover"
/>
</div>
<div className="flex flex-col min-w-0"> <div className="flex flex-col min-w-0">
<span className="text-sm font-medium truncate">{user.name}</span> <span className="text-sm font-medium truncate">{user.name}</span>
<span className="text-xs text-muted-foreground truncate"> <span className="text-xs text-muted-foreground truncate">
@@ -122,6 +138,20 @@ export function NavbarUser({ user, pagadorAvatarUrl }: NavbarUserProps) {
Enviar Feedback Enviar Feedback
</button> </button>
</DialogTrigger> </DialogTrigger>
{updateCheck.hasUpdate && (
<Link
href={updateCheck.releaseUrl}
target="_blank"
rel="noopener noreferrer"
className={cn(itemClass, "text-success")}
>
<RiMegaphoneLine className="size-4 text-success shrink-0" />
<span className="flex-1 tracking-wide text-xs font-medium">
Atualização {updateCheck.latestVersion} disponível
</span>
</Link>
)}
</div> </div>
<DropdownMenuSeparator /> <DropdownMenuSeparator />

View File

@@ -30,13 +30,15 @@ export function NavUser({ user, pagadorAvatarUrl }: NavUserProps) {
size="lg" size="lg"
className="data-popup-open:bg-sidebar-accent data-popup-open:text-sidebar-accent-foreground " className="data-popup-open:bg-sidebar-accent data-popup-open:text-sidebar-accent-foreground "
> >
<Image <div className="relative size-8 shrink-0 overflow-hidden rounded-full">
src={avatarSrc} <Image
alt={user.name} src={avatarSrc}
width={32} alt={user.name}
height={32} fill
className="size-8 shrink-0 rounded-full object-cover" sizes="32px"
/> className="object-cover"
/>
</div>
<div className="grid flex-1 text-left text-sm leading-tight"> <div className="grid flex-1 text-left text-sm leading-tight">
<span className="truncate font-medium">{user.name}</span> <span className="truncate font-medium">{user.name}</span>
<span className="text-muted-foreground truncate text-xs"> <span className="text-muted-foreground truncate text-xs">

View File

@@ -31,6 +31,13 @@ type ChartContextProps = {
const ChartContext = React.createContext<ChartContextProps | null>(null); const ChartContext = React.createContext<ChartContextProps | null>(null);
const CHART_MIN_WIDTH = 280;
const CHART_MIN_HEIGHT = 200;
const CHART_INITIAL_DIMENSION = {
width: CHART_MIN_WIDTH,
height: CHART_MIN_HEIGHT,
} as const;
function useChart() { function useChart() {
const context = React.useContext(ChartContext); const context = React.useContext(ChartContext);
@@ -80,8 +87,9 @@ function ChartContainer({
<RechartsPrimitive.ResponsiveContainer <RechartsPrimitive.ResponsiveContainer
width="100%" width="100%"
height="100%" height="100%"
minWidth={280} minWidth={CHART_MIN_WIDTH}
minHeight={200} minHeight={CHART_MIN_HEIGHT}
initialDimension={CHART_INITIAL_DIMENSION}
> >
{children} {children}
</RechartsPrimitive.ResponsiveContainer> </RechartsPrimitive.ResponsiveContainer>

View File

@@ -56,7 +56,7 @@ const formatDigits = (digits: string) => {
return BRL_FORMATTER.format(numeric); return BRL_FORMATTER.format(numeric);
}; };
export interface CurrencyInputProps interface CurrencyInputProps
extends Omit< extends Omit<
React.ComponentProps<typeof Input>, React.ComponentProps<typeof Input>,
"value" | "defaultValue" | "type" | "inputMode" | "onChange" "value" | "defaultValue" | "type" | "inputMode" | "onChange"

View File

@@ -0,0 +1,55 @@
import { version as currentVersion } from "@/package.json";
const GITHUB_REPO = "felipegcoutinho/openmonetis";
const RELEASES_URL = `https://github.com/${GITHUB_REPO}/releases`;
export type UpdateCheckResult = {
hasUpdate: boolean;
latestVersion: string;
releaseUrl: string;
};
function compareVersions(a: string, b: string): number {
const normalize = (v: string) => v.replace(/^v/, "").split(".").map(Number);
const partsA = normalize(a);
const partsB = normalize(b);
for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
const diff = (partsA[i] ?? 0) - (partsB[i] ?? 0);
if (diff !== 0) return diff;
}
return 0;
}
export async function checkForUpdate(): Promise<UpdateCheckResult> {
const fallback: UpdateCheckResult = {
hasUpdate: false,
latestVersion: currentVersion,
releaseUrl: RELEASES_URL,
};
try {
// GitHub redireciona /releases/latest para a URL com a tag — sem API, sem rate limit
const response = await fetch(
`https://github.com/${GITHUB_REPO}/releases/latest`,
{ redirect: "manual", next: { revalidate: 86400 } },
);
const location = response.headers.get("location");
if (!location) return fallback;
const match = location.match(/releases\/tag\/v?(.+)$/);
if (!match) return fallback;
const latestVersion = match[1];
const releaseUrl = `https://github.com/${GITHUB_REPO}/releases/tag/v${latestVersion}`;
return {
hasUpdate: compareVersions(latestVersion, currentVersion) > 0,
latestVersion,
releaseUrl,
};
} catch {
return fallback;
}
}