fix: correct V13 and public presentation patterns in isolated QA

This commit is contained in:
2026-11-21 12:36:28 +02:00
parent 1950bb69ec
commit e239a31a76
66 changed files with 3977 additions and 278 deletions
+50 -32
View File
@@ -1,4 +1,5 @@
import { Link, useForm, usePage } from '@inertiajs/react';
import { publicPortfolioText } from '@/lib/public-presentation';
import { searchTerritoryHref } from '@/lib/search-territory';
import { catalogueDetailHref } from '@/lib/catalogue-context';
import { Management } from '../management/shared';
@@ -12,6 +13,7 @@ import {
export default function Index({
records,
management,
publicReferenceNames = {},
filters,
territorySelection = [],
sectors = [],
@@ -19,6 +21,7 @@ export default function Index({
}: {
records: Paginated<Dossier>;
management: boolean;
publicReferenceNames?: Record<string, string>;
sectors?: string[];
publishedOpportunities?: Paginated<{
id: number;
@@ -121,10 +124,11 @@ export default function Index({
{records.data.map((r) => (
<article
key={r.id}
className="space-y-3 rounded-xl border p-5"
className="flex min-w-0 flex-col gap-3 rounded-xl border p-5 [overflow-wrap:anywhere]"
>
<p className="text-sm">
{kind(r)} · {r.content.code}
{kind(r)}
{management && ` · ${r.content.code}`}
{management &&
` · ${r.publication_status === 'published' ? 'Publicado' : 'Rascunho'}`}
</p>
@@ -145,9 +149,13 @@ export default function Index({
</Link>
</h2>
<p>
{r.content.description ??
r.content.focus ??
r.content.anchors}
{publicPortfolioText(
r.content.description ??
r.content.focus ??
r.content.anchors ??
'',
publicReferenceNames,
)}
</p>
{(r.content.location || r.content.region) && (
<p>
@@ -163,37 +171,47 @@ export default function Index({
</span>
</p>
)}
<Link
className="underline"
href={catalogueDetailHref(
`${base}/${r.id}`,
new URLSearchParams(
Object.entries(filters).filter(
([, value]) => Boolean(value),
) as [string, string][],
).toString(),
url,
)}
<nav
aria-label={`Acções de ${r.title}`}
className="mt-auto flex flex-wrap items-center gap-3"
>
Consultar ficha
</Link>
{!management &&
(r.corridor_id || r.cluster_id || r.project_id) && (
<Link
className="ml-4 underline"
href={searchTerritoryHref(
`/oportunidades?${new URLSearchParams(r.corridor_id ? { corridor_id: r.corridor_id } : r.cluster_id ? { cluster_id: r.cluster_id } : { project_id: r.project_id! })}`,
url,
)}
>
Ver oportunidades associadas
</Link>
)}
<Link
className="underline"
href={catalogueDetailHref(
`${base}/${r.id}`,
new URLSearchParams(
Object.entries(filters).filter(
([, value]) => Boolean(value),
) as [string, string][],
).toString(),
url,
)}
>
Consultar ficha
</Link>
{!management &&
(r.corridor_id ||
r.cluster_id ||
r.project_id) && (
<Link
className="underline"
href={searchTerritoryHref(
`/oportunidades?${new URLSearchParams(r.corridor_id ? { corridor_id: r.corridor_id } : r.cluster_id ? { cluster_id: r.cluster_id } : { project_id: r.project_id! })}`,
url,
)}
>
Ver oportunidades associadas
</Link>
)}
</nav>
</article>
))}
</div>
{!records.data.length && (
<div className="space-y-3 rounded-xl border p-5" role="status">
<div
className="flex min-w-0 flex-col gap-3 rounded-xl border p-5 [overflow-wrap:anywhere]"
role="status"
>
<p>
Ainda não existem fichas publicadas para esta pesquisa.
Os filtros activos foram mantidos.
@@ -253,7 +271,7 @@ export default function Index({
{publishedOpportunities.data.map((opportunity) => (
<article
key={opportunity.id}
className="space-y-3 rounded-xl border p-5"
className="flex min-w-0 flex-col gap-3 rounded-xl border p-5 [overflow-wrap:anywhere]"
>
<h3 className="text-xl font-semibold">
<Link
+35 -5
View File
@@ -1,3 +1,8 @@
import PublicReference from '@/components/public-reference';
import {
publicReference,
publicPortfolioText,
} from '@/lib/public-presentation';
import { Link, useForm, router, usePage } from '@inertiajs/react';
import { useState } from 'react';
import { catalogueReturnHref } from '@/lib/catalogue-context';
@@ -30,6 +35,7 @@ export default function Show(props: Props) {
}
type Props = {
publicReferenceNames?: Record<string, string>;
editorialEnabled?: boolean;
competitiveness?: ApprovedCompetitiveness | null;
complements?: ComplementOption[];
@@ -65,6 +71,7 @@ type Props = {
};
function Editor({
publicReferenceNames = {},
editorialEnabled = false,
competitiveness,
complements = [],
@@ -104,9 +111,19 @@ function Editor({
Voltar à pesquisa
</Link>
<p>
{kind(record)} · {record.content.code}
{kind(record)}
{management && ` · ${record.content.code}`}
</p>
<p className="text-sm">Fonte: {record.source}</p>
{(management || publicReference(record.source)) && (
<p className="text-sm">
Fonte:{' '}
{management ? (
record.source
) : (
<PublicReference value={record.source} />
)}
</p>
)}
{competitiveness && (
<ClusterCompetitivenessPublic analysis={competitiveness} />
)}
@@ -150,7 +167,8 @@ function Editor({
Referência de projecto âncora
</h2>
<p>
{anchorProject.code} · {anchorProject.name}
{management && `${anchorProject.code} · `}
{anchorProject.name}
</p>
<p>
Estado registado:{' '}
@@ -234,7 +252,16 @@ function Editor({
>
{z.name}
</Link>{' '}
· {z.association_type} · Fonte: {z.source_reference}
· {z.association_type}
{publicReference(z.source_reference) && (
<>
{' '}
· Fonte:{' '}
<PublicReference
value={z.source_reference}
/>
</>
)}
</p>
))}
</section>
@@ -491,7 +518,10 @@ function Editor({
{labels[key] ?? key}
</dt>
<dd className="mt-1 whitespace-pre-line">
{value}
{publicPortfolioText(
value,
publicReferenceNames,
)}
</dd>
</div>
))}