fix: back button goes to folder, remove try-catch that redirected to setup on any error
This commit is contained in:
@@ -47,9 +47,11 @@ type DocumentType = {
|
||||
export default function DocumentViewClient({
|
||||
document: doc,
|
||||
organization,
|
||||
backUrl,
|
||||
}: {
|
||||
document: DocumentType;
|
||||
organization: Organization;
|
||||
backUrl?: string | null;
|
||||
}) {
|
||||
const primaryColor = organization.primaryColor || "#2563eb";
|
||||
const [numPages, setNumPages] = useState<number | null>(null);
|
||||
@@ -187,15 +189,23 @@ export default function DocumentViewClient({
|
||||
<p className="text-xs text-white/70 hidden md:block">Portal de Transparência</p>
|
||||
</div>
|
||||
</div>
|
||||
<Link
|
||||
href="/"
|
||||
className="text-white/80 hover:text-white flex items-center gap-1 md:gap-2 text-xs md:text-sm"
|
||||
>
|
||||
<ArrowLeft size={14} className="md:hidden" />
|
||||
<ArrowLeft size={16} className="hidden md:block" />
|
||||
<span className="hidden sm:inline">Voltar ao Portal</span>
|
||||
<span className="sm:hidden">Voltar</span>
|
||||
</Link>
|
||||
{backUrl ? (
|
||||
<Link
|
||||
href={backUrl}
|
||||
className="text-white/80 hover:text-white flex items-center gap-1 md:gap-2 text-xs md:text-sm"
|
||||
>
|
||||
<ArrowLeft size={14} className="md:hidden" />
|
||||
<ArrowLeft size={16} className="hidden md:block" />
|
||||
<span className="hidden sm:inline">Voltar à Pasta</span>
|
||||
<span className="sm:hidden">Voltar</span>
|
||||
</Link>
|
||||
) : (
|
||||
<div className="text-white/50 flex items-center gap-1 md:gap-2 text-xs md:text-sm">
|
||||
<ArrowLeft size={14} className="md:hidden" />
|
||||
<ArrowLeft size={16} className="hidden md:block" />
|
||||
<span className="hidden sm:inline">Documento Público</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ export default async function PublicDocumentPage({
|
||||
primaryColor: true,
|
||||
},
|
||||
},
|
||||
folder: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
isPublished: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -27,10 +34,17 @@ export default async function PublicDocumentPage({
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Determina o link de voltar
|
||||
const backUrl = document.folder?.isPublished
|
||||
? `/visualizar/pasta/${document.folder.id}`
|
||||
: null;
|
||||
|
||||
return (
|
||||
<DocumentViewClient
|
||||
document={document}
|
||||
organization={document.organization}
|
||||
backUrl={backUrl}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,25 +5,20 @@ import LoginClient from "@/components/LoginClient";
|
||||
import { getSession } from "@/app/actions/auth";
|
||||
|
||||
export default async function Page() {
|
||||
try {
|
||||
// Verifica se o usuário já está logado
|
||||
const session = await getSession();
|
||||
if (session) {
|
||||
redirect("/dashboard");
|
||||
}
|
||||
// Verifica se o usuário já está logado
|
||||
const session = await getSession();
|
||||
if (session) {
|
||||
redirect("/dashboard");
|
||||
}
|
||||
|
||||
// Verifica se existe alguma organização cadastrada
|
||||
const organization = await prisma.organization.findFirst();
|
||||
// Verifica se existe alguma organização cadastrada
|
||||
const organization = await prisma.organization.findFirst();
|
||||
|
||||
// Se não houver organização, redireciona para o setup inicial (Instalação)
|
||||
if (!organization) {
|
||||
redirect("/setup");
|
||||
}
|
||||
|
||||
return <LoginClient organization={organization} />;
|
||||
} catch (error) {
|
||||
console.error("Erro ao verificar organização:", error);
|
||||
// Se der erro de banco (provavelmente banco vazio ou não iniciado), vamos para o setup
|
||||
// Se não houver organização, redireciona para o setup inicial (Instalação)
|
||||
if (!organization) {
|
||||
redirect("/setup");
|
||||
}
|
||||
|
||||
return <LoginClient organization={organization} />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user