fix: correct V13 and public presentation patterns in isolated QA
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { publicReference, uniquePresentation } from '@/lib/public-presentation';
|
||||
import PublicReference from './public-reference';
|
||||
import { usePage } from '@inertiajs/react';
|
||||
import EvidenceDetails from './evidence-details';
|
||||
|
||||
export type TerritorialSourceEvidence = {
|
||||
@@ -15,28 +18,68 @@ export default function TerritorialSources({
|
||||
}: {
|
||||
sources?: TerritorialSourceEvidence[];
|
||||
}) {
|
||||
if (!sources?.length) return null;
|
||||
const management = usePage().url.startsWith('/management/');
|
||||
const visible = uniquePresentation(
|
||||
(sources ?? []).filter(
|
||||
(row) =>
|
||||
management ||
|
||||
publicReference(row.source_reference) ||
|
||||
publicReference(row.source_quote) ||
|
||||
publicReference(row.supports),
|
||||
),
|
||||
(row) =>
|
||||
JSON.stringify([
|
||||
row.association,
|
||||
row.role,
|
||||
management
|
||||
? row.source_reference
|
||||
: publicReference(row.source_reference),
|
||||
publicReference(row.source_quote),
|
||||
publicReference(row.supports),
|
||||
...(management ? [row.traceability] : []),
|
||||
]),
|
||||
);
|
||||
if (!visible.length) return null;
|
||||
return (
|
||||
<EvidenceDetails title="Fontes das relações territoriais">
|
||||
{sources.map((source, i) => (
|
||||
{visible.map((source, i) => (
|
||||
<article className="border-t pt-3" key={i}>
|
||||
<h3 className="font-semibold">
|
||||
{source.role} — {source.association}
|
||||
</h3>
|
||||
<p>
|
||||
Fonte:{' '}
|
||||
{source.source_reference ??
|
||||
'ligação ao exemplar por recuperar'}
|
||||
</p>
|
||||
<p>{source.source_quote ?? source.supports}</p>
|
||||
{(management ||
|
||||
publicReference(source.source_reference)) && (
|
||||
<p>
|
||||
Fonte:{' '}
|
||||
{management ? (
|
||||
source.source_reference
|
||||
) : (
|
||||
<PublicReference
|
||||
value={source.source_reference}
|
||||
/>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{(publicReference(source.source_quote) ||
|
||||
publicReference(source.supports)) && (
|
||||
<p>
|
||||
{publicReference(source.source_quote) ||
|
||||
publicReference(source.supports)}
|
||||
</p>
|
||||
)}
|
||||
<EvidenceDetails title="Proveniência e versão da referência">
|
||||
<p>
|
||||
{source.official_source_accepted
|
||||
? 'Fonte oficial identificada.'
|
||||
: 'Ligação ao exemplar oficial por recuperar.'}
|
||||
</p>
|
||||
<p>{source.traceability}</p>
|
||||
{source.existing_validation && (
|
||||
{(management ||
|
||||
publicReference(source.traceability)) && (
|
||||
<p>{source.traceability}</p>
|
||||
)}
|
||||
{(management
|
||||
? source.existing_validation
|
||||
: publicReference(source.existing_validation)) && (
|
||||
<p>{source.existing_validation}</p>
|
||||
)}
|
||||
</EvidenceDetails>
|
||||
|
||||
Reference in New Issue
Block a user