306 lines
14 KiB
TypeScript
306 lines
14 KiB
TypeScript
import { Link, useForm, usePage } from '@inertiajs/react';
|
|
import { publicPortfolioText } from '@/lib/public-presentation';
|
|
import { searchTerritoryHref } from '@/lib/search-territory';
|
|
import { catalogueDetailHref } from '@/lib/catalogue-context';
|
|
import { Management } from '../management/shared';
|
|
import type { Paginated } from '../management/shared';
|
|
import { Layout, Field, control, button, Pagination, kind } from './shared';
|
|
import type { Dossier } from './shared';
|
|
import {
|
|
TerritoryFields,
|
|
type TerritoryOption,
|
|
} from '@/components/investment-territory';
|
|
export default function Index({
|
|
records,
|
|
management,
|
|
publicReferenceNames = {},
|
|
filters,
|
|
territorySelection = [],
|
|
sectors = [],
|
|
publishedOpportunities = null,
|
|
}: {
|
|
records: Paginated<Dossier>;
|
|
management: boolean;
|
|
publicReferenceNames?: Record<string, string>;
|
|
sectors?: string[];
|
|
publishedOpportunities?: Paginated<{
|
|
id: number;
|
|
title: string;
|
|
slug: string;
|
|
summary: string | null;
|
|
location: string;
|
|
}> | null;
|
|
filters: {
|
|
q?: string;
|
|
kind?: string;
|
|
sector?: string;
|
|
province_id?: string;
|
|
district_id?: string;
|
|
admin_post_id?: string;
|
|
locality_id?: string;
|
|
};
|
|
territorySelection?: TerritoryOption[];
|
|
}) {
|
|
const form = useForm({
|
|
q: filters.q ?? '',
|
|
kind: filters.kind ?? '',
|
|
sector: filters.sector ?? '',
|
|
province_id: filters.province_id ?? '',
|
|
district_id: filters.district_id ?? '',
|
|
admin_post_id: filters.admin_post_id ?? '',
|
|
locality_id: filters.locality_id ?? '',
|
|
});
|
|
const base = management ? '/management/portfolio' : '/carteira';
|
|
const { url } = usePage();
|
|
const Frame = management ? Management : Layout;
|
|
return (
|
|
<Frame title="Corredores, clusters e projectos âncora">
|
|
<p>
|
|
Explore o território, identifique os elos da cadeia de valor e
|
|
acompanhe o seu interesse numa única conta.
|
|
</p>
|
|
{management && (
|
|
<p className="rounded border border-amber-500 p-3">
|
|
Matriz documental para revisão. Rascunhos não aparecem no
|
|
portal público. Pontuações não são recomendações
|
|
personalizadas.
|
|
</p>
|
|
)}
|
|
<form
|
|
className="flex flex-wrap items-end gap-3"
|
|
onSubmit={(e) => {
|
|
e.preventDefault();
|
|
form.get(base);
|
|
}}
|
|
>
|
|
<Field label="Pesquisar">
|
|
<input
|
|
className={control}
|
|
value={form.data.q}
|
|
onChange={(e) => form.setData('q', e.target.value)}
|
|
/>
|
|
</Field>
|
|
<Field label="Explorar por">
|
|
<select
|
|
className={control}
|
|
value={form.data.kind}
|
|
onChange={(e) => form.setData('kind', e.target.value)}
|
|
>
|
|
<option value="">Toda a carteira</option>
|
|
<option value="corridor">Corredores</option>
|
|
<option value="cluster">Matriz de clusters</option>
|
|
<option value="project">Projectos âncora</option>
|
|
</select>
|
|
</Field>
|
|
<Field label="Sector documentado">
|
|
<select
|
|
className={control}
|
|
value={form.data.sector}
|
|
onChange={(e) => form.setData('sector', e.target.value)}
|
|
>
|
|
<option value="">Todos os sectores</option>
|
|
{sectors.map((sector) => (
|
|
<option key={sector} value={sector}>
|
|
{sector}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</Field>
|
|
<TerritoryFields
|
|
initial={territorySelection}
|
|
onChange={(path) =>
|
|
form.setData((current) => ({
|
|
...current,
|
|
province_id: path[0]?.id ?? '',
|
|
district_id: path[1]?.id ?? '',
|
|
admin_post_id: path[2]?.id ?? '',
|
|
locality_id: path[3]?.id ?? '',
|
|
}))
|
|
}
|
|
/>
|
|
<button className={button}>Pesquisar</button>
|
|
</form>
|
|
<div className="grid gap-4 md:grid-cols-2">
|
|
{records.data.map((r) => (
|
|
<article
|
|
key={r.id}
|
|
className="flex min-w-0 flex-col gap-3 rounded-xl border p-5 [overflow-wrap:anywhere]"
|
|
>
|
|
<p className="text-sm">
|
|
{kind(r)}
|
|
{management && ` · ${r.content.code}`}
|
|
{management &&
|
|
` · ${r.publication_status === 'published' ? 'Publicado' : 'Rascunho'}`}
|
|
</p>
|
|
<h2 className="text-xl font-semibold">
|
|
<Link
|
|
className="underline"
|
|
href={catalogueDetailHref(
|
|
`${base}/${r.id}`,
|
|
new URLSearchParams(
|
|
Object.entries(filters).filter(
|
|
([, value]) => Boolean(value),
|
|
) as [string, string][],
|
|
).toString(),
|
|
url,
|
|
)}
|
|
>
|
|
{r.title}
|
|
</Link>
|
|
</h2>
|
|
<p>
|
|
{publicPortfolioText(
|
|
r.content.description ??
|
|
r.content.focus ??
|
|
r.content.anchors ??
|
|
'',
|
|
publicReferenceNames,
|
|
)}
|
|
</p>
|
|
{(r.content.location || r.content.region) && (
|
|
<p>
|
|
Localização:{' '}
|
|
{r.content.location ?? r.content.region}
|
|
</p>
|
|
)}
|
|
{r.content.priority && (
|
|
<p>
|
|
{r.content.priority}{' '}
|
|
<span className="text-sm">
|
|
(proposta documental)
|
|
</span>
|
|
</p>
|
|
)}
|
|
<nav
|
|
aria-label={`Acções de ${r.title}`}
|
|
className="mt-auto flex flex-wrap items-center gap-3"
|
|
>
|
|
<Link
|
|
className="underline"
|
|
href={catalogueDetailHref(
|
|
`${base}/${r.id}`,
|
|
new URLSearchParams(
|
|
Object.entries(filters).filter(
|
|
([, value]) => Boolean(value),
|
|
) as [string, string][],
|
|
).toString(),
|
|
url,
|
|
)}
|
|
>
|
|
Consultar ficha
|
|
</Link>
|
|
{!management &&
|
|
(r.corridor_id ||
|
|
r.cluster_id ||
|
|
r.project_id) && (
|
|
<Link
|
|
className="underline"
|
|
href={searchTerritoryHref(
|
|
`/oportunidades?${new URLSearchParams(r.corridor_id ? { corridor_id: r.corridor_id } : r.cluster_id ? { cluster_id: r.cluster_id } : { project_id: r.project_id! })}`,
|
|
url,
|
|
)}
|
|
>
|
|
Ver oportunidades associadas
|
|
</Link>
|
|
)}
|
|
</nav>
|
|
</article>
|
|
))}
|
|
</div>
|
|
{!records.data.length && (
|
|
<div
|
|
className="flex min-w-0 flex-col gap-3 rounded-xl border p-5 [overflow-wrap:anywhere]"
|
|
role="status"
|
|
>
|
|
<p>
|
|
Ainda não existem fichas publicadas para esta pesquisa.
|
|
Os filtros activos foram mantidos.
|
|
</p>
|
|
<p>
|
|
Esta lista contém dossiers territoriais documentados;
|
|
não representa concursos abertos nem confirma
|
|
disponibilidade de infra-estruturas ou incentivos.
|
|
</p>
|
|
<nav
|
|
aria-label="Alternativas de exploração"
|
|
className="flex flex-wrap gap-4"
|
|
>
|
|
<Link
|
|
className="underline"
|
|
href={searchTerritoryHref('/oportunidades', url)}
|
|
>
|
|
Ver oportunidades publicadas
|
|
</Link>
|
|
<Link
|
|
className="underline"
|
|
href={searchTerritoryHref('/zonas', url)}
|
|
>
|
|
Consultar ZEE, ZFI e parques
|
|
</Link>
|
|
<Link className="underline" href="/Simulador">
|
|
Transformar uma ideia num projecto
|
|
</Link>
|
|
</nav>
|
|
</div>
|
|
)}
|
|
<Pagination page={records} />
|
|
{!management && publishedOpportunities && (
|
|
<section
|
|
className="space-y-4"
|
|
aria-label="Oportunidades publicadas nesta consulta"
|
|
>
|
|
<h2 className="text-2xl font-semibold">
|
|
Oportunidades publicadas nesta consulta
|
|
</h2>
|
|
<p>
|
|
Consulte as oportunidades sem repetir a pesquisa. São
|
|
respeitados os filtros de texto, sector e localização; a
|
|
selecção de corredores, clusters ou projectos limita
|
|
esta lista às associações documentadas.
|
|
</p>
|
|
{publishedOpportunities.data.length === 0 && (
|
|
<p role="status">
|
|
Não há oportunidades publicadas com correspondência
|
|
documentada para os filtros desta consulta. Isto não
|
|
demonstra inexistência de oportunidades: rascunhos e
|
|
localizações não documentadas não são incluídos por
|
|
inferência.
|
|
</p>
|
|
)}
|
|
<div className="grid gap-4 md:grid-cols-2">
|
|
{publishedOpportunities.data.map((opportunity) => (
|
|
<article
|
|
key={opportunity.id}
|
|
className="flex min-w-0 flex-col gap-3 rounded-xl border p-5 [overflow-wrap:anywhere]"
|
|
>
|
|
<h3 className="text-xl font-semibold">
|
|
<Link
|
|
className="underline"
|
|
href={catalogueDetailHref(
|
|
`/oportunidades/${opportunity.slug}`,
|
|
new URLSearchParams(
|
|
Object.entries(filters).filter(
|
|
([, value]) =>
|
|
Boolean(value),
|
|
) as [string, string][],
|
|
).toString(),
|
|
url,
|
|
)}
|
|
>
|
|
{opportunity.title}
|
|
</Link>
|
|
</h3>
|
|
{opportunity.summary && (
|
|
<p>{opportunity.summary}</p>
|
|
)}
|
|
<p>{opportunity.location}</p>
|
|
</article>
|
|
))}
|
|
</div>
|
|
<Pagination page={publishedOpportunities} />
|
|
</section>
|
|
)}
|
|
</Frame>
|
|
);
|
|
}
|