diff --git a/src/app/documento/[id]/DocumentViewClient.tsx b/src/app/documento/[id]/DocumentViewClient.tsx index ba384be..718cd17 100644 --- a/src/app/documento/[id]/DocumentViewClient.tsx +++ b/src/app/documento/[id]/DocumentViewClient.tsx @@ -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(null); @@ -187,15 +189,23 @@ export default function DocumentViewClient({

Portal de Transparência

- - - - Voltar ao Portal - Voltar - + {backUrl ? ( + + + + Voltar à Pasta + Voltar + + ) : ( +
+ + + Documento Público +
+ )} diff --git a/src/app/documento/[id]/page.tsx b/src/app/documento/[id]/page.tsx index fa7cb41..b505095 100644 --- a/src/app/documento/[id]/page.tsx +++ b/src/app/documento/[id]/page.tsx @@ -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 ( ); } + diff --git a/src/app/page.tsx b/src/app/page.tsx index 82dcaef..dbd7f56 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -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 ; - } 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 ; } +