organizao de suporte
This commit is contained in:
@@ -54,9 +54,26 @@
|
|||||||
.catalogue-filters-heading {
|
.catalogue-filters-heading {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#catalogue-filter-fields {
|
#catalogue-filter-fields,
|
||||||
|
.catalogue-service-fields {
|
||||||
padding: 0 1.15rem 1.15rem;
|
padding: 0 1.15rem 1.15rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.catalogue-service-fields label {
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.catalogue-service-fields label input:not([type='checkbox']),
|
||||||
|
.catalogue-service-fields label select {
|
||||||
|
margin-top: 0.35rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
.catalogue-service-fields .catalogue-filter-submit > button {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
.catalogue-filters input:not([type='checkbox']),
|
.catalogue-filters input:not([type='checkbox']),
|
||||||
.catalogue-filters select {
|
.catalogue-filters select {
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import {
|
|||||||
type PublicDocument,
|
type PublicDocument,
|
||||||
} from '@/components/public-document-content';
|
} from '@/components/public-document-content';
|
||||||
import { Head, Link, useForm, usePage } from '@inertiajs/react';
|
import { Head, Link, useForm, usePage } from '@inertiajs/react';
|
||||||
import { useState } from 'react';
|
import { useId, useState, type FormEvent, type ReactNode } from 'react';
|
||||||
|
import { ChevronDown, Search, SlidersHorizontal } from 'lucide-react';
|
||||||
|
import '../../../css/investment-catalogue.css';
|
||||||
import { PortalMenu } from '@/components/portal-menu';
|
import { PortalMenu } from '@/components/portal-menu';
|
||||||
import { newSubmissionKey } from '@/lib/portal-api';
|
import { newSubmissionKey } from '@/lib/portal-api';
|
||||||
import { ProvinceSelect } from '@/components/investment-territory';
|
import { ProvinceSelect } from '@/components/investment-territory';
|
||||||
@@ -125,6 +127,68 @@ const states: Record<string, string> = {
|
|||||||
published: 'Publicado',
|
published: 'Publicado',
|
||||||
withdrawn: 'Retirado',
|
withdrawn: 'Retirado',
|
||||||
};
|
};
|
||||||
|
function ServiceFilters({
|
||||||
|
children,
|
||||||
|
onSubmit,
|
||||||
|
clearUrl,
|
||||||
|
onClear,
|
||||||
|
activeCount,
|
||||||
|
}: {
|
||||||
|
children: ReactNode;
|
||||||
|
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
||||||
|
clearUrl: string;
|
||||||
|
onClear: () => void;
|
||||||
|
activeCount: number;
|
||||||
|
}) {
|
||||||
|
const [expanded, setExpanded] = useState(true);
|
||||||
|
const fieldsId = useId();
|
||||||
|
return (
|
||||||
|
<form
|
||||||
|
className="catalogue-filters"
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
aria-label="Filtros de pesquisa"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="catalogue-filters-toggle"
|
||||||
|
aria-expanded={expanded}
|
||||||
|
aria-controls={fieldsId}
|
||||||
|
onClick={() => setExpanded(!expanded)}
|
||||||
|
>
|
||||||
|
<SlidersHorizontal size={18} aria-hidden="true" />
|
||||||
|
<span>Filtros</span>
|
||||||
|
{activeCount > 0 && (
|
||||||
|
<span className="catalogue-count">{activeCount}</span>
|
||||||
|
)}
|
||||||
|
<ChevronDown size={18} aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<h2 className="catalogue-filters-heading">
|
||||||
|
<SlidersHorizontal size={17} aria-hidden="true" /> Filtros
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
id={fieldsId}
|
||||||
|
className={`${expanded ? 'block' : 'hidden'} catalogue-service-fields lg:block`}
|
||||||
|
>
|
||||||
|
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-1">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
<div className="catalogue-filter-submit mt-5 grid gap-3">
|
||||||
|
<button className={button}>
|
||||||
|
<Search size={16} aria-hidden="true" /> Pesquisar
|
||||||
|
</button>
|
||||||
|
<Link
|
||||||
|
className="rounded border px-4 py-2 text-center text-sm underline"
|
||||||
|
href={clearUrl}
|
||||||
|
onClick={onClear}
|
||||||
|
>
|
||||||
|
Limpar filtros
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function Pagination({ page }: { page: Page<unknown> }) {
|
function Pagination({ page }: { page: Page<unknown> }) {
|
||||||
return (
|
return (
|
||||||
<nav aria-label="Paginação" className="flex gap-6 py-5">
|
<nav aria-label="Paginação" className="flex gap-6 py-5">
|
||||||
@@ -469,6 +533,35 @@ export default function Services(p: Props) {
|
|||||||
stage: Array.isArray(p.filters?.stage) ? p.filters.stage : [],
|
stage: Array.isArray(p.filters?.stage) ? p.filters.stage : [],
|
||||||
module: Array.isArray(p.filters?.module) ? p.filters.module : [],
|
module: Array.isArray(p.filters?.module) ? p.filters.module : [],
|
||||||
});
|
});
|
||||||
|
const activeCount = Object.values(filter.data).reduce<number>(
|
||||||
|
(count, value) =>
|
||||||
|
count + (Array.isArray(value) ? value.length : value ? 1 : 0),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const clearFilters = () =>
|
||||||
|
filter.setData((data) => ({
|
||||||
|
...data,
|
||||||
|
q: '',
|
||||||
|
category: '',
|
||||||
|
topic: '',
|
||||||
|
sector: '',
|
||||||
|
province: '',
|
||||||
|
document_type: '',
|
||||||
|
language: '',
|
||||||
|
issuer: '',
|
||||||
|
legal_status: '',
|
||||||
|
source_confirmation: '',
|
||||||
|
territory_id: '',
|
||||||
|
activity: [],
|
||||||
|
stage: [],
|
||||||
|
module: [],
|
||||||
|
}));
|
||||||
|
// Keep a previously selected criterion visible if its option is no longer
|
||||||
|
// returned by the public catalogue, so it can still be removed.
|
||||||
|
const optionsWithSelection = (
|
||||||
|
options: string[] | undefined,
|
||||||
|
selected: string[],
|
||||||
|
) => [...new Set([...(options ?? []), ...selected.filter(Boolean)])];
|
||||||
const [selectedPartner, setSelectedPartner] = useState<number>();
|
const [selectedPartner, setSelectedPartner] = useState<number>();
|
||||||
const title = p.sector?.name ?? titles[p.section];
|
const title = p.sector?.name ?? titles[p.section];
|
||||||
const formTypes = [
|
const formTypes = [
|
||||||
@@ -599,8 +692,16 @@ export default function Services(p: Props) {
|
|||||||
)}
|
)}
|
||||||
{(p.section === 'documents' || p.section === 'legislation') && (
|
{(p.section === 'documents' || p.section === 'legislation') && (
|
||||||
<>
|
<>
|
||||||
<form
|
<div className="investment-catalogue catalogue-workspace">
|
||||||
className="grid min-w-0 gap-3 sm:grid-cols-2 lg:grid-cols-4"
|
<aside aria-label="Filtros da biblioteca">
|
||||||
|
<ServiceFilters
|
||||||
|
activeCount={activeCount}
|
||||||
|
onClear={clearFilters}
|
||||||
|
clearUrl={
|
||||||
|
p.section === 'documents'
|
||||||
|
? '/documentos'
|
||||||
|
: '/legislacao'
|
||||||
|
}
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
filter.get(
|
filter.get(
|
||||||
@@ -616,11 +717,16 @@ export default function Services(p: Props) {
|
|||||||
className={input}
|
className={input}
|
||||||
value={filter.data.q}
|
value={filter.data.q}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
filter.setData('q', e.target.value)
|
filter.setData(
|
||||||
|
'q',
|
||||||
|
e.target.value,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
{!!(p.topics?.length || filter.data.topic) && (
|
{!!(
|
||||||
|
p.topics?.length || filter.data.topic
|
||||||
|
) && (
|
||||||
<label className="block min-w-0">
|
<label className="block min-w-0">
|
||||||
Tema
|
Tema
|
||||||
<select
|
<select
|
||||||
@@ -634,16 +740,25 @@ export default function Services(p: Props) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">Todos</option>
|
<option value="">Todos</option>
|
||||||
{p.topics?.map((topic) => (
|
{optionsWithSelection(
|
||||||
<option key={topic} value={topic}>
|
p.topics,
|
||||||
{documentFacetLabel(topic)}
|
[filter.data.topic],
|
||||||
|
).map((topic) => (
|
||||||
|
<option
|
||||||
|
key={topic}
|
||||||
|
value={topic}
|
||||||
|
>
|
||||||
|
{documentFacetLabel(
|
||||||
|
topic,
|
||||||
|
)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
{!!(
|
{!!(
|
||||||
p.categories?.length || filter.data.category
|
p.categories?.length ||
|
||||||
|
filter.data.category
|
||||||
) && (
|
) && (
|
||||||
<label className="block min-w-0">
|
<label className="block min-w-0">
|
||||||
Categoria
|
Categoria
|
||||||
@@ -658,12 +773,17 @@ export default function Services(p: Props) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">Todas</option>
|
<option value="">Todas</option>
|
||||||
{p.categories?.map((category) => (
|
{optionsWithSelection(
|
||||||
|
p.categories,
|
||||||
|
[filter.data.category],
|
||||||
|
).map((category) => (
|
||||||
<option
|
<option
|
||||||
key={category}
|
key={category}
|
||||||
value={category}
|
value={category}
|
||||||
>
|
>
|
||||||
{documentTypeLabels[category] ??
|
{documentTypeLabels[
|
||||||
|
category
|
||||||
|
] ??
|
||||||
documentFacetLabel(
|
documentFacetLabel(
|
||||||
category,
|
category,
|
||||||
)}
|
)}
|
||||||
@@ -680,7 +800,9 @@ export default function Services(p: Props) {
|
|||||||
Tipo documental
|
Tipo documental
|
||||||
<select
|
<select
|
||||||
className={input}
|
className={input}
|
||||||
value={filter.data.document_type}
|
value={
|
||||||
|
filter.data.document_type
|
||||||
|
}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
filter.setData(
|
filter.setData(
|
||||||
'document_type',
|
'document_type',
|
||||||
@@ -689,22 +811,35 @@ export default function Services(p: Props) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">Todos</option>
|
<option value="">Todos</option>
|
||||||
{p.documentTypes?.map((type) => (
|
{optionsWithSelection(
|
||||||
<option key={type} value={type}>
|
p.documentTypes,
|
||||||
{documentTypeLabels[type] ??
|
[filter.data.document_type],
|
||||||
'Documento'}
|
).map((type) => (
|
||||||
|
<option
|
||||||
|
key={type}
|
||||||
|
value={type}
|
||||||
|
>
|
||||||
|
{documentTypeLabels[
|
||||||
|
type
|
||||||
|
] ?? 'Documento'}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
{!!p.activities?.length && (
|
{!!(
|
||||||
|
p.activities?.length ||
|
||||||
|
filter.data.activity.length
|
||||||
|
) && (
|
||||||
<fieldset className="min-w-0 rounded border p-3">
|
<fieldset className="min-w-0 rounded border p-3">
|
||||||
<legend className="px-1">
|
<legend className="px-1">
|
||||||
Actividade ou CAE
|
Actividade ou CAE
|
||||||
</legend>
|
</legend>
|
||||||
<div className="max-h-36 space-y-2 overflow-y-auto">
|
<div className="max-h-36 space-y-2 overflow-y-auto">
|
||||||
{p.activities.map((activity) => (
|
{optionsWithSelection(
|
||||||
|
p.activities,
|
||||||
|
filter.data.activity,
|
||||||
|
).map((activity) => (
|
||||||
<label
|
<label
|
||||||
key={activity}
|
key={activity}
|
||||||
className="flex items-start gap-2 break-words"
|
className="flex items-start gap-2 break-words"
|
||||||
@@ -717,7 +852,8 @@ export default function Services(p: Props) {
|
|||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
filter.setData(
|
filter.setData(
|
||||||
'activity',
|
'activity',
|
||||||
e.target.checked
|
e.target
|
||||||
|
.checked
|
||||||
? [
|
? [
|
||||||
...filter
|
...filter
|
||||||
.data
|
.data
|
||||||
@@ -725,7 +861,9 @@ export default function Services(p: Props) {
|
|||||||
activity,
|
activity,
|
||||||
]
|
]
|
||||||
: filter.data.activity.filter(
|
: filter.data.activity.filter(
|
||||||
(value) =>
|
(
|
||||||
|
value,
|
||||||
|
) =>
|
||||||
value !==
|
value !==
|
||||||
activity,
|
activity,
|
||||||
),
|
),
|
||||||
@@ -738,13 +876,19 @@ export default function Services(p: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
)}
|
)}
|
||||||
{!!p.stages?.length && (
|
{!!(
|
||||||
|
p.stages?.length ||
|
||||||
|
filter.data.stage.length
|
||||||
|
) && (
|
||||||
<fieldset className="min-w-0 rounded border p-3">
|
<fieldset className="min-w-0 rounded border p-3">
|
||||||
<legend className="px-1">
|
<legend className="px-1">
|
||||||
Etapa do projecto
|
Etapa do projecto
|
||||||
</legend>
|
</legend>
|
||||||
<div className="max-h-36 space-y-2 overflow-y-auto">
|
<div className="max-h-36 space-y-2 overflow-y-auto">
|
||||||
{p.stages.map((stage) => (
|
{optionsWithSelection(
|
||||||
|
p.stages,
|
||||||
|
filter.data.stage,
|
||||||
|
).map((stage) => (
|
||||||
<label
|
<label
|
||||||
key={stage}
|
key={stage}
|
||||||
className="flex items-start gap-2 break-words"
|
className="flex items-start gap-2 break-words"
|
||||||
@@ -757,7 +901,8 @@ export default function Services(p: Props) {
|
|||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
filter.setData(
|
filter.setData(
|
||||||
'stage',
|
'stage',
|
||||||
e.target.checked
|
e.target
|
||||||
|
.checked
|
||||||
? [
|
? [
|
||||||
...filter
|
...filter
|
||||||
.data
|
.data
|
||||||
@@ -765,7 +910,9 @@ export default function Services(p: Props) {
|
|||||||
stage,
|
stage,
|
||||||
]
|
]
|
||||||
: filter.data.stage.filter(
|
: filter.data.stage.filter(
|
||||||
(value) =>
|
(
|
||||||
|
value,
|
||||||
|
) =>
|
||||||
value !==
|
value !==
|
||||||
stage,
|
stage,
|
||||||
),
|
),
|
||||||
@@ -778,11 +925,19 @@ export default function Services(p: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
)}
|
)}
|
||||||
{!!p.modules?.length && (
|
{!!(
|
||||||
|
p.modules?.length ||
|
||||||
|
filter.data.module.length
|
||||||
|
) && (
|
||||||
<fieldset className="min-w-0 rounded border p-3">
|
<fieldset className="min-w-0 rounded border p-3">
|
||||||
<legend className="px-1">Módulo</legend>
|
<legend className="px-1">
|
||||||
|
Módulo
|
||||||
|
</legend>
|
||||||
<div className="max-h-36 space-y-2 overflow-y-auto">
|
<div className="max-h-36 space-y-2 overflow-y-auto">
|
||||||
{p.modules.map((module) => (
|
{optionsWithSelection(
|
||||||
|
p.modules,
|
||||||
|
filter.data.module,
|
||||||
|
).map((module) => (
|
||||||
<label
|
<label
|
||||||
key={module}
|
key={module}
|
||||||
className="flex items-start gap-2 break-words"
|
className="flex items-start gap-2 break-words"
|
||||||
@@ -795,7 +950,8 @@ export default function Services(p: Props) {
|
|||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
filter.setData(
|
filter.setData(
|
||||||
'module',
|
'module',
|
||||||
e.target.checked
|
e.target
|
||||||
|
.checked
|
||||||
? [
|
? [
|
||||||
...filter
|
...filter
|
||||||
.data
|
.data
|
||||||
@@ -803,7 +959,9 @@ export default function Services(p: Props) {
|
|||||||
module,
|
module,
|
||||||
]
|
]
|
||||||
: filter.data.module.filter(
|
: filter.data.module.filter(
|
||||||
(value) =>
|
(
|
||||||
|
value,
|
||||||
|
) =>
|
||||||
value !==
|
value !==
|
||||||
module,
|
module,
|
||||||
),
|
),
|
||||||
@@ -819,8 +977,10 @@ export default function Services(p: Props) {
|
|||||||
investment:
|
investment:
|
||||||
'Oportunidades',
|
'Oportunidades',
|
||||||
zones: 'Zonas e parques',
|
zones: 'Zonas e parques',
|
||||||
education: 'Educação',
|
education:
|
||||||
business: 'Negócios',
|
'Educação',
|
||||||
|
business:
|
||||||
|
'Negócios',
|
||||||
land: 'Terra e DUAT',
|
land: 'Terra e DUAT',
|
||||||
}[module] ??
|
}[module] ??
|
||||||
'Documentos de apoio'}
|
'Documentos de apoio'}
|
||||||
@@ -830,7 +990,9 @@ export default function Services(p: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
)}
|
)}
|
||||||
{!!(p.issuers?.length || filter.data.issuer) && (
|
{!!(
|
||||||
|
p.issuers?.length || filter.data.issuer
|
||||||
|
) && (
|
||||||
<label className="block min-w-0">
|
<label className="block min-w-0">
|
||||||
Entidade emitente
|
Entidade emitente
|
||||||
<select
|
<select
|
||||||
@@ -844,7 +1006,10 @@ export default function Services(p: Props) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">Todas</option>
|
<option value="">Todas</option>
|
||||||
{p.issuers?.map((issuer) => (
|
{optionsWithSelection(
|
||||||
|
p.issuers,
|
||||||
|
[filter.data.issuer],
|
||||||
|
).map((issuer) => (
|
||||||
<option key={issuer}>
|
<option key={issuer}>
|
||||||
{issuer}
|
{issuer}
|
||||||
</option>
|
</option>
|
||||||
@@ -853,7 +1018,8 @@ export default function Services(p: Props) {
|
|||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
{!!(
|
{!!(
|
||||||
p.languages?.length || filter.data.language
|
p.languages?.length ||
|
||||||
|
filter.data.language
|
||||||
) && (
|
) && (
|
||||||
<label className="block min-w-0">
|
<label className="block min-w-0">
|
||||||
Idioma
|
Idioma
|
||||||
@@ -868,12 +1034,17 @@ export default function Services(p: Props) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">Todos</option>
|
<option value="">Todos</option>
|
||||||
{p.languages?.map((language) => (
|
{optionsWithSelection(
|
||||||
|
p.languages,
|
||||||
|
[filter.data.language],
|
||||||
|
).map((language) => (
|
||||||
<option
|
<option
|
||||||
key={language}
|
key={language}
|
||||||
value={language}
|
value={language}
|
||||||
>
|
>
|
||||||
{documentFacetLabel(language)}
|
{documentFacetLabel(
|
||||||
|
language,
|
||||||
|
)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
@@ -896,10 +1067,17 @@ export default function Services(p: Props) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">Todas</option>
|
<option value="">Todas</option>
|
||||||
{p.legalStatuses?.map((status) => (
|
{optionsWithSelection(
|
||||||
<option key={status} value={status}>
|
p.legalStatuses,
|
||||||
{legalStatusLabels[status] ??
|
[filter.data.legal_status],
|
||||||
'Por confirmar'}
|
).map((status) => (
|
||||||
|
<option
|
||||||
|
key={status}
|
||||||
|
value={status}
|
||||||
|
>
|
||||||
|
{legalStatusLabels[
|
||||||
|
status
|
||||||
|
] ?? 'Por confirmar'}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
@@ -909,7 +1087,9 @@ export default function Services(p: Props) {
|
|||||||
Confirmação da fonte
|
Confirmação da fonte
|
||||||
<select
|
<select
|
||||||
className={input}
|
className={input}
|
||||||
value={filter.data.source_confirmation}
|
value={
|
||||||
|
filter.data.source_confirmation
|
||||||
|
}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
filter.setData(
|
filter.setData(
|
||||||
'source_confirmation',
|
'source_confirmation',
|
||||||
@@ -942,6 +1122,24 @@ export default function Services(p: Props) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">Todos</option>
|
<option value="">Todos</option>
|
||||||
|
{filter.data.territory_id &&
|
||||||
|
!p.territories?.some(
|
||||||
|
(territory) =>
|
||||||
|
territory.id ===
|
||||||
|
filter.data
|
||||||
|
.territory_id,
|
||||||
|
) && (
|
||||||
|
<option
|
||||||
|
value={
|
||||||
|
filter.data
|
||||||
|
.territory_id
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Localização seleccionada
|
||||||
|
indisponível — remova o
|
||||||
|
filtro
|
||||||
|
</option>
|
||||||
|
)}
|
||||||
{p.territories?.map((territory) => (
|
{p.territories?.map((territory) => (
|
||||||
<option
|
<option
|
||||||
key={territory.id}
|
key={territory.id}
|
||||||
@@ -952,28 +1150,30 @@ export default function Services(p: Props) {
|
|||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<span className="text-xs text-slate-600">
|
<span className="text-xs text-slate-600">
|
||||||
Documentos nacionais aplicáveis permanecem
|
Documentos nacionais aplicáveis
|
||||||
incluídos.
|
permanecem incluídos.
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<button className={button}>Pesquisar</button>
|
</ServiceFilters>
|
||||||
<Link
|
</aside>
|
||||||
className="self-center underline"
|
<section
|
||||||
href={
|
className="catalogue-results space-y-5"
|
||||||
p.section === 'documents'
|
aria-label="Resultados da biblioteca"
|
||||||
? '/documentos'
|
|
||||||
: '/legislacao'
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
Limpar filtros
|
<h2 className="catalogue-results-heading text-xl font-bold">
|
||||||
</Link>
|
Documentos disponíveis
|
||||||
</form>
|
{p.resources
|
||||||
|
? ` · ${p.resources.total}`
|
||||||
|
: ''}
|
||||||
|
</h2>
|
||||||
{!!p.topics?.length && (
|
{!!p.topics?.length && (
|
||||||
<nav
|
<nav
|
||||||
aria-label="Navegar por assunto"
|
aria-label="Navegar por assunto"
|
||||||
className="flex flex-wrap gap-2"
|
className="flex flex-wrap gap-2"
|
||||||
>
|
>
|
||||||
<span className="font-semibold">Assuntos:</span>
|
<span className="font-semibold">
|
||||||
|
Assuntos:
|
||||||
|
</span>
|
||||||
{p.topics.map((topic) => (
|
{p.topics.map((topic) => (
|
||||||
<Link
|
<Link
|
||||||
key={topic}
|
key={topic}
|
||||||
@@ -988,8 +1188,9 @@ export default function Services(p: Props) {
|
|||||||
<p className="text-sm">
|
<p className="text-sm">
|
||||||
Os documentos nacionais aplicáveis continuam
|
Os documentos nacionais aplicáveis continuam
|
||||||
incluídos numa pesquisa territorial e são
|
incluídos numa pesquisa territorial e são
|
||||||
identificados como nacionais. A localização da
|
identificados como nacionais. A localização
|
||||||
entidade emitente não define o âmbito de aplicação.
|
da entidade emitente não define o âmbito de
|
||||||
|
aplicação.
|
||||||
</p>
|
</p>
|
||||||
{p.resources?.data.map((r, index) => (
|
{p.resources?.data.map((r, index) => (
|
||||||
<div key={r.id} className="contents">
|
<div key={r.id} className="contents">
|
||||||
@@ -1019,15 +1220,22 @@ export default function Services(p: Props) {
|
|||||||
))}
|
))}
|
||||||
{!p.resources?.data.length && (
|
{!p.resources?.data.length && (
|
||||||
<p>
|
<p>
|
||||||
Não existem documentos publicados para esta
|
Não existem documentos publicados para
|
||||||
pesquisa.{' '}
|
esta pesquisa.{' '}
|
||||||
<Link href="/apoio" className="underline">
|
<Link
|
||||||
|
href="/apoio"
|
||||||
|
className="underline"
|
||||||
|
>
|
||||||
Solicitar documento ao apoio
|
Solicitar documento ao apoio
|
||||||
</Link>
|
</Link>
|
||||||
.
|
.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{p.resources && <Pagination page={p.resources} />}
|
{p.resources && (
|
||||||
|
<Pagination page={p.resources} />
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
<div className="flex flex-wrap gap-4">
|
<div className="flex flex-wrap gap-4">
|
||||||
<Link
|
<Link
|
||||||
className={button}
|
className={button}
|
||||||
@@ -1135,8 +1343,12 @@ export default function Services(p: Props) {
|
|||||||
intermediado pelo apoio; os dados privados dos
|
intermediado pelo apoio; os dados privados dos
|
||||||
proponentes não são publicados.
|
proponentes não são publicados.
|
||||||
</p>
|
</p>
|
||||||
<form
|
<div className="investment-catalogue catalogue-workspace">
|
||||||
className="grid gap-3 md:grid-cols-4"
|
<aside aria-label="Filtros de parcerias">
|
||||||
|
<ServiceFilters
|
||||||
|
activeCount={activeCount}
|
||||||
|
clearUrl="/parcerias"
|
||||||
|
onClear={clearFilters}
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
filter.get('/parcerias');
|
filter.get('/parcerias');
|
||||||
@@ -1154,7 +1366,9 @@ export default function Services(p: Props) {
|
|||||||
}
|
}
|
||||||
{key === 'province' ? (
|
{key === 'province' ? (
|
||||||
<ProvinceSelect
|
<ProvinceSelect
|
||||||
value={filter.data.province}
|
value={
|
||||||
|
filter.data.province
|
||||||
|
}
|
||||||
onChange={(province) =>
|
onChange={(province) =>
|
||||||
filter.setData(
|
filter.setData(
|
||||||
'province',
|
'province',
|
||||||
@@ -1180,8 +1394,18 @@ export default function Services(p: Props) {
|
|||||||
</label>
|
</label>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
<button className={button}>Filtrar</button>
|
</ServiceFilters>
|
||||||
</form>
|
</aside>
|
||||||
|
<section
|
||||||
|
className="catalogue-results space-y-5"
|
||||||
|
aria-label="Resultados de parcerias"
|
||||||
|
>
|
||||||
|
<h2 className="catalogue-results-heading text-xl font-bold">
|
||||||
|
Parcerias publicadas
|
||||||
|
{p.partnerships
|
||||||
|
? ` · ${p.partnerships.total}`
|
||||||
|
: ''}
|
||||||
|
</h2>
|
||||||
{p.partnerships?.data.map((item) => (
|
{p.partnerships?.data.map((item) => (
|
||||||
<article
|
<article
|
||||||
key={item.id}
|
key={item.id}
|
||||||
@@ -1203,7 +1427,9 @@ export default function Services(p: Props) {
|
|||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
className={button}
|
className={button}
|
||||||
onClick={() => setSelectedPartner(item.id)}
|
onClick={() =>
|
||||||
|
setSelectedPartner(item.id)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Pedir contacto sobre esta parceria
|
Pedir contacto sobre esta parceria
|
||||||
</button>
|
</button>
|
||||||
@@ -1211,11 +1437,15 @@ export default function Services(p: Props) {
|
|||||||
))}
|
))}
|
||||||
{!p.partnerships?.data.length && (
|
{!p.partnerships?.data.length && (
|
||||||
<p>
|
<p>
|
||||||
Ainda não existem propostas publicadas para esta
|
Ainda não existem propostas publicadas
|
||||||
pesquisa.
|
para esta pesquisa.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{p.partnerships && <Pagination page={p.partnerships} />}
|
{p.partnerships && (
|
||||||
|
<Pagination page={p.partnerships} />
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
{selectedPartner && (
|
{selectedPartner && (
|
||||||
<RequestForm
|
<RequestForm
|
||||||
key={selectedPartner}
|
key={selectedPartner}
|
||||||
@@ -1272,8 +1502,8 @@ export default function Services(p: Props) {
|
|||||||
</p>
|
</p>
|
||||||
))}
|
))}
|
||||||
<Link href="/investidor" className="underline">
|
<Link href="/investidor" className="underline">
|
||||||
Consultar oportunidades e manifestações de interesse da
|
Consultar oportunidades e manifestações de interesse
|
||||||
carteira
|
da carteira
|
||||||
</Link>
|
</Link>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import { compileFunction } from 'node:vm';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
import { createElement } from 'react';
|
||||||
|
import { renderToStaticMarkup } from 'react-dom/server';
|
||||||
|
import ts from 'typescript';
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const Empty = () => null;
|
||||||
|
function render(section, filters = {}) {
|
||||||
|
const source = fs.readFileSync(
|
||||||
|
new URL(
|
||||||
|
'../../resources/js/pages/portal/services.tsx',
|
||||||
|
import.meta.url,
|
||||||
|
),
|
||||||
|
'utf8',
|
||||||
|
);
|
||||||
|
const code = ts.transpileModule(source, {
|
||||||
|
compilerOptions: {
|
||||||
|
module: ts.ModuleKind.CommonJS,
|
||||||
|
target: ts.ScriptTarget.ES2022,
|
||||||
|
jsx: ts.JsxEmit.ReactJSX,
|
||||||
|
},
|
||||||
|
}).outputText;
|
||||||
|
const module = { exports: {} };
|
||||||
|
const props = { auth: { user: null } };
|
||||||
|
const mocks = {
|
||||||
|
'lucide-react': {
|
||||||
|
ChevronDown: Empty,
|
||||||
|
Search: Empty,
|
||||||
|
SlidersHorizontal: Empty,
|
||||||
|
},
|
||||||
|
'@inertiajs/react': {
|
||||||
|
Head: Empty,
|
||||||
|
Link: 'a',
|
||||||
|
usePage: () => ({ props, url: '/documentos' }),
|
||||||
|
useForm: (data) => ({ data, setData() {}, get() {} }),
|
||||||
|
},
|
||||||
|
'@/lib/document-facet-label': { documentFacetLabel: (value) => value },
|
||||||
|
'@/lib/portal-presentation': { PORTAL_MORE_LINK: '' },
|
||||||
|
'../../../css/investment-catalogue.css': {},
|
||||||
|
};
|
||||||
|
compileFunction(code, ['require', 'module', 'exports'])(
|
||||||
|
(name) => {
|
||||||
|
if (mocks[name]) return mocks[name];
|
||||||
|
if (name.startsWith('@/'))
|
||||||
|
return new Proxy(
|
||||||
|
{ __esModule: true, default: Empty },
|
||||||
|
{ get: (target, key) => target[key] ?? Empty },
|
||||||
|
);
|
||||||
|
return require(name);
|
||||||
|
},
|
||||||
|
module,
|
||||||
|
module.exports,
|
||||||
|
);
|
||||||
|
return renderToStaticMarkup(
|
||||||
|
createElement(module.exports.default, {
|
||||||
|
section,
|
||||||
|
filters,
|
||||||
|
topics: ['Fiscalidade'],
|
||||||
|
categories: ['Legislação'],
|
||||||
|
documentTypes: ['guide'],
|
||||||
|
activities: ['CAE exemplo'],
|
||||||
|
stages: ['Etapa exemplo'],
|
||||||
|
modules: ['simulator'],
|
||||||
|
issuers: ['Instituição exemplo'],
|
||||||
|
languages: ['Português'],
|
||||||
|
legalStatuses: ['amended'],
|
||||||
|
territories: [{ id: 'territory', name: 'Cabo Delgado' }],
|
||||||
|
resources: {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
prev_page_url: null,
|
||||||
|
next_page_url: null,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
test('biblioteca e legislação mantêm todos os critérios e opções visíveis no painel aberto', () => {
|
||||||
|
for (const section of ['documents', 'legislation']) {
|
||||||
|
const html = render(section);
|
||||||
|
for (const label of [
|
||||||
|
'Pesquisar',
|
||||||
|
'Tema',
|
||||||
|
'Fiscalidade',
|
||||||
|
'Categoria',
|
||||||
|
'Legislação',
|
||||||
|
'Tipo documental',
|
||||||
|
'Guia',
|
||||||
|
'Actividade ou CAE',
|
||||||
|
'CAE exemplo',
|
||||||
|
'Etapa do projecto',
|
||||||
|
'Etapa exemplo',
|
||||||
|
'Módulo',
|
||||||
|
'Simulador fiscal',
|
||||||
|
'Entidade emitente',
|
||||||
|
'Instituição exemplo',
|
||||||
|
'Idioma',
|
||||||
|
'Português',
|
||||||
|
'Situação jurídica indicada',
|
||||||
|
'Alterada; consulte alterações posteriores',
|
||||||
|
'Confirmação da fonte',
|
||||||
|
'Fonte oficial confirmada',
|
||||||
|
'Âmbito territorial',
|
||||||
|
'Cabo Delgado',
|
||||||
|
'Limpar filtros',
|
||||||
|
])
|
||||||
|
assert.ok(html.includes(label), `${section}: ${label}`);
|
||||||
|
assert.match(html, /aria-expanded="true"/);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('critérios seleccionados continuam acessíveis quando já não constam das opções', () => {
|
||||||
|
const html = render('documents', {
|
||||||
|
topic: 'Tema antigo',
|
||||||
|
activity: ['CAE antigo'],
|
||||||
|
stage: ['Etapa antiga'],
|
||||||
|
module: ['outro'],
|
||||||
|
territory_id: 'old-territory',
|
||||||
|
});
|
||||||
|
for (const value of [
|
||||||
|
'Tema antigo',
|
||||||
|
'CAE antigo',
|
||||||
|
'Etapa antiga',
|
||||||
|
'Documentos de apoio',
|
||||||
|
'old-territory',
|
||||||
|
'Localização seleccionada indisponível',
|
||||||
|
])
|
||||||
|
assert.ok(html.includes(value), value);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user