fix: harmonizar pesquisa e navegacao dos catalogos em QA
This commit is contained in:
@@ -481,32 +481,6 @@ export default function Services(p: Props) {
|
||||
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} />
|
||||
@@ -677,63 +651,80 @@ export default function Services(p: Props) {
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block min-w-0">
|
||||
Tema
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.topic}
|
||||
onChange={(e) =>
|
||||
filter.setData('topic', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{p.topics?.map((topic) => (
|
||||
<option key={topic}>{topic}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="block min-w-0">
|
||||
Categoria
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.category}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'category',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todas</option>
|
||||
{p.categories?.map((category) => (
|
||||
<option key={category} value={category}>
|
||||
{documentTypeLabels[category] ??
|
||||
category}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="block min-w-0">
|
||||
Tipo documental
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.document_type}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'document_type',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{p.documentTypes?.map((type) => (
|
||||
<option key={type} value={type}>
|
||||
{documentTypeLabels[type] ??
|
||||
'Documento'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{!!(p.topics?.length || filter.data.topic) && (
|
||||
<label className="block min-w-0">
|
||||
Tema
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.topic}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'topic',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{p.topics?.map((topic) => (
|
||||
<option key={topic}>{topic}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{!!(
|
||||
p.categories?.length || filter.data.category
|
||||
) && (
|
||||
<label className="block min-w-0">
|
||||
Categoria
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.category}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'category',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todas</option>
|
||||
{p.categories?.map((category) => (
|
||||
<option
|
||||
key={category}
|
||||
value={category}
|
||||
>
|
||||
{documentTypeLabels[category] ??
|
||||
category}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{!!(
|
||||
p.documentTypes?.length ||
|
||||
filter.data.document_type
|
||||
) && (
|
||||
<label className="block min-w-0">
|
||||
Tipo documental
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.document_type}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'document_type',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{p.documentTypes?.map((type) => (
|
||||
<option key={type} value={type}>
|
||||
{documentTypeLabels[type] ??
|
||||
'Documento'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{!!p.activities?.length && (
|
||||
<fieldset className="min-w-0 rounded border p-3">
|
||||
<legend className="px-1">
|
||||
@@ -866,62 +857,78 @@ export default function Services(p: Props) {
|
||||
</div>
|
||||
</fieldset>
|
||||
)}
|
||||
<label className="block min-w-0">
|
||||
Entidade emitente
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.issuer}
|
||||
onChange={(e) =>
|
||||
filter.setData('issuer', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todas</option>
|
||||
{p.issuers?.map((issuer) => (
|
||||
<option key={issuer}>{issuer}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="block min-w-0">
|
||||
Idioma
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.language}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'language',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{p.languages?.map((language) => (
|
||||
<option key={language}>
|
||||
{language}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="block min-w-0">
|
||||
Situação jurídica indicada
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.legal_status}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'legal_status',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todas</option>
|
||||
{p.legalStatuses?.map((status) => (
|
||||
<option key={status} value={status}>
|
||||
{legalStatusLabels[status] ??
|
||||
'Por confirmar'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{!!(p.issuers?.length || filter.data.issuer) && (
|
||||
<label className="block min-w-0">
|
||||
Entidade emitente
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.issuer}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'issuer',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todas</option>
|
||||
{p.issuers?.map((issuer) => (
|
||||
<option key={issuer}>
|
||||
{issuer}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{!!(
|
||||
p.languages?.length || filter.data.language
|
||||
) && (
|
||||
<label className="block min-w-0">
|
||||
Idioma
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.language}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'language',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{p.languages?.map((language) => (
|
||||
<option key={language}>
|
||||
{language}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{!!(
|
||||
p.legalStatuses?.length ||
|
||||
filter.data.legal_status
|
||||
) && (
|
||||
<label className="block min-w-0">
|
||||
Situação jurídica indicada
|
||||
<select
|
||||
className={input}
|
||||
value={filter.data.legal_status}
|
||||
onChange={(e) =>
|
||||
filter.setData(
|
||||
'legal_status',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todas</option>
|
||||
{p.legalStatuses?.map((status) => (
|
||||
<option key={status} value={status}>
|
||||
{legalStatusLabels[status] ??
|
||||
'Por confirmar'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<label className="block min-w-0">
|
||||
Confirmação da fonte
|
||||
<select
|
||||
@@ -985,30 +992,6 @@ 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"
|
||||
@@ -1307,16 +1290,6 @@ export default function Services(p: Props) {
|
||||
</>
|
||||
)}
|
||||
</main>
|
||||
<footer className="border-t px-5 py-8 text-center text-sm">
|
||||
Investe Moçambique ·{' '}
|
||||
<Link href="/apoio" className="underline">
|
||||
Apoio ao Investidor
|
||||
</Link>{' '}
|
||||
·{' '}
|
||||
<Link href="/documentos" className="underline">
|
||||
Documentos e Formulários
|
||||
</Link>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user