commit16
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
|
||||
export type RelatedOpportunitySearch = {
|
||||
query: string;
|
||||
subject: string;
|
||||
href: string;
|
||||
items: {
|
||||
id: number;
|
||||
slug: string;
|
||||
title: string;
|
||||
summary?: string | null;
|
||||
}[];
|
||||
};
|
||||
|
||||
export default function OpportunityRelatedResults({
|
||||
related,
|
||||
loading,
|
||||
error,
|
||||
total,
|
||||
}: {
|
||||
related: RelatedOpportunitySearch | null;
|
||||
loading: boolean;
|
||||
error: string;
|
||||
total: number;
|
||||
}) {
|
||||
if (loading || error || total !== 0 || !related?.items.length) return null;
|
||||
const context = new URL(related.href, 'https://portal.invalid');
|
||||
context.searchParams.set('q', related.query);
|
||||
return (
|
||||
<section
|
||||
className="space-y-3 rounded-xl border border-slate-300 bg-white p-5"
|
||||
aria-label="Fichas relacionadas, sem correspondência completa"
|
||||
>
|
||||
<h3 className="text-xl font-bold">
|
||||
Fichas relacionadas com «{related.subject}»
|
||||
</h3>
|
||||
<p>
|
||||
Não encontrámos fichas que correspondam a todos os termos de «
|
||||
{related.query}». As fichas abaixo são de actividades
|
||||
relacionadas e podem corresponder a outras etapas da cadeia.
|
||||
</p>
|
||||
<ul className="space-y-3">
|
||||
{related.items.map((item) => (
|
||||
<li key={item.id}>
|
||||
<Link
|
||||
className="font-semibold underline"
|
||||
href={`/oportunidades/${encodeURIComponent(item.slug)}${context.search}`}
|
||||
>
|
||||
{item.title}
|
||||
</Link>
|
||||
{item.summary && <p>{item.summary}</p>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Link className="underline" href={related.href}>
|
||||
Ver a pesquisa relacionada «{related.subject}»
|
||||
</Link>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user