fix: replace all Link components with native anchor tags and router.push with window.location.href to fix navigation bugs in admin dashboard
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
ArrowUpRight,
|
||||
ArrowRight,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Sidebar } from "@/components/Sidebar";
|
||||
import { DynamicFavicon } from "@/components/DynamicFavicon";
|
||||
@@ -79,16 +78,14 @@ export default function DashboardClient({
|
||||
</div>
|
||||
|
||||
<div className="flex items-center">
|
||||
<Button
|
||||
asChild
|
||||
<a
|
||||
href="/dashboard/documentos?upload=true"
|
||||
style={{ backgroundColor: primaryColor }}
|
||||
className="w-full sm:w-auto h-11 sm:h-10 px-4 sm:px-6 rounded-xl sm:rounded-lg font-bold text-xs shadow-none hover:opacity-90 active:scale-95 transition-all text-white"
|
||||
className="w-full sm:w-auto h-11 sm:h-10 px-4 sm:px-6 rounded-xl sm:rounded-lg font-bold text-xs shadow-none hover:opacity-90 active:scale-95 transition-all text-white flex items-center justify-center"
|
||||
>
|
||||
<Link href="/dashboard/documentos?upload=true">
|
||||
<Plus size={18} className="mr-2 stroke-[3]" />
|
||||
Novo Documento
|
||||
</Link>
|
||||
</Button>
|
||||
<Plus size={18} className="mr-2 stroke-[3]" />
|
||||
Novo Documento
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -165,9 +162,9 @@ export default function DashboardClient({
|
||||
<motion.div initial={{ opacity: 0, y: 15 }} animate={{ opacity: 1, y: 0 }} transition={{ delay: 0.3 }} className="lg:col-span-8">
|
||||
<div className="flex items-center justify-between mb-3 lg:mb-4 px-1">
|
||||
<h3 className="text-base lg:text-lg font-black text-slate-900 tracking-tight">Atividade Recente</h3>
|
||||
<Link href="/dashboard/documentos" className="group flex items-center gap-2 text-[9px] font-bold uppercase tracking-widest text-slate-400 hover:text-slate-900 transition-colors">
|
||||
<a href="/dashboard/documentos" className="group flex items-center gap-2 text-[9px] font-bold uppercase tracking-widest text-slate-400 hover:text-slate-900 transition-colors">
|
||||
Ver Todos <ArrowRight size={12} className="group-hover:translate-x-0.5 transition-transform" />
|
||||
</Link>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-2xl lg:rounded-[24px] border-2 border-slate-100 overflow-hidden">
|
||||
@@ -177,14 +174,12 @@ export default function DashboardClient({
|
||||
<FileText size={20} className="text-slate-300" />
|
||||
</div>
|
||||
<p className="text-slate-500 font-medium mb-4 text-sm">Nenhum documento encontrado.</p>
|
||||
<Button asChild variant="outline" className="rounded-lg border-2 font-bold px-6 h-9 text-[10px] uppercase tracking-widest">
|
||||
<Link href="/dashboard/documentos/novo">Começar Agora</Link>
|
||||
</Button>
|
||||
<a href="/dashboard/documentos/novo" className="inline-flex items-center justify-center rounded-lg border-2 border-slate-200 font-bold px-6 h-9 text-[10px] uppercase tracking-widest hover:bg-slate-50 transition-colors">Começar Agora</a>
|
||||
</div>
|
||||
) : (
|
||||
<div className="divide-y-2 divide-slate-50">
|
||||
{stats.recentDocs.map((doc) => (
|
||||
<Link
|
||||
<a
|
||||
key={doc.id}
|
||||
href={`/dashboard/documentos/${doc.id}`}
|
||||
className="flex items-center gap-3 lg:gap-4 py-3 lg:py-3.5 px-4 lg:px-6 hover:bg-slate-50/50 transition-all group"
|
||||
@@ -207,7 +202,7 @@ export default function DashboardClient({
|
||||
</div>
|
||||
</div>
|
||||
<ChevronRight size={18} className="sm:hidden text-slate-300 shrink-0" />
|
||||
</Link>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -31,7 +31,6 @@ import {
|
||||
Pencil,
|
||||
Calendar,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -212,11 +211,10 @@ export default function DocumentsClient({
|
||||
|
||||
// Navigation Handler
|
||||
const handleRowClick = (item: any) => {
|
||||
if (item.isFolder) {
|
||||
router.push(`/dashboard/documentos?folder=${item.id}`);
|
||||
} else {
|
||||
router.push(`/dashboard/documentos/${item.id}`);
|
||||
}
|
||||
const url = item.isFolder
|
||||
? `/dashboard/documentos?folder=${item.id}`
|
||||
: `/dashboard/documentos/${item.id}`;
|
||||
window.location.href = url;
|
||||
};
|
||||
|
||||
// Unified Filters (Folders + Documents)
|
||||
@@ -580,12 +578,12 @@ export default function DocumentsClient({
|
||||
<div className="flex-1 min-w-0">
|
||||
{/* Breadcrumbs */}
|
||||
<nav className="flex items-center gap-1.5 mb-3 flex-wrap overflow-x-auto">
|
||||
<Link
|
||||
<a
|
||||
href="/dashboard/documentos"
|
||||
className="p-1.5 rounded-lg hover:bg-slate-100 border border-transparent hover:border-slate-200 transition-all text-slate-400 hover:text-slate-900 shrink-0"
|
||||
>
|
||||
<Home size={14} />
|
||||
</Link>
|
||||
</a>
|
||||
{breadcrumb.length === 0 ? (
|
||||
<>
|
||||
<ChevronRight size={10} className="text-slate-300 shrink-0" />
|
||||
@@ -602,12 +600,12 @@ export default function DocumentsClient({
|
||||
{folder.name}
|
||||
</span>
|
||||
) : (
|
||||
<Link
|
||||
<a
|
||||
href={`/dashboard/documentos?folder=${folder.id}`}
|
||||
className="px-2 py-0.5 bg-slate-100 hover:bg-slate-200 border border-slate-200 rounded-md text-[9px] font-bold uppercase tracking-widest text-slate-600 hover:text-slate-900 transition-all truncate max-w-[80px] sm:max-w-none"
|
||||
>
|
||||
{folder.name}
|
||||
</Link>
|
||||
</a>
|
||||
)}
|
||||
</React.Fragment>
|
||||
))
|
||||
@@ -857,7 +855,7 @@ export default function DocumentsClient({
|
||||
</td>
|
||||
<td className="px-4 py-2.5">
|
||||
{item.isFolder ? (
|
||||
<Link
|
||||
<a
|
||||
href={`/dashboard/documentos?folder=${item.id}`}
|
||||
className="flex items-center gap-3"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
@@ -875,7 +873,7 @@ export default function DocumentsClient({
|
||||
<p className="text-sm font-bold text-slate-700 truncate leading-none mb-0.5 group-hover:text-red-600 transition-colors uppercase tracking-tight">{item.name}</p>
|
||||
<p className="text-[10px] font-medium text-slate-400 uppercase tracking-tighter">{item._count?.documents || 0} itens</p>
|
||||
</div>
|
||||
</Link>
|
||||
</a>
|
||||
) : (
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-8 h-8 flex items-center justify-center text-slate-400 shrink-0">
|
||||
@@ -927,16 +925,12 @@ export default function DocumentsClient({
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</Button>
|
||||
<Button
|
||||
asChild
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-all"
|
||||
<a
|
||||
href={item.isFolder ? `/dashboard/documentos?folder=${item.id}` : `/dashboard/documentos/${item.id}`}
|
||||
className="h-8 w-8 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-all flex items-center justify-center"
|
||||
>
|
||||
<Link href={item.isFolder ? `/dashboard/documentos?folder=${item.id}` : `/dashboard/documentos/${item.id}`}>
|
||||
<ChevronRight size={16} />
|
||||
</Link>
|
||||
</Button>
|
||||
<ChevronRight size={16} />
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
Share2,
|
||||
Info,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { updateDocument, deleteDocument } from "@/app/actions/documents";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -124,8 +123,7 @@ export default function DocumentDetailClient({
|
||||
const result = await deleteDocument(document.id);
|
||||
|
||||
if (result.success) {
|
||||
router.push("/dashboard/documentos");
|
||||
router.refresh();
|
||||
window.location.href = "/dashboard/documentos";
|
||||
} else {
|
||||
setMessage({ type: "error", text: result.error || "Erro ao excluir." });
|
||||
setIsDeleting(false);
|
||||
@@ -154,7 +152,7 @@ export default function DocumentDetailClient({
|
||||
<div className="flex flex-col md:flex-row md:items-end justify-between gap-6">
|
||||
<div className="flex-1 min-w-0">
|
||||
<nav className="flex items-center gap-2 mb-3 text-[10px] font-bold uppercase tracking-widest text-slate-400">
|
||||
<Link href="/dashboard/documentos" className="hover:text-slate-900 transition-colors">Documentos</Link>
|
||||
<a href="/dashboard/documentos" className="hover:text-slate-900 transition-colors cursor-pointer">Documentos</a>
|
||||
<ChevronLeft size={10} className="rotate-180" />
|
||||
<span className="text-slate-900 truncate tracking-[0.1em]">Gerenciar Arquivo</span>
|
||||
</nav>
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
FileText,
|
||||
ChevronLeft,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { uploadFile } from "@/app/actions/upload";
|
||||
import { createDocument } from "@/app/actions/documents";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -111,8 +110,7 @@ export default function NewDocumentClient({
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
router.push("/dashboard/documentos");
|
||||
router.refresh();
|
||||
window.location.href = "/dashboard/documentos";
|
||||
} else {
|
||||
setError(result.error || "Erro ao salvar.");
|
||||
setIsSaving(false);
|
||||
@@ -126,7 +124,7 @@ export default function NewDocumentClient({
|
||||
<div className="flex flex-col md:flex-row md:items-end justify-between gap-6">
|
||||
<div className="flex-1 min-w-0">
|
||||
<nav className="flex items-center gap-2 mb-3 text-[10px] font-bold uppercase tracking-widest text-slate-400">
|
||||
<Link href="/dashboard/documentos" className="hover:text-slate-900 transition-colors">Documentos</Link>
|
||||
<a href="/dashboard/documentos" className="hover:text-slate-900 transition-colors cursor-pointer">Documentos</a>
|
||||
<ChevronLeft size={10} className="rotate-180" />
|
||||
<span className="text-slate-900 truncate tracking-[0.1em]">Upload de Arquivo</span>
|
||||
</nav>
|
||||
|
||||
@@ -75,8 +75,7 @@ export default function SetupClient() {
|
||||
const result = await createOrganization(formData);
|
||||
|
||||
if (result.success) {
|
||||
router.push("/dashboard");
|
||||
router.refresh();
|
||||
window.location.href = "/dashboard";
|
||||
} else {
|
||||
alert(result.error || "Erro ao finalizar instalação");
|
||||
setIsSubmitting(false);
|
||||
|
||||
@@ -34,8 +34,7 @@ export default function LoginClient({ organization }: { organization: Organizati
|
||||
setIsLoading(true);
|
||||
const result = await login(email, password);
|
||||
if (result.success) {
|
||||
router.push("/dashboard");
|
||||
router.refresh();
|
||||
window.location.href = "/dashboard";
|
||||
} else {
|
||||
setError(result.error || "Erro ao fazer login");
|
||||
setIsLoading(false);
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
X,
|
||||
Globe,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { logout } from "@/app/actions/auth";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -93,7 +92,7 @@ export function Sidebar({
|
||||
{menuItems.map((item) => {
|
||||
const isActive = pathname === item.href || (item.href !== "/dashboard" && pathname.startsWith(item.href));
|
||||
return (
|
||||
<Link
|
||||
<a
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
@@ -105,7 +104,7 @@ export function Sidebar({
|
||||
>
|
||||
<item.icon size={18} className={`transition-transform duration-300 ${isActive ? "scale-110" : "group-hover:scale-110 opacity-70 group-hover:opacity-100"}`} />
|
||||
<span className="text-[13px] tracking-tight">{item.label}</span>
|
||||
</Link>
|
||||
</a>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
@@ -131,7 +130,7 @@ export function Sidebar({
|
||||
|
||||
<div className="p-4 lg:p-6 mt-auto">
|
||||
<div className="flex flex-col gap-3 lg:gap-4 p-4 lg:p-5 rounded-2xl lg:rounded-[24px] bg-white border border-slate-200/80">
|
||||
<Link
|
||||
<a
|
||||
href="/dashboard/perfil"
|
||||
onClick={() => setMobileOpen(false)}
|
||||
className="flex items-center gap-3 lg:gap-3.5 group"
|
||||
@@ -148,7 +147,7 @@ export function Sidebar({
|
||||
</p>
|
||||
<p className="text-[10px] lg:text-[11px] font-medium text-slate-400 truncate mt-0.5">{user.email}</p>
|
||||
</div>
|
||||
</Link>
|
||||
</a>
|
||||
|
||||
<div className="h-px bg-slate-100 mx-1" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user