oportunidades 6
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-10 21:17:46 +02:00
parent 01405cbf8a
commit 20971d523f
126 changed files with 44362 additions and 3496 deletions
+6 -3
View File
@@ -102,7 +102,7 @@ function TopBar({
requestCount: number;
}) {
return (
<header className="sticky top-0 z-30 border-b border-slate-200 bg-white/95 backdrop-blur">
<nav aria-label="Navegação das manifestações" className="sticky top-0 z-30 border-b border-slate-200 bg-white/95 backdrop-blur">
<div className="mx-auto flex max-w-6xl flex-wrap items-center justify-between gap-3 px-5 py-4">
<button
onClick={() => onNavigate('home')}
@@ -129,7 +129,7 @@ function TopBar({
</button>
</div>
</div>
</header>
</nav>
);
}
@@ -863,6 +863,7 @@ function InterestForm({
<Field label="País" error={errors.country}>
<CountrySelect
countries={countries}
label="País do requerente"
value={form.country}
onChange={(value) => update('country', value)}
required
@@ -876,6 +877,7 @@ function InterestForm({
>
<CountrySelect
countries={countries}
label="País de origem declarado desta solicitação"
value={form.declared_origin_country_code ?? ''}
onChange={(value) =>
update('declared_origin_country_code', value)
@@ -1100,7 +1102,7 @@ export default function PortalInvestidorApp({
<div className="min-h-screen bg-slate-50 font-sans text-slate-900">
<TopBar onNavigate={navigate} requestCount={requestCount} />
<PortalMenu />
<main>
{view === 'home' && (
<>
<Hero
@@ -1329,6 +1331,7 @@ export default function PortalInvestidorApp({
/>
)}
</main>
<Footer />
<style>{`
+2 -2
View File
@@ -47,7 +47,7 @@ export default function Dashboard({
} | null;
}) {
return (
<main className="space-y-8 p-4 md:p-8">
<div className="space-y-8 p-4 md:p-8">
<Head title="Painel" />
<h1 className="text-2xl font-semibold">Painel do portal</h1>
<ProfileNavigation />
@@ -305,7 +305,7 @@ export default function Dashboard({
<Link href="/" className="inline-block underline">
Voltar ao portal público
</Link>
</main>
</div>
);
}
Dashboard.layout = { breadcrumbs: [{ title: 'Painel', href: dashboard() }] };
+30
View File
@@ -38,6 +38,7 @@ export default function RequestPage({
payments,
caseVersion,
countries,
toolPrefill,
}: {
request: {
id: string;
@@ -80,6 +81,12 @@ export default function RequestPage({
payments: DeskPayment[];
caseVersion: number;
countries: Country[];
toolPrefill: {
description: string;
draft_id: string;
draft_version: number;
snapshot_sha256: string;
} | null;
events: {
id: string;
action: string;
@@ -142,6 +149,29 @@ export default function RequestPage({
</a>
)}
</section>
{canEdit && toolPrefill && (
<section className={card + ' space-y-3'} aria-label="Descrição guardada no projeto">
<h2 className="text-xl font-bold">Reutilizar dados do projeto</h2>
<p>A descrição está vazia neste pedido. Pode reutilizar o resumo já guardado na ferramenta deste dossier, versão {toolPrefill.draft_version}.</p>
<blockquote className="rounded border p-3 whitespace-pre-wrap">{toolPrefill.description}</blockquote>
<p>Esta ação guarda o rascunho com os dados preenchidos nesta página. Reveja-os antes de submeter.</p>
<button
type="button"
className={button}
disabled={form.processing || !!form.data.payload.description?.trim()}
onClick={() => {
form.transform((data) => ({
...data,
version: request.version,
submit: false,
payload: {...data.payload, description: toolPrefill.description},
tool_prefill: {draft_id:toolPrefill.draft_id, draft_version:toolPrefill.draft_version, snapshot_sha256:toolPrefill.snapshot_sha256},
}));
form.put(`/balcao-virtual/pedidos/${request.id}`, {onSuccess: () => form.setData('payload', {...form.data.payload, description:toolPrefill.description})});
}}
>Reutilizar descrição guardada e guardar rascunho</button>
</section>
)}
<section className={card + ' space-y-3'}>
<h2 className="text-xl font-bold">
Verificações automáticas de preparação
+36 -2
View File
@@ -1,5 +1,6 @@
import { Head, Link, useForm } from '@inertiajs/react';
import { Head, Link, router, useForm } from '@inertiajs/react';
import { useState } from 'react';
import type { LegacyArticle } from '@/pages/portal/legacy';
export type InvestmentContext = {
id: string;
@@ -10,15 +11,31 @@ export type InvestmentContext = {
export default function InvestmentContexts({
contexts,
contentSource,
}: {
contexts: InvestmentContext[];
contentSource?: LegacyArticle;
}) {
const [key] = useState(() => globalThis.crypto.randomUUID());
const form = useForm({ title: '', client_key: key, reuse_consent: false });
const form = useForm({
title: '',
client_key: key,
reuse_consent: false,
content_resource_id: contentSource?.id,
});
return (
<main className="mx-auto max-w-5xl space-y-6 p-4 md:p-8">
<Head title="Os meus investimentos" />
<h1 className="text-2xl font-semibold">Os meus investimentos</h1>
{contentSource && (
<p>
Preparar a partir de{' '}
<Link className="underline" href={contentSource.href}>
{contentSource.title}
</Link>
. A fonte e a versão serão guardadas no dossier escolhido.
</p>
)}
<p>
Prepare cada investimento no seu dossier. Pode trabalhar em
várias etapas em paralelo.
@@ -36,6 +53,23 @@ export default function InvestmentContexts({
Guardado em{' '}
{new Date(item.updated_at).toLocaleString('pt-MZ')}
</p>
{contentSource && (
<button
type="button"
className="mt-3 rounded border p-2"
onClick={() =>
router.post(
`/investimentos/${item.id}/conteudos`,
{
version: item.version,
resource_id: contentSource.id,
},
)
}
>
Continuar neste dossier com o artigo
</button>
)}
</li>
))}
</ul>
+41 -3
View File
@@ -31,6 +31,13 @@ type Path = {
next: { code: string; title: string; href: string; action: string } | null;
tools: Record<string, string | null>;
results: PathResult[];
content_sources: {
resource_id: number;
title: string;
return_href: string;
source_url: string;
metadata_version: number;
}[];
documents: {
id: string;
document_id: string;
@@ -349,12 +356,43 @@ export default function InvestmentPath(path: Path) {
);
}
return (
<main className="mx-auto max-w-6xl space-y-6 p-4 md:p-8">
<main className="mx-auto min-w-0 max-w-6xl space-y-6 p-4 [overflow-wrap:anywhere] [&_label]:min-w-0 [&_select]:min-w-0 [&_select]:max-w-full [&_input]:min-w-0 [&_input]:max-w-full md:p-8">
<Head title={path.case.title} />
<Link className="underline" href="/investimentos">
Os meus investimentos
</Link>
<h1 className="text-2xl font-semibold">{path.case.title}</h1>
{!!path.content_sources?.length && (
<section
className="space-y-2 rounded-xl border p-4"
aria-label="Fontes da ideia"
>
<h2 className="font-semibold">
Conteúdos associados à ideia
</h2>
<ul>
{path.content_sources.map((source) => (
<li
key={`${source.resource_id}-${source.metadata_version}`}
>
<Link
className="underline"
href={`${source.return_href}?context=${path.case.id}`}
>
{source.title}
</Link>{' '}
·{' '}
<Link
className="underline"
href={`/documentos/${source.resource_id}`}
>
Exemplar e origem
</Link>
</li>
))}
</ul>
</section>
)}
{flash?.success && <output>{flash.success}</output>}
{error && <p role="alert">{error}</p>}
<section className="rounded-xl border p-4">
@@ -580,7 +618,7 @@ export default function InvestmentPath(path: Path) {
</h2>
{path.canWrite && (
<form
className="grid gap-3"
className="grid min-w-0 gap-3 [&_label]:min-w-0 [&_select]:min-w-0 [&_select]:max-w-full [&_input]:min-w-0 [&_input]:max-w-full"
onSubmit={(event) => {
event.preventDefault();
task.transform((data) => ({
@@ -630,7 +668,7 @@ export default function InvestmentPath(path: Path) {
<input
required
type="datetime-local"
className="rounded border p-2"
className="w-full min-w-0 rounded border p-2"
value={task.data.due_at}
onChange={(e) =>
task.setData('due_at', e.target.value)
@@ -157,6 +157,7 @@ export default function OpportunityResources({
const [busy, setBusy] = useState(false);
const [message, setMessage] = useState('');
const [errors, setErrors] = useState<Record<string, string>>({});
const foreignCountry = Boolean(payload.country_code && payload.country_code !== 'MZ');
const set = (name: string, value: Payload[string]) =>
setPayload((previous) => ({ ...previous, [name]: value }));
function select(nextKind: Kind, record: Resource | null = null) {
@@ -239,7 +240,7 @@ export default function OpportunityResources({
}
setMessage(data.message);
setEditing(null);
setPayload({});
setPayload(kind === 'locations' ? {country_code:'MZ'} : {});
setPath([]);
setGeometry('');
setFile(null);
@@ -272,8 +273,9 @@ export default function OpportunityResources({
</Link>
<p>
Recursos de preparação. Não alteram automaticamente a ficha
pública ou relações territoriais aceites. ClamD real pendente;
scan simulado nunca verifica ficheiros reais.
pública ou relações territoriais aceites. O estado e o motor
do scan são apresentados por ficheiro e versão; um scan
simulado nunca verifica ficheiros reais.
</p>
<div
id="resource-result"
@@ -300,9 +302,8 @@ export default function OpportunityResources({
<p className="rounded border p-3">
Pode guardar anexos para preparação. Cada ficheiro permanece
sem download ou pré-visualização enquanto o seu scan não
estiver concluído. ClamD pendente não impede guardar
metadados, locais ou rascunhos; testes com scanner simulado
não verificam os seus ficheiros.
estiver concluído. Guardar metadados, locais ou rascunhos
é independente do scan e não publica ficheiros.
</p>
)}
<section>
@@ -411,10 +412,37 @@ export default function OpportunityResources({
</h2>
{kind === 'locations' && (
<div>
<Field label="País da localização" error={errors.country_code}><select className={control} disabled={readOnly} value={String(payload.country_code ?? '')} onChange={e=>set('country_code',e.target.value)}><option value="">Por indicar</option>{countries.map(c=><option key={c.code} value={c.code}>{c.name}</option>)}</select></Field>
{payload.country_code !== 'MZ' && <p>A hierarquia abaixo corresponde a Moçambique. Uma localização noutro país requer o seu próprio cadastro; não use territórios moçambicanos para a representar.</p>}
<Field label="País da localização" error={errors.country_code}>
<select
className={control}
disabled={readOnly}
value={String(payload.country_code ?? '')}
onChange={(event) => {
const country = event.target.value;
set('country_code', country || null);
if (country && country !== 'MZ' && path.length) {
setPath([]);
setMessage('A seleção territorial de Moçambique foi retirada do preenchimento ao mudar de país. Guarde para registar a alteração; a geometria própria foi preservada.');
}
}}
>
<option value="">Por indicar</option>
{countries.map(c=><option key={c.code} value={c.code}>{c.name}</option>)}
</select>
</Field>
{foreignCountry && (
<p>A hierarquia abaixo corresponde a Moçambique e não é aplicável ao país escolhido. Pode guardar uma localização incompleta noutro país sem esta hierarquia.</p>
)}
{foreignCountry && path.length > 0 && (
<p role="alert">
Este registo conserva uma seleção territorial de Moçambique incompatível com o país. Escolha Moçambique ou{' '}
<button type="button" className="underline" disabled={readOnly} onClick={() => setPath([])}>
retirar a seleção territorial deste preenchimento
</button>. O registo guardado só muda quando guardar.
</p>
)}
<TerritoryGeometryPreview
territoryId={path.at(-1)?.id}
territoryId={foreignCountry ? undefined : path.at(-1)?.id}
management
endpoint={basePath === '/minhas-oportunidades' ? '/minhas-oportunidades/territory-geometries' : undefined}
/>
@@ -424,6 +452,7 @@ export default function OpportunityResources({
index={index}
parent={path[index - 1]?.id ?? ''}
selected={path[index]}
disabled={readOnly || foreignCountry}
endpoint={basePath === '/minhas-oportunidades' ? '/minhas-oportunidades/territory-options' : '/management/territory-options'}
onChange={(value) =>
setPath((previous) =>
+2 -2
View File
@@ -55,7 +55,7 @@ export function Management({
aiEnabled?: boolean;
}>().props;
return (
<main className="space-y-6 p-4 md:p-8">
<div className="space-y-6 p-4 md:p-8">
<Head title={title} />
{auth?.canManagePortal && basePath !== '/minhas-oportunidades' ? <nav
className="flex flex-wrap gap-4 text-sm underline"
@@ -116,7 +116,7 @@ export function Management({
</p>
)}
{children}
</main>
</div>
);
}
+301
View File
@@ -0,0 +1,301 @@
import { Head, Link, useForm } from '@inertiajs/react';
export type LegacyArticle = {
id: number;
title: string;
author: string;
legacy_id: number;
legacy_category: string;
published_at: string;
modified_at: string;
source_url: string;
href: string;
landing_href: string;
start_href: string;
group: { label: string; heading: string };
related_articles: { id: number; slug: string; title: string; href: string }[];
html: string;
library_href: string;
image: { href: string; alt: string; source_url: string } | null;
sector: { name: string; slug: string } | null;
territorial_references: string[];
territorial_status: string;
opportunities: {
title: string;
slug: string;
province: string;
summary: string;
}[];
};
export default function LegacySector({
article,
articles = [article],
view,
query = '',
match = true,
contentContext,
}: {
article: LegacyArticle;
articles?: LegacyArticle[];
view: 'landing' | 'article';
query?: string;
match?: boolean;
contentContext?: { id: string; title: string } | null;
}) {
const search = useForm({ q: query });
return (
<main className="legacy-agronegocio mx-auto max-w-6xl space-y-8 rounded-2xl bg-[#f6f3ea] p-4 sm:p-8">
<Head
title={
view === 'landing' ? `Explorar ${article.group.label}` : article.title
}
/>
<style>{`
.legacy-agronegocio { color: #10352b; font-family: 'Noto Sans', system-ui, sans-serif; }
.legacy-agronegocio h1, .legacy-agronegocio h2 { font-family: 'Noto Serif', Georgia, serif; }
.legacy-agronegocio a, .legacy-agronegocio button { outline-offset: 4px; }
.legacy-agronegocio a:focus-visible, .legacy-agronegocio button:focus-visible { outline: 3px solid #b22222; }
.legacy-article { font-size: 1.0625rem; line-height: 1.8; overflow-wrap: anywhere; }
.legacy-article p, .legacy-article ul, .legacy-article ol { margin-block: 1.2em; }
.legacy-article ul { list-style: disc; padding-inline-start: 1.6em; }
.legacy-article ol { list-style: decimal; padding-inline-start: 1.6em; }
.legacy-article a { text-decoration: underline; }
`}</style>
<nav className="flex flex-wrap gap-4" aria-label={article.group.label}>
<Link href={article.landing_href} className="underline">
Explorar {article.group.label}
</Link>
<Link href="/sectores" className="underline">
Todos os setores
</Link>
<Link href={article.library_href} className="underline">
Exemplar na biblioteca
</Link>
</nav>
<header className="overflow-hidden rounded-2xl border bg-white">
{article.image && (
<img
className="aspect-video w-full object-cover"
src={article.image.href}
alt={article.image.alt}
width={900}
height={506}
/>
)}
<div className="space-y-3 p-5 sm:p-8">
<p className="text-sm font-semibold tracking-wide text-[#b22222] uppercase">
Conhecer · preparar · acompanhar
</p>
<h1 className="text-3xl font-semibold sm:text-4xl">
{view === 'landing'
? article.group.heading
: article.title}
</h1>
<p>
Explore o setor e prepare a sua ideia com o contexto
guardado no dossier.
</p>
<p className="text-sm">
Fonte: {article.author} · Publicado em{' '}
<time dateTime={article.published_at}>
{article.published_at.slice(0, 10)}
</time>{' '}
· Atualizado em{' '}
<time dateTime={article.modified_at}>
{article.modified_at.slice(0, 10)}
</time>
</p>
</div>
</header>
{view === 'landing' ? (
<section className="space-y-4" aria-labelledby="learn-title">
<h2 id="learn-title" className="text-2xl font-semibold">
Compreender o setor
</h2>
<form
onSubmit={(e) => {
e.preventDefault();
search.get(article.landing_href);
}}
className="flex flex-wrap gap-3"
>
<label className="grid flex-1 gap-1">
Pesquisar no conteúdo
<input
className="min-w-0 rounded border p-3"
value={search.data.q}
onChange={(e) =>
search.setData('q', e.target.value)
}
maxLength={120}
type="search"
/>
</label>
<button
className="self-end rounded bg-[#b22222] px-5 py-3 text-white"
disabled={search.processing}
>
Pesquisar
</button>
</form>
{match ? (
<div className="grid gap-4 sm:grid-cols-2">
{articles.map((item) => (
<article key={item.id} className="space-y-3 rounded-xl border bg-white p-5">
<h3 className="text-xl font-semibold">
<Link className="underline" href={item.href}>
{item.title}
</Link>
</h3>
<p>
Conteúdo editorial preservado do portal Tempo.
</p>
<Link
className="inline-block rounded bg-[#10352b] px-5 py-3 text-white"
href={item.href}
>
Ler o artigo
</Link>
</article>
))}
</div>
) : (
<p role="status">
Nenhum conteúdo corresponde à pesquisa.
</p>
)}
</section>
) : (
<section
aria-label="Artigo educativo"
className="legacy-article max-w-3xl"
dangerouslySetInnerHTML={{ __html: article.html }}
/>
)}
{view === 'article' && article.related_articles.length > 0 && (
<section className="space-y-3" aria-labelledby="related-title">
<h2 id="related-title" className="text-2xl font-semibold">Outras leituras no setor</h2>
<ul className="grid gap-3 sm:grid-cols-2">
{article.related_articles.map((item) => (
<li key={item.id}><Link className="underline" href={item.href}>{item.title}</Link></li>
))}
</ul>
</section>
)}
<section
className="space-y-4 rounded-xl border bg-white p-5"
aria-labelledby="locations-title"
>
<h2 id="locations-title" className="text-2xl font-semibold">
Contexto territorial
</h2>
<ul className="flex flex-wrap gap-3">
{article.territorial_references.map((name) => (
<li key={name} className="rounded border px-3 py-2">
{name}
</li>
))}
</ul>
<p>{article.territorial_status}</p>
<div className="flex flex-wrap gap-4">
<Link href="/carteira?kind=corridor" className="underline">
Consultar os corredores cadastrados
</Link>
<Link href="/zonas" className="underline">
Consultar localizações e mapas disponíveis
</Link>
</div>
</section>
<section
className="space-y-4"
aria-labelledby="opportunities-title"
>
<h2 id="opportunities-title" className="text-2xl font-semibold">
Oportunidades publicadas no setor
</h2>
<p>
Cadastros independentes do artigo, com a sua própria autoria
e situação de publicação.
</p>
{article.opportunities.length ? (
<ul className="grid gap-4 sm:grid-cols-2">
{article.opportunities.map((o) => (
<li
key={o.slug}
className="rounded-xl border bg-white p-5"
>
<h3 className="font-semibold">
<Link
className="underline"
href={`/oportunidades/${o.slug}`}
>
{o.title}
</Link>
</h3>
<p>{o.province}</p>
<p>{o.summary}</p>
</li>
))}
</ul>
) : (
<p>
Ainda não há oportunidades publicadas neste setor. Pode
desenvolver uma ideia no seu dossier.
</p>
)}
</section>
<section
className="space-y-3 rounded-xl bg-[#10352b] p-6 text-white"
aria-labelledby="prepare-title"
>
<h2 id="prepare-title" className="text-2xl font-semibold">
Preparar a sua ideia
</h2>
<p>
A leitura é pública. Para guardar dados pessoais, escolha ou
crie um dossier na sua conta.
</p>
<Link
className="inline-block rounded bg-white px-5 py-3 font-semibold text-[#10352b]"
href={
contentContext
? `/investimentos/${contentContext.id}`
: article.start_href
}
>
{contentContext
? `Continuar: ${contentContext.title}`
: 'Iniciar ou continuar uma ideia'}
</Link>
</section>
<footer className="space-y-2 border-t pt-4 text-sm">
<p>
Conteúdo editorial de {article.author}. Categoria original:{' '}
{article.legacy_category}. Não representa uma oportunidade
concreta, autorização de investimento ou cálculo.
</p>
<a
className="underline"
href={article.source_url}
rel="noopener noreferrer"
>
Consultar a página original
</a>
{article.image && (
<p>
<a
className="underline"
href={article.image.source_url}
rel="noopener noreferrer"
>
Origem da imagem
</a>{' '}
· Autoria individual e data de criação não indicadas no
legado.
</p>
)}
</footer>
</main>
);
}
+4 -2
View File
@@ -161,7 +161,9 @@ export default function Manage({
requirementCatalogue,
requirementAssociationsEnabled,
disclosureAuthorization,
legacyContentEnabled = false,
}: {
legacyContentEnabled?: boolean;
documents: DocumentFile[];
resources: Resource[];
requirementCatalogue: { key: string; label: string; tax: string }[];
@@ -533,9 +535,9 @@ export default function Manage({
}
/>
</Field>
<Field label="Assunto">
<Field label={legacyContentEnabled ? 'Assunto (opcional)' : 'Assunto'}>
<input
required
required={!legacyContentEnabled}
className={control}
value={form.data.topic}
onChange={(e) =>
+2
View File
@@ -264,6 +264,7 @@ function RequestForm({
{field === 'country' ? (
<CountrySelect
countries={countries}
label="País do requerente"
value={form.data.country}
onChange={(value) =>
form.setData('country', value)
@@ -290,6 +291,7 @@ function RequestForm({
País de origem declarado desta solicitação
<CountrySelect
countries={countries}
label="País de origem declarado desta solicitação"
value={form.data.declared_origin_country_code}
onChange={(value) =>
form.setData('declared_origin_country_code', value)