Adicionado botão para atualizar a pagina

This commit is contained in:
Guilherme Bano
2026-02-20 17:56:43 -03:00
committed by Felipe Coutinho
parent 7b3979ad8e
commit 446ab0bb38
2 changed files with 58 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import { AnimatedThemeToggler } from "./animated-theme-toggler";
import LogoutButton from "./auth/logout-button"; import LogoutButton from "./auth/logout-button";
import { CalculatorDialogButton } from "./calculadora/calculator-dialog"; import { CalculatorDialogButton } from "./calculadora/calculator-dialog";
import { PrivacyModeToggle } from "./privacy-mode-toggle"; import { PrivacyModeToggle } from "./privacy-mode-toggle";
import { RefreshPageButton } from "./refresh-page-button";
type SiteHeaderProps = { type SiteHeaderProps = {
notificationsSnapshot: DashboardNotificationsSnapshot; notificationsSnapshot: DashboardNotificationsSnapshot;
@@ -25,6 +26,7 @@ export async function SiteHeader({ notificationsSnapshot }: SiteHeaderProps) {
totalCount={notificationsSnapshot.totalCount} totalCount={notificationsSnapshot.totalCount}
/> />
<CalculatorDialogButton withTooltip /> <CalculatorDialogButton withTooltip />
<RefreshPageButton />
<PrivacyModeToggle /> <PrivacyModeToggle />
<AnimatedThemeToggler /> <AnimatedThemeToggler />
<span className="text-muted-foreground">|</span> <span className="text-muted-foreground">|</span>

View File

@@ -0,0 +1,56 @@
"use client";
import { RiRefreshLine } from "@remixicon/react";
import { useRouter } from "next/navigation";
import { useTransition } from "react";
import { buttonVariants } from "@/components/ui/button";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
import { cn } from "@/lib/utils/ui";
type RefreshPageButtonProps = React.ComponentPropsWithoutRef<"button">;
export function RefreshPageButton({
className,
...props
}: RefreshPageButtonProps) {
const router = useRouter();
const [isPending, startTransition] = useTransition();
const handleClick = () => {
startTransition(() => {
router.refresh();
});
};
return (
<Tooltip>
<TooltipTrigger asChild>
<button
type="button"
onClick={handleClick}
disabled={isPending}
aria-label="Atualizar página"
title="Atualizar página"
className={cn(
buttonVariants({ variant: "ghost", size: "icon-sm" }),
"size-8 text-muted-foreground transition-all duration-200",
"hover:text-foreground focus-visible:ring-2 focus-visible:ring-primary/40 border",
"disabled:pointer-events-none disabled:opacity-50",
className,
)}
{...props}
>
<RiRefreshLine
className={cn("size-4 transition-transform duration-200", isPending && "animate-spin")}
aria-hidden
/>
</button>
</TooltipTrigger>
<TooltipContent side="bottom">Atualizar página</TooltipContent>
</Tooltip>
);
}