vrsao 2
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-08 14:02:01 +02:00
parent bdd766c68a
commit 1106509116
354 changed files with 48275 additions and 24635 deletions
+227 -39
View File
@@ -37,20 +37,34 @@ type DocumentResource = {
const modulePaths: Record<string, { href: string; label: string }> = {
simulator: { href: '/Simulador', label: 'Simulador fiscal' },
investment: { href: '/oportunidades', label: 'Oportunidades de investimento' },
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',
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',
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({
@@ -67,46 +81,220 @@ export default function DocumentPage({
<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>
<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>}
<p className="text-sm text-slate-600">
{resource.category} · {resource.topic}
</p>
<h1 className="text-3xl font-bold break-words">
{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>
<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>
{resource.source_confirmation === 'identified' && <p className="rounded border border-amber-300 bg-amber-50 p-3" role="note">A origem está identificada, mas a autenticidade desta cópia não foi confirmada independentemente. Consulte a fonte indicada.</p>}
<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_label ?? 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>}
{resource.source_confirmation === 'identified' && (
<p
className="rounded border border-amber-300 bg-amber-50 p-3"
role="note"
>
A origem está identificada, mas a autenticidade
desta cópia não foi confirmada independentemente.
Consulte a fonte indicada.
</p>
)}
<p className="text-sm break-words">
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_label ?? 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>}
<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>
<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>
File diff suppressed because it is too large Load Diff
+444 -206
View File
@@ -24,13 +24,24 @@ const titles: Record<string, string> = {
desk: 'Balcão Virtual',
};
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',
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',
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',
};
type Resource = {
id: number;
@@ -410,7 +421,13 @@ function PartnershipForm() {
function Simulator() {
return (
<div className="space-y-5">
<p><Link href="/como-investir" className="underline">Voltar ao roteiro de investimento</Link> para rever mercado, localização, recursos, formalização e execução.</p>
<p>
<Link href="/como-investir" className="underline">
Voltar ao roteiro de investimento
</Link>{' '}
para rever mercado, localização, recursos, formalização e
execução.
</p>
<SimulationForm />
</div>
);
@@ -455,13 +472,41 @@ export default function Services(p: Props) {
});
const [selectedPartner, setSelectedPartner] = useState<number>();
const title = p.sector?.name ?? titles[p.section];
const formTypes = ['official_form', 'digital_adaptation', 'guidance_template'];
const firstFormIndex = p.resources?.data.findIndex((resource) => formTypes.includes(resource.document_type)) ?? -1;
const activeFilterNames: Record<string, string> = { q: 'Texto', topic: 'Assunto', category: 'Categoria', document_type: 'Tipo', activity: 'Actividade', stage: 'Etapa', module: 'Módulo', issuer: 'Emitente', language: 'Idioma', legal_status: 'Situação', source_confirmation: 'Fonte', territory_id: 'Território' };
const activeFilters = Object.entries(filter.data).flatMap(([key, value]) => {
const text = Array.isArray(value) ? value.join(', ') : typeof value === 'string' ? value : '';
return activeFilterNames[key] && text.trim() ? [`${activeFilterNames[key]}: ${text}`] : [];
});
const formTypes = [
'official_form',
'digital_adaptation',
'guidance_template',
];
const firstFormIndex =
p.resources?.data.findIndex((resource) =>
formTypes.includes(resource.document_type),
) ?? -1;
const activeFilterNames: Record<string, string> = {
q: 'Texto',
topic: 'Assunto',
category: 'Categoria',
document_type: 'Tipo',
activity: 'Actividade',
stage: 'Etapa',
module: 'Módulo',
issuer: 'Emitente',
language: 'Idioma',
legal_status: 'Situação',
source_confirmation: 'Fonte',
territory_id: 'Território',
};
const activeFilters = Object.entries(filter.data).flatMap(
([key, value]) => {
const text = Array.isArray(value)
? value.join(', ')
: typeof value === 'string'
? value
: '';
return activeFilterNames[key] && text.trim()
? [`${activeFilterNames[key]}: ${text}`]
: [];
},
);
return (
<div className="min-h-screen bg-slate-50 text-slate-900">
<Head title={title} />
@@ -629,24 +674,124 @@ export default function Services(p: Props) {
))}
</select>
</label>
{!!p.activities?.length && <fieldset className="min-w-0 rounded border p-3">
<legend className="px-1">Actividade ou CAE</legend>
<div className="max-h-36 space-y-2 overflow-y-auto">
{p.activities.map((activity) => <label key={activity} className="flex items-start gap-2 break-words"><input type="checkbox" checked={filter.data.activity.includes(activity)} onChange={(e) => filter.setData('activity', e.target.checked ? [...filter.data.activity, activity] : filter.data.activity.filter((value) => value !== activity))} /><span>{activity}</span></label>)}
</div>
</fieldset>}
{!!p.stages?.length && <fieldset className="min-w-0 rounded border p-3">
<legend className="px-1">Etapa do projecto</legend>
<div className="max-h-36 space-y-2 overflow-y-auto">
{p.stages.map((stage) => <label key={stage} className="flex items-start gap-2 break-words"><input type="checkbox" checked={filter.data.stage.includes(stage)} onChange={(e) => filter.setData('stage', e.target.checked ? [...filter.data.stage, stage] : filter.data.stage.filter((value) => value !== stage))} /><span>{stage}</span></label>)}
</div>
</fieldset>}
{!!p.modules?.length && <fieldset className="min-w-0 rounded border p-3">
<legend className="px-1">Módulo</legend>
<div className="max-h-36 space-y-2 overflow-y-auto">
{p.modules.map((module) => <label key={module} className="flex items-start gap-2 break-words"><input type="checkbox" checked={filter.data.module.includes(module)} onChange={(e) => filter.setData('module', e.target.checked ? [...filter.data.module, module] : filter.data.module.filter((value) => value !== module))} /><span>{module}</span></label>)}
</div>
</fieldset>}
{!!p.activities?.length && (
<fieldset className="min-w-0 rounded border p-3">
<legend className="px-1">
Actividade ou CAE
</legend>
<div className="max-h-36 space-y-2 overflow-y-auto">
{p.activities.map((activity) => (
<label
key={activity}
className="flex items-start gap-2 break-words"
>
<input
type="checkbox"
checked={filter.data.activity.includes(
activity,
)}
onChange={(e) =>
filter.setData(
'activity',
e.target.checked
? [
...filter
.data
.activity,
activity,
]
: filter.data.activity.filter(
(value) =>
value !==
activity,
),
)
}
/>
<span>{activity}</span>
</label>
))}
</div>
</fieldset>
)}
{!!p.stages?.length && (
<fieldset className="min-w-0 rounded border p-3">
<legend className="px-1">
Etapa do projecto
</legend>
<div className="max-h-36 space-y-2 overflow-y-auto">
{p.stages.map((stage) => (
<label
key={stage}
className="flex items-start gap-2 break-words"
>
<input
type="checkbox"
checked={filter.data.stage.includes(
stage,
)}
onChange={(e) =>
filter.setData(
'stage',
e.target.checked
? [
...filter
.data
.stage,
stage,
]
: filter.data.stage.filter(
(value) =>
value !==
stage,
),
)
}
/>
<span>{stage}</span>
</label>
))}
</div>
</fieldset>
)}
{!!p.modules?.length && (
<fieldset className="min-w-0 rounded border p-3">
<legend className="px-1">Módulo</legend>
<div className="max-h-36 space-y-2 overflow-y-auto">
{p.modules.map((module) => (
<label
key={module}
className="flex items-start gap-2 break-words"
>
<input
type="checkbox"
checked={filter.data.module.includes(
module,
)}
onChange={(e) =>
filter.setData(
'module',
e.target.checked
? [
...filter
.data
.module,
module,
]
: filter.data.module.filter(
(value) =>
value !==
module,
),
)
}
/>
<span>{module}</span>
</label>
))}
</div>
</fieldset>
)}
<label className="block min-w-0">
Entidade emitente
<select
@@ -763,188 +908,281 @@ export default function Services(p: Props) {
Limpar filtros
</Link>
</form>
{activeFilters.length > 0 && <section aria-label="Filtros activos" className="rounded border bg-white p-3">
<h2 className="font-semibold">Filtros activos</h2>
<ul className="flex flex-wrap gap-2">{activeFilters.map((item) => <li key={item} className="rounded-full bg-slate-100 px-3 py-1 text-sm">{item}</li>)}</ul>
</section>}
<p role="status" aria-live="polite">{p.resources?.total ?? 0} documentos correspondem aos filtros activos.</p>
{!!p.topics?.length && <nav aria-label="Navegar por assunto" className="flex flex-wrap gap-2">
<span className="font-semibold">Assuntos:</span>
{p.topics.map((topic) => <Link key={topic} className="rounded-full border bg-white px-3 py-1 underline" href={`${p.section === 'documents' ? '/documentos' : '/legislacao'}?${new URLSearchParams({ topic }).toString()}`}>{topic}</Link>)}
</nav>}
<p className="text-sm">Os documentos nacionais aplicáveis continuam incluídos numa pesquisa territorial e são identificados como nacionais. A localização da entidade emitente não define o âmbito de aplicação.</p>
{p.resources?.data.map((r, index) => (
<div key={r.id} className="contents">{index === 0 && <h2 className="pt-4 text-xl font-bold">{firstFormIndex === 0 ? 'Formulários e modelos' : 'Documentos de consulta'}</h2>}{index === firstFormIndex && firstFormIndex > 0 && <h2 className="pt-4 text-xl font-bold">Formulários e modelos</h2>}
<article
key={r.id}
className="min-w-0 space-y-2 overflow-hidden rounded-xl border bg-white p-5"
{activeFilters.length > 0 && (
<section
aria-label="Filtros activos"
className="rounded border bg-white p-3"
>
<h2 className="text-xl font-bold break-words">
{r.title}
{r.essential ? ' · Essencial' : ''}
<h2 className="font-semibold">
Filtros activos
</h2>
<p>
{documentTypeLabels[r.document_type] ?? r.document_type} · {r.category} · {r.topic}
</p>
{r.description && <p>{r.description}</p>}
<dl className="grid gap-2 text-sm sm:grid-cols-2">
<div>
<dt className="font-semibold">
Entidade emitente
</dt>
<dd>{r.issuer ?? 'Não indicada'}</dd>
</div>
<div>
<dt className="font-semibold">
Número e data
</dt>
<dd>
{[
r.document_number,
r.document_date,
]
.filter(Boolean)
.join(' · ') || 'Não indicados'}
</dd>
</div>
<div>
<dt className="font-semibold">
Versão / idioma
</dt>
<dd>
{r.version_label ??
'Versão não indicada'}{' '}
· {r.language}
</dd>
</div>
<div>
<dt className="font-semibold">Período de aplicação documentado</dt>
<dd>{r.applicable_from || r.applicable_until ? `${r.applicable_from ?? 'Início não indicado'} — ${r.applicable_until ?? 'Sem data final indicada'}` : 'Não registado'}</dd>
</div>
<div>
<dt className="font-semibold">
Âmbito
</dt>
<dd>
{r.territorial_scope === 'national'
? 'Nacional'
: r.territorial_scope ===
'unknown'
? 'Por confirmar'
: r.territorial_scope}
</dd>
</div>
<div>
<dt className="font-semibold">Fonte</dt>
<dd>
{r.source_confirmation ===
'official_confirmed'
? 'Fonte oficial confirmada'
: r.source_confirmation ===
'identified'
? 'Origem identificada'
: 'Fonte por confirmar'}
</dd>
</div>
{r.source_confirmation === 'identified' && (
<div className="sm:col-span-2 rounded border border-amber-300 bg-amber-50 p-3" role="note">
A origem está identificada, mas a autenticidade desta cópia não foi confirmada independentemente. Consulte a fonte indicada.
<ul className="flex flex-wrap gap-2">
{activeFilters.map((item) => (
<li
key={item}
className="rounded-full bg-slate-100 px-3 py-1 text-sm"
>
{item}
</li>
))}
</ul>
</section>
)}
<p role="status" aria-live="polite">
{p.resources?.total ?? 0} documentos correspondem
aos filtros activos.
</p>
{!!p.topics?.length && (
<nav
aria-label="Navegar por assunto"
className="flex flex-wrap gap-2"
>
<span className="font-semibold">Assuntos:</span>
{p.topics.map((topic) => (
<Link
key={topic}
className="rounded-full border bg-white px-3 py-1 underline"
href={`${p.section === 'documents' ? '/documentos' : '/legislacao'}?${new URLSearchParams({ topic }).toString()}`}
>
{topic}
</Link>
))}
</nav>
)}
<p className="text-sm">
Os documentos nacionais aplicáveis continuam
incluídos numa pesquisa territorial e são
identificados como nacionais. A localização da
entidade emitente não define o âmbito de aplicação.
</p>
{p.resources?.data.map((r, index) => (
<div key={r.id} className="contents">
{index === 0 && (
<h2 className="pt-4 text-xl font-bold">
{firstFormIndex === 0
? 'Formulários e modelos'
: 'Documentos de consulta'}
</h2>
)}
{index === firstFormIndex &&
firstFormIndex > 0 && (
<h2 className="pt-4 text-xl font-bold">
Formulários e modelos
</h2>
)}
<article
key={r.id}
className="min-w-0 space-y-2 overflow-hidden rounded-xl border bg-white p-5"
>
<h2 className="text-xl font-bold break-words">
{r.title}
{r.essential ? ' · Essencial' : ''}
</h2>
<p>
{documentTypeLabels[r.document_type] ??
r.document_type}{' '}
· {r.category} · {r.topic}
</p>
{r.description && <p>{r.description}</p>}
<dl className="grid gap-2 text-sm sm:grid-cols-2">
<div>
<dt className="font-semibold">
Entidade emitente
</dt>
<dd>
{r.issuer ?? 'Não indicada'}
</dd>
</div>
<div>
<dt className="font-semibold">
Número e data
</dt>
<dd>
{[
r.document_number,
r.document_date,
]
.filter(Boolean)
.join(' · ') ||
'Não indicados'}
</dd>
</div>
<div>
<dt className="font-semibold">
Versão / idioma
</dt>
<dd>
{r.version_label ??
'Versão não indicada'}{' '}
· {r.language}
</dd>
</div>
<div>
<dt className="font-semibold">
Período de aplicação documentado
</dt>
<dd>
{r.applicable_from ||
r.applicable_until
? `${r.applicable_from ?? 'Início não indicado'} — ${r.applicable_until ?? 'Sem data final indicada'}`
: 'Não registado'}
</dd>
</div>
<div>
<dt className="font-semibold">
Âmbito
</dt>
<dd>
{r.territorial_scope ===
'national'
? 'Nacional'
: r.territorial_scope ===
'unknown'
? 'Por confirmar'
: r.territorial_scope}
</dd>
</div>
<div>
<dt className="font-semibold">
Fonte
</dt>
<dd>
{r.source_confirmation ===
'official_confirmed'
? 'Fonte oficial confirmada'
: r.source_confirmation ===
'identified'
? 'Origem identificada'
: 'Fonte por confirmar'}
</dd>
</div>
{r.source_confirmation ===
'identified' && (
<div
className="rounded border border-amber-300 bg-amber-50 p-3 sm:col-span-2"
role="note"
>
A origem está identificada, mas
a autenticidade desta cópia não
foi confirmada
independentemente. Consulte a
fonte indicada.
</div>
)}
<div>
<dt className="font-semibold">
Vigência
</dt>
<dd>
{legalStatusLabels[
r.legal_status
] ?? r.legal_status}
</dd>
</div>
<div>
<dt className="font-semibold">
Revisão
</dt>
<dd>
Revisão administrativa registada{' '}
{r.independent_review
? 'com revisão independente'
: 'sem revisão independente'}
</dd>
</div>
</dl>
<p className="my-3 text-sm">
Fonte: {r.source_reference}
</p>
<Link
className="mr-4 inline-block underline"
href={`/documentos/${r.id}?${new URLSearchParams({ back: currentUrl }).toString()}`}
>
Consultar ficha
</Link>
{r.view_url && (
<a
className="mr-4 inline-block underline"
href={r.view_url}
target="_blank"
rel="noreferrer"
>
Consultar ficheiro
</a>
)}
{r.links?.length > 0 && (
<div className="text-sm">
<strong>
Onde este documento é utilizado:
</strong>
<ul className="list-disc pl-6">
{r.links.map((link, index) => (
<li
key={`${link.target_type}-${link.target_key}-${index}`}
>
{link.target_type ===
'module' &&
publicModulePaths[
link.target_key
] ? (
<Link
className="underline"
href={
publicModulePaths[
link
.target_key
].href
}
>
{
publicModulePaths[
link
.target_key
].label
}
</Link>
) : (
<>
{link.target_type ===
'requirement'
? `Requisito documental: ${link.target_label ?? link.target_key}`
: `${link.target_type}: ${link.target_key}`}
</>
)}{' '}
· {link.relationship} ·{' '}
{link.applicability}
{link.condition_text
? ` · Condição: ${link.condition_text}`
: ''}
{link.basis_reference
? ` · Referência documental: ${link.basis_reference}`
: ''}
{link.review_status ===
'confirmed'
? ' · Citação conferida; aplicação fiscal pendente'
: ' · Pendente de conferência; não é fundamento confirmado'}
</li>
))}
</ul>
</div>
)}
<div>
<dt className="font-semibold">
Vigência
</dt>
<dd>
{legalStatusLabels[r.legal_status] ?? r.legal_status}
</dd>
</div>
<div>
<dt className="font-semibold">
Revisão
</dt>
<dd>
Revisão administrativa registada{' '}
{r.independent_review
? 'com revisão independente'
: 'sem revisão independente'}
</dd>
</div>
</dl>
<p className="my-3 text-sm">
Fonte: {r.source_reference}
</p>
<Link className="mr-4 inline-block underline" href={`/documentos/${r.id}?${new URLSearchParams({ back: currentUrl }).toString()}`}>
Consultar ficha
</Link>
{r.view_url && <a className="mr-4 inline-block underline" href={r.view_url} target="_blank" rel="noreferrer">Consultar ficheiro</a>}
{r.links?.length > 0 && (
<div className="text-sm">
<strong>
Onde este documento é utilizado:
</strong>
<ul className="list-disc pl-6">
{r.links.map((link, index) => (
<li
key={`${link.target_type}-${link.target_key}-${index}`}
>
{link.target_type ===
'module' &&
publicModulePaths[
link.target_key
] ? (
<Link
className="underline"
href={
publicModulePaths[
link.target_key
].href
}
>
{
publicModulePaths[
link.target_key
].label
}
</Link>
) : (
<>
{link.target_type === 'requirement' ? `Requisito documental: ${link.target_label ?? link.target_key}` : `${link.target_type}: ${link.target_key}`}
</>
)}{' '}
· {link.relationship} ·{' '}
{link.applicability}
{link.condition_text
? ` · Condição: ${link.condition_text}`
: ''}
{link.basis_reference
? ` · Referência documental: ${link.basis_reference}`
: ''}
{link.review_status === 'confirmed'
? ' · Citação conferida; aplicação fiscal pendente'
: ' · Pendente de conferência; não é fundamento confirmado'}
</li>
))}
</ul>
</div>
)}
{r.source_url && (
{r.source_url && (
<a
className="underline"
href={r.source_url}
target="_blank"
rel="noreferrer"
>
Abrir fonte identificada
</a>
)}
<a
className="underline"
href={r.source_url}
target="_blank"
rel="noreferrer"
href={r.download_url}
className="ml-4 underline"
>
Abrir fonte identificada
Descarregar {r.title}
</a>
)}
<a
href={r.download_url}
className="ml-4 underline"
>
Descarregar {r.title}
</a>
</article>
</article>
</div>
))}
{!p.resources?.data.length && (