commit correcoes

This commit is contained in:
2026-11-21 20:58:19 +02:00
parent 4ca54e7655
commit 9d7a14459b
581 changed files with 151192 additions and 1620 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+48 -4
View File
@@ -23,6 +23,8 @@ type Result = {
description: string | null;
url: string;
category: string;
location?: string | null;
coverage?: string | null;
};
type Results = {
data: Result[];
@@ -33,9 +35,26 @@ type Results = {
unavailable: string[];
};
type SearchAnswer = {
type: 'count' | 'guide' | 'products' | 'list';
label: string;
count: number | null;
filter: string;
category?: 'all' | 'physical' | 'financial';
};
const ANSWER_HELP: Record<SearchAnswer['type'], string> = {
count: 'Contagem dos registos publicados e disponíveis para consulta no InvesteMoz.',
list: 'Registos publicados e disponíveis para consulta no InvesteMoz.',
guide: 'Consulte o roteiro público e prepare depois o licenciamento no seu dossier. Os requisitos dependem da actividade e localização.',
products: 'Produtos físicos e referências de cadeias de valor separados dos produtos financeiros. A presença física de uma instituição não determina a cobertura do financiamento.',
};
type CategoryMeta = { icon: LucideIcon; iconClass: string; badgeClass: string };
const CATEGORY_META: Record<string, CategoryMeta> = {
'Produtos e localizações': { icon: Factory, iconClass: 'bg-teal-50 text-teal-700', badgeClass: 'bg-teal-50 text-teal-700' },
'Produtos financeiros': { icon: Landmark, iconClass: 'bg-blue-50 text-blue-700', badgeClass: 'bg-blue-50 text-blue-700' },
'Páginas e serviços': {
icon: Compass,
iconClass: 'bg-slate-100 text-slate-700',
@@ -292,9 +311,11 @@ function QuickLinks() {
export default function Search({
query,
results,
answer = null,
}: {
query: string;
results: Results;
answer?: SearchAnswer | null;
}) {
const [input, setInput] = useState(query);
useEffect(() => setInput(query), [query]);
@@ -308,7 +329,7 @@ export default function Search({
unavailable,
} = results;
const pageUrl = (page: number) =>
`/pesquisa?${new URLSearchParams({ q: query, page: String(page) })}`;
`/pesquisa?${new URLSearchParams({ q: query, page: String(page), ...(answer?.category ? { category: answer.category } : {}) })}`;
const start = total ? (current - 1) * perPage + 1 : 0;
const end = Math.min(start + data.length - 1, total);
const highlight = useMemo(() => buildHighlightRegex(query), [query]);
@@ -340,6 +361,7 @@ export default function Search({
role="search"
className="mt-6 flex max-w-3xl flex-col gap-2 sm:flex-row"
>
{answer?.category && <input type="hidden" name="category" value={answer.category} />}
<label htmlFor="search-query" className="sr-only">
Pesquisar no InvesteMoz
</label>
@@ -376,6 +398,26 @@ export default function Search({
</section>
<div className="mx-auto max-w-5xl px-4 py-8 sm:px-6">
{answer && (
<section aria-label="Resposta à pesquisa" className="mb-6 rounded-xl border border-slate-200 bg-white p-5">
<p className="text-xl font-semibold text-[#101820]" aria-live="polite">
{answer.type !== 'count' ? answer.label : answer.count === null ? 'Contagem indisponível de momento' : `${answer.count.toLocaleString('pt-MZ')} ${answer.label}`}
</p>
<p className="mt-2 text-sm text-slate-600">{ANSWER_HELP[answer.type]}</p>
{answer.filter && answer.type !== 'guide' && <p className="mt-1 text-sm text-slate-600">Correspondência textual: {answer.filter}.</p>}
{answer.type === 'products' && (
<nav aria-label="Categoria de produtos" className="mt-4 flex flex-wrap gap-2">
{([['all', 'Todos'], ['physical', 'Produtos físicos'], ['financial', 'Produtos financeiros']] as const).map(([category, label]) => (
<Link key={category} href={`/pesquisa?${new URLSearchParams({ q: answer.filter, category })}`}
aria-current={(answer.category ?? 'all') === category ? 'page' : undefined}
className={`rounded-full border px-3 py-2 text-sm font-semibold ${(answer.category ?? 'all') === category ? 'border-slate-800 bg-slate-800 text-white' : 'border-slate-200 text-slate-700 hover:bg-slate-100'}`}>
{label}
</Link>
))}
</nav>
)}
</section>
)}
{unavailable.length > 0 && (
<p
role="alert"
@@ -387,7 +429,7 @@ export default function Search({
</p>
)}
{query ? (
{query || answer ? (
<>
<div className="flex flex-wrap items-center justify-between gap-3">
<p
@@ -395,8 +437,8 @@ export default function Search({
className="text-sm text-slate-600"
>
{total > 0
? `Resultados ${start}–${end} de ${total} para “${query}”.`
: `Nenhum resultado nas fontes consultadas para “${query}”.`}
? `Resultados ${start}–${end} de ${total} para “${query || answer?.label}”.`
: `Nenhum resultado nas fontes consultadas para “${query || answer?.label}”.`}
</p>
{last > 1 && (
<span className="rounded-full bg-white px-3 py-1 text-xs font-semibold text-slate-600 ring-1 ring-slate-200">
@@ -473,6 +515,8 @@ export default function Search({
/>
</p>
)}
{item.location && <p className="mt-2 text-sm text-slate-700"><MapPin size={14} className="mr-1 inline" aria-hidden="true" />{item.location}</p>}
{item.coverage && <p className="mt-1 text-xs text-slate-600">{item.coverage}</p>}
</div>
<ArrowUpRight
size={20}