113 lines
7.4 KiB
TypeScript
113 lines
7.4 KiB
TypeScript
import { Head, Link } from '@inertiajs/react';
|
|
import { PortalMenu } from '@/layouts/portal-navigation';
|
|
|
|
type DocumentResource = {
|
|
title: string;
|
|
description: string | null;
|
|
category: string;
|
|
topic: string;
|
|
document_type: string;
|
|
document_number: string | null;
|
|
document_date: string | null;
|
|
applicable_from: string | null;
|
|
applicable_until: string | null;
|
|
source_url: string | null;
|
|
language: string;
|
|
version_label: string | null;
|
|
territorial_scope: string;
|
|
territory_name: string | null;
|
|
source_confirmation: string;
|
|
legal_status: string;
|
|
source_reference: string;
|
|
issuer: string | null;
|
|
file_name: string;
|
|
size_bytes: number | null;
|
|
view_url: string | null;
|
|
links: {
|
|
target_type: string;
|
|
target_key: string;
|
|
relationship: string;
|
|
applicability: string;
|
|
condition_text: string | null;
|
|
basis_reference: string | null;
|
|
review_status: string;
|
|
}[];
|
|
};
|
|
|
|
const modulePaths: Record<string, { href: string; label: string }> = {
|
|
simulator: { href: '/Simulador', label: 'Simulador fiscal' },
|
|
investment: { href: '/oportunidades', label: 'Oportunidades de investimento' },
|
|
zones: { href: '/zonas', label: 'ZEE, ZFI e parques industriais' },
|
|
education: { href: '/educacao', label: 'Educação e competências' },
|
|
business: { href: '/negocios', label: 'Negócios' },
|
|
land: { href: '/investidor/terra-duat', label: 'Terra e DUAT' },
|
|
};
|
|
const documentTypeLabels: Record<string, string> = {
|
|
legislation: 'Legislação', procedure: 'Procedimento oficial', official_form: 'Formulário oficial',
|
|
digital_adaptation: 'Adaptação digital de formulário', guidance_template: 'Modelo orientativo',
|
|
guide: 'Guia', study: 'Estudo', reference_data: 'Dados de referência', unknown: 'Tipo por classificar',
|
|
};
|
|
const legalStatusLabels: Record<string, string> = {
|
|
not_applicable: 'Não aplicável', in_force: 'Vigência indicada; confirme o período', historical: 'Histórico',
|
|
proposed: 'Proposta; não é norma vigente', repealed: 'Revogada', amended: 'Alterada; consulte alterações posteriores', unknown: 'Por confirmar',
|
|
};
|
|
|
|
export default function DocumentPage({
|
|
resource,
|
|
backUrl,
|
|
downloadUrl,
|
|
}: {
|
|
resource: DocumentResource;
|
|
backUrl: string;
|
|
downloadUrl: string;
|
|
}) {
|
|
return (
|
|
<div className="min-h-screen bg-slate-50 text-slate-900">
|
|
<Head title={resource.title} />
|
|
<PortalMenu />
|
|
<main className="mx-auto max-w-4xl space-y-6 px-5 py-10">
|
|
<Link className="underline" href={backUrl}>← Voltar à pesquisa</Link>
|
|
<article className="space-y-5 rounded-xl border bg-white p-5 sm:p-8">
|
|
<header className="space-y-2">
|
|
<p className="text-sm text-slate-600">{resource.category} · {resource.topic}</p>
|
|
<h1 className="break-words text-3xl font-bold">{resource.title}</h1>
|
|
{resource.description && <p className="whitespace-pre-line">{resource.description}</p>}
|
|
</header>
|
|
<dl className="grid gap-4 sm:grid-cols-2">
|
|
<div><dt className="font-semibold">Tipo documental</dt><dd>{documentTypeLabels[resource.document_type] ?? resource.document_type}</dd></div>
|
|
<div><dt className="font-semibold">Entidade emitente / autor</dt><dd>{resource.issuer ?? 'Não indicada'}</dd></div>
|
|
<div><dt className="font-semibold">Número e data</dt><dd>{[resource.document_number, resource.document_date].filter(Boolean).join(' · ') || 'Não indicados'}</dd></div>
|
|
<div><dt className="font-semibold">Período de aplicação documentado</dt><dd>{resource.applicable_from || resource.applicable_until ? `${resource.applicable_from ?? 'Início não indicado'} — ${resource.applicable_until ?? 'Sem data final indicada'}` : 'Não registado'}</dd></div>
|
|
<div><dt className="font-semibold">Versão e idioma</dt><dd>{resource.version_label ?? 'Versão não indicada'} · {resource.language}</dd></div>
|
|
<div><dt className="font-semibold">Âmbito</dt><dd>{resource.territorial_scope === 'national' ? 'Nacional' : resource.territory_name ?? 'Por confirmar'}</dd></div>
|
|
<div><dt className="font-semibold">Situação documental</dt><dd>{legalStatusLabels[resource.legal_status] ?? resource.legal_status}</dd></div>
|
|
<div><dt className="font-semibold">Fonte</dt><dd>{resource.source_confirmation === 'official_confirmed' ? 'Fonte oficial confirmada' : resource.source_confirmation === 'identified' ? 'Origem identificada' : 'Por confirmar'}</dd></div>
|
|
</dl>
|
|
<p className="break-words text-sm">Referência: {resource.source_reference}</p>
|
|
{resource.links.length > 0 && <section className="space-y-2">
|
|
<h2 className="text-xl font-semibold">Base legal e documentos relacionados no portal</h2>
|
|
<ul className="list-disc space-y-2 pl-6">
|
|
{resource.links.map((link, index) => {
|
|
const destination = link.target_type === 'module' ? modulePaths[link.target_key] : undefined;
|
|
return <li key={`${link.target_type}-${link.target_key}-${index}`}>
|
|
{destination ? <Link className="underline" href={destination.href}>{destination.label}</Link> : <span>{link.target_type === 'requirement' ? `Requisito documental: ${link.target_key}` : `${link.target_type}: ${link.target_key}`}</span>}
|
|
{' · '}{link.applicability === 'evidence' ? 'evidência documental' : link.applicability}
|
|
{link.condition_text && <span> · Condição: {link.condition_text}</span>}
|
|
{link.basis_reference && <span> · Referência documental (não é regra fiscal): {link.basis_reference}</span>}
|
|
{link.review_status === 'confirmed' ? <span> · Citação conferida no ficheiro; aplicação fiscal pendente</span> : <span> · Pendente de conferência; não constitui fundamento confirmado</span>}
|
|
</li>;
|
|
})}
|
|
</ul>
|
|
</section>}
|
|
<div className="flex flex-wrap gap-3 border-t pt-4">
|
|
<a className="rounded-lg bg-emerald-800 px-5 py-3 font-semibold text-white" href={downloadUrl}>Descarregar ficheiro ({resource.file_name}{resource.size_bytes ? ` · ${Math.ceil(resource.size_bytes / 1024)} KB` : ''})</a>
|
|
{resource.view_url && <a className="rounded-lg border px-5 py-3 font-semibold underline" href={resource.view_url} target="_blank" rel="noreferrer">Consultar ficheiro</a>}
|
|
{resource.source_url && <a className="rounded-lg border px-5 py-3 font-semibold underline" href={resource.source_url} target="_blank" rel="noreferrer">Abrir fonte identificada</a>}
|
|
</div>
|
|
<p className="text-sm text-slate-600">A disponibilização desta referência não certifica vigência, elegibilidade, viabilidade ou aprovação oficial. Consulte o diploma ou a entidade competente para confirmar a sua aplicação ao caso concreto.</p>
|
|
</article>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|