This commit is contained in:
2026-11-02 20:31:15 +02:00
parent 8ddfa93f45
commit 1da273f1f3
131 changed files with 14802 additions and 526 deletions
@@ -5,6 +5,7 @@ import type { FormEvent } from 'react';
import { newSubmissionKey } from '@/lib/portal-api';
import { Frame, Field, button, card, input } from './shared';
import CountrySelect, { type Country } from '@/components/country-select';
import { businessModalities } from './business-types';
type Opportunity = {
id: string;
@@ -190,20 +191,20 @@ export default function BusinessInterest({
) : (
<form className={`${card} space-y-4`} onSubmit={submit}>
<div className="space-y-1 text-sm font-medium">
<span>País de origem declarado desta solicitação</span>
<span>País de origem do pedido (opcional)</span>
<CountrySelect
countries={countries}
id={fieldId('declared_origin_country_code')}
error={fieldErrors.declared_origin_country_code}
value={form.declared_origin_country_code}
label="País de origem declarado desta solicitação"
label="País de origem do pedido (opcional)"
onChange={(value) =>
update('declared_origin_country_code', value)
}
/>
<p className="text-sm">
Origem opcional e independente do país do
investidor.
País de onde apresenta este pedido. Pode ser
diferente do país do requerente.
</p>
</div>
<Field label="Nome ou denominação">
@@ -261,7 +262,9 @@ export default function BusinessInterest({
{fieldError('investorType')}
</Field>
<div className="space-y-1 text-sm font-medium">
<span>País</span>
<label htmlFor={fieldId('country')}>
País do requerente
</label>
<CountrySelect
countries={countries}
required
@@ -296,7 +299,8 @@ export default function BusinessInterest({
>
{modalities.map((modality) => (
<option key={modality} value={modality}>
{modality.replaceAll('_', ' ')}
{businessModalities[modality] ??
modality.replaceAll('_', ' ')}
</option>
))}
</select>
@@ -314,7 +318,7 @@ export default function BusinessInterest({
/>
{fieldError('investmentRange')}
</Field>
<Field label="Motivação e pedido">
<Field label="Como pretende participar nesta oportunidade?">
<textarea
className={input}
required
@@ -2,6 +2,9 @@ import { Link } from '@inertiajs/react';
import { Frame, button, card } from './shared';
import { businessModalities } from './business-types';
import PartnershipSourceLinks from '@/components/partnership-source-links';
import SimilarBusinesses from '@/components/similar-businesses';
import { downloadPublicBusinessOffline } from '@/lib/public-business-offline';
import { useState } from 'react';
import {
ClassificationSummary,
type PublicClassification,
@@ -24,17 +27,21 @@ type Business = {
district?: string | null;
locality?: string | null;
sector?: { name: string; slug: string } | null;
published_at?: string | null;
};
export default function BusinessOpportunity({
record,
returnUrl = '/negocios',
interestUrl = `/negocios/${record.slug}/manifestar-interesse`,
similarCatalogueUrl,
}: {
record: Business;
returnUrl?: string;
interestUrl?: string;
similarCatalogueUrl?: string;
}) {
const [offlineMessage, setOfflineMessage] = useState('');
return (
<Frame title={record.title}>
<Link
@@ -88,7 +95,52 @@ export default function BusinessOpportunity({
<Link className={button} href={interestUrl}>
Manifestar interesse
</Link>
<div className="space-y-2">
<button
type="button"
className="underline"
onClick={() => {
try {
downloadPublicBusinessOffline(
record,
businessModalities[record.modality] ??
record.modality,
);
setOfflineMessage(
'Ficheiro preparado. Guarde-o e abra-o para consultar esta ficha sem rede.',
);
} catch {
setOfflineMessage(
'Não foi possível preparar o ficheiro. Tente novamente.',
);
}
}}
>
Guardar ficha para consulta offline (.html)
</button>
<p role="status" aria-live="polite">
{offlineMessage}
</p>
</div>
</section>
{similarCatalogueUrl && (
<SimilarBusinesses
currentId={record.id}
classifications={record.multidimensional}
catalogueUrl={similarCatalogueUrl}
criteria={[
businessModalities[record.modality] ?? record.modality,
...(record.sector ? [record.sector.name] : []),
...(record.province &&
new URL(
similarCatalogueUrl,
'https://portal.invalid',
).searchParams.has('province_id')
? [record.province]
: []),
]}
/>
)}
</Frame>
);
}
+53 -40
View File
@@ -1,3 +1,7 @@
import {
readOpportunitySelection,
persistOpportunitySelection,
} from '@/lib/opportunity-selection';
import CatalogueGuideLinks from '@/components/catalogue-guide-links';
import OpportunityCorridorGroups, {
type CorridorGroup,
@@ -6,10 +10,12 @@ import { searchTerritoryHref } from '@/lib/search-territory';
import type { EducationalArticle } from '@/components/educational-article-card';
import OpportunitySearchFilters from '@/components/opportunity-search-filters';
import SearchState from '@/components/search-state';
import OpportunityRelatedResults, {
type RelatedOpportunitySearch,
} from '@/components/opportunity-related-results';
import { Link, router, useForm, usePage } from '@inertiajs/react';
import { useEffect, useRef, useState } from 'react';
import Map from '@/components/interactive-investment-map';
import TerritoryGeometryPreview from '@/components/territory-geometry-preview';
import Map from '@/components/catalogue-investment-map';
import type { InvestmentMapArea } from '@/components/interactive-investment-map';
import { type TerritoryOption } from '@/components/investment-territory';
import { Frame, button, card, money, api } from './shared';
@@ -29,7 +35,9 @@ export default function Catalogue({
territorySelection,
catalogueUrl,
corridorGroups = [],
relatedSearch = null,
}: {
relatedSearch?: RelatedOpportunitySearch | null;
guides?: EducationalArticle[];
corridorGroups?: CorridorGroup[];
filters: Record<string, string | string[] | boolean>;
@@ -55,27 +63,19 @@ export default function Catalogue({
const page = usePage<{ auth: { user: unknown } }>();
const { auth } = page.props;
const [investmentSelection, setInvestmentSelection] = useState<number[]>(
() => {
try {
return JSON.parse(
sessionStorage.getItem(
'investment-opportunity-selection',
) ?? '[]',
);
} catch {
return [];
}
},
readOpportunitySelection,
);
const [selectionStorageUnavailable, setSelectionStorageUnavailable] =
useState(false);
function updateInvestmentSelection(next: number[]) {
setInvestmentSelection(next);
setSelectionStorageUnavailable(!persistOpportunitySelection(next));
}
function selectInvestment(id: number, checked: boolean) {
const next = checked
? [...new Set([...investmentSelection, id])]
: investmentSelection.filter((x) => x !== id);
setInvestmentSelection(next);
sessionStorage.setItem(
'investment-opportunity-selection',
JSON.stringify(next),
);
updateInvestmentSelection(next);
}
const form = useForm({
perspective: String(filters.perspective ?? ''),
@@ -427,6 +427,12 @@ export default function Catalogue({
total={results.total}
retry={() => runSearch()}
/>
<OpportunityRelatedResults
related={relatedSearch}
loading={searchLoading}
error={searchError}
total={results.total}
/>
{!searchLoading &&
!searchError &&
results.total === 0 &&
@@ -544,8 +550,8 @@ export default function Catalogue({
<div role={error ? 'alert' : 'status'} aria-live="polite">
{error ? (
<>
Não foi possível apresentar o mapa. A lista
continua disponível.{' '}
Não foi possível carregar as oportunidades no
mapa. A lista continua disponível.{' '}
<button
className="underline"
onClick={() =>
@@ -562,19 +568,20 @@ export default function Catalogue({
)}
</div>
)}
{!searchLoading &&
!searchError &&
['map', 'combined'].includes(view) &&
!error && <Map points={points} areas={areas} />}
{!searchLoading &&
!searchError &&
['map', 'combined'].includes(view) && (
<TerritoryGeometryPreview
<Map
points={error ? [] : points}
areas={areas}
territoryId={
form.data.locality_id ||
form.data.admin_post_id ||
form.data.district_id ||
form.data.province_id
String(
filters.locality_id ||
filters.admin_post_id ||
filters.district_id ||
filters.province_id ||
'',
) || undefined
}
/>
)}
@@ -659,10 +666,7 @@ export default function Catalogue({
selected={investmentSelection}
onSelect={selectInvestment}
onClear={() => {
setInvestmentSelection([]);
sessionStorage.removeItem(
'investment-opportunity-selection',
);
updateInvestmentSelection([]);
}}
onCompare={(ids) =>
void api(
@@ -785,10 +789,10 @@ export default function Catalogue({
aria-label="Paginação"
className={view === 'corridors' ? 'hidden' : 'flex gap-6'}
>
{results.prev_page_url && (
{!searchLoading && !searchError && results.prev_page_url && (
<Link href={results.prev_page_url}>Anterior</Link>
)}
{results.next_page_url && (
{!searchLoading && !searchError && results.next_page_url && (
<Link href={results.next_page_url}>Seguinte</Link>
)}
</nav>
@@ -807,11 +811,23 @@ export default function Catalogue({
Comparar {selected.length} oportunidades
</button>
)}
{selectionStorageUnavailable && (
<p
role="status"
className="my-3 rounded border border-amber-300 p-3 text-sm"
>
O navegador não permitiu guardar a escolha. A selecção
actual continua disponível nesta página; ao sair ou
actualizar, pode recuperar uma escolha anterior ou perdê-la.
</p>
)}
{view !== 'corridors' && !!investmentSelection.length && (
<section className={card}>
<p>
{investmentSelection.length} oportunidades escolhidas,
conservadas ao mudar de página.
{selectionStorageUnavailable
? ' disponíveis nesta página.'
: ' conservadas ao mudar de página.'}
</p>
<Link
className={button}
@@ -827,10 +843,7 @@ export default function Catalogue({
<button
className="ml-4 underline"
onClick={() => {
setInvestmentSelection([]);
sessionStorage.removeItem(
'investment-opportunity-selection',
);
updateInvestmentSelection([]);
}}
>
Limpar escolha
+25
View File
@@ -11,6 +11,7 @@ import type { EducationalArticle } from '@/components/educational-article-card';
import { ClassificationSummary } from '@/components/opportunity-classification';
import { Link, router, usePage } from '@inertiajs/react';
import { useState } from 'react';
import { downloadPublicOpportunityOffline } from '@/lib/public-opportunity-offline';
import InvestmentMapPanel from '@/components/investment-map-panel';
import StructureGeographyPanel, {
LocationList,
@@ -42,6 +43,7 @@ export default function Detail({
page.url.split('?')[1] ?? '',
).get('context');
const [sharing, setSharing] = useState('');
const [offlineMessage, setOfflineMessage] = useState('');
return (
<Frame title={r.title}>
{r.maturity_label === 'Em preparação' && (
@@ -114,6 +116,29 @@ export default function Detail({
{r.reference} · {r.sector?.name} · {r.province} {r.district}
</p>
<p className="text-xl">{r.summary}</p>
<div className="space-y-2">
<button
type="button"
className="underline"
onClick={() => {
try {
downloadPublicOpportunityOffline(r);
setOfflineMessage(
'Ficheiro preparado. Guarde-o e abra-o para consultar esta ficha sem rede.',
);
} catch {
setOfflineMessage(
'Não foi possível preparar o ficheiro. Tente novamente.',
);
}
}}
>
Guardar ficha para consulta offline (.html)
</button>
<p role="status" aria-live="polite">
{offlineMessage}
</p>
</div>
<InvestmentComplements items={complements} />
<ClassificationSummary rows={c.classification ?? []} />
<TerritorialSources sources={c.source_evidence} />
+168 -11
View File
@@ -1,16 +1,48 @@
import { Link, router } from '@inertiajs/react';
import { Frame, card, button } from './shared';
import OpportunityAlertPreferences, {
type AlertPreferences,
type AlertOptions,
} from '@/components/opportunity-alert-preferences';
export default function Notifications({
unread,
notifications,
alertPreferences = null,
alertOptions = null,
}: {
alertPreferences?: AlertPreferences | null;
alertOptions?: AlertOptions | null;
unread: number;
notifications: {
data: {
id: string;
submission_id: string;
submission_id: string | null;
opportunity_id?: number | null;
tender_version_id?: string | null;
funding_version_id?: string | null;
kind: string;
payload: { status?: string; reference?: string };
payload: {
status?: string;
reference?: string;
title?: string;
slug?: string;
source?: string;
source_url?: string;
source_reference?: string;
source_checked_on?: string;
preference_version?: number;
tender_id?: string;
programme_id?: string;
scope_explanation?: Record<string, string>;
window_states?: {
title: string;
state: string;
end_on?: string | null;
}[];
publication_version?: number;
act?: string;
published_at?: string | null;
};
read_at: string | null;
created_at: string;
}[];
@@ -24,38 +56,163 @@ export default function Notifications({
contacted: 'Contactado',
closed: 'Encerrado',
};
const fundingStates: Record<string, string> = {
open: 'aberta segundo as datas documentadas',
closed: 'encerrada',
upcoming: 'abertura futura',
unknown: 'por confirmar',
};
return (
<Frame title="Notificações e acompanhamento">
<Link href="/investidor/manifestacoes" className="underline">
Área do investidor
</Link>
<p role="status">{unread} notificações por ler</p>
{alertPreferences && alertOptions && (
<OpportunityAlertPreferences
key={alertPreferences.version}
preferences={alertPreferences}
options={alertOptions}
/>
)}
{notifications.data.map((n) => (
<article key={n.id} className={card + ' space-y-3'}>
<h2 className="text-xl font-bold">
{n.kind === 'received'
? 'Manifestação recebida'
: n.kind === 'status'
? 'Estado actualizado'
: 'Nova mensagem na conversa'}
{n.kind === 'funding_match'
? 'Nova publicação de fundo ou apoio'
: n.kind === 'tender_match'
? 'Novo acto de concurso compatível'
: n.kind === 'opportunity_match'
? 'Nova oportunidade compatível'
: n.kind === 'received'
? 'Manifestação recebida'
: n.kind === 'status'
? 'Estado actualizado'
: 'Nova mensagem na conversa'}
</h2>
<p>
{n.payload.reference ??
{n.payload.title ??
n.payload.reference ??
(n.payload.status
? (states[n.payload.status] ?? n.payload.status)
: 'Consulte o pedido para ler a mensagem.')}
</p>
{(n.kind === 'funding_match' ||
n.kind === 'opportunity_match' ||
n.kind === 'tender_match') && (
<p className="text-sm">
Fonte: {n.payload.source}.{' '}
{n.payload.published_at &&
!Number.isNaN(
new Date(n.payload.published_at).getTime(),
) ? (
<>
Publicação em{' '}
<time dateTime={n.payload.published_at}>
{new Date(
n.payload.published_at,
).toLocaleString('pt-MZ')}
</time>
.{' '}
</>
) : (
'Data de publicação não indicada. '
)}
Correspondência com a versão{' '}
{n.payload.preference_version} das suas
preferências; não representa avaliação de
rentabilidade ou elegibilidade.
</p>
)}
{n.kind === 'tender_match' && (
<p>
{alertOptions?.tenderActs?.[n.payload.act ?? ''] ??
n.payload.act ??
'Acto publicado'}{' '}
· versão {n.payload.publication_version}.
Referência: {n.payload.reference ?? 'Não indicada'}.
Consulte o concurso para verificar o estado e as
condições actuais. Este aviso não apresenta uma
proposta.
</p>
)}
{n.kind === 'funding_match' && (
<div>
{n.payload.source_url && (
<p>
<a
className="underline"
href={n.payload.source_url}
target="_blank"
rel="noopener noreferrer"
>
{n.payload.source_reference ??
'Consultar fonte documentada'}
</a>
{n.payload.source_checked_on
? ` — consultada em ${n.payload.source_checked_on}`
: ''}
</p>
)}
<p>
Versão {n.payload.publication_version}. Consulte
a ficha para conferir as condições actuais. Este
aviso não confirma uma candidatura aberta nem
concessão de financiamento.
</p>
{Object.entries(
n.payload.scope_explanation ?? {},
).map(([key, text]) => (
<p key={key}>{text}</p>
))}
<ul>
{(n.payload.window_states ?? []).map(
(window, index) => (
<li key={index}>
{window.title}:{' '}
{fundingStates[window.state] ??
window.state}
{window.end_on
? `; data-limite ${window.end_on}`
: ''}{' '}
(estado na data do aviso).
</li>
),
)}
</ul>
</div>
)}
<p className="text-sm">
Recebida em{' '}
{new Date(n.created_at).toLocaleString('pt-MZ')}
</p>
<div className="flex flex-wrap gap-4">
<Link
href={
'/investidor/manifestacoes/' + n.submission_id
n.kind === 'funding_match' &&
n.payload.programme_id
? '/fundos/' +
encodeURIComponent(n.payload.programme_id)
: n.kind === 'tender_match' &&
n.payload.tender_id
? '/concursos/' +
encodeURIComponent(n.payload.tender_id)
: n.kind === 'opportunity_match' &&
n.payload.slug
? '/oportunidades/' +
encodeURIComponent(n.payload.slug)
: '/investidor/manifestacoes/' +
n.submission_id
}
className="underline"
>
Abrir manifestação
{n.kind === 'funding_match'
? 'Consultar fundo ou apoio'
: n.kind === 'tender_match'
? 'Consultar concurso'
: n.kind === 'opportunity_match'
? 'Consultar oportunidade'
: 'Abrir manifestação'}
</Link>
{!n.read_at && (
<button
@@ -77,7 +234,7 @@ export default function Notifications({
</article>
))}
{!notifications.data.length && (
<p>Ainda não existem notificações.</p>
<p>Não existem notificações disponíveis nesta consulta.</p>
)}
<nav aria-label="Paginação" className="flex gap-4">
{notifications.prev_page_url && (
+4 -5
View File
@@ -97,7 +97,8 @@ export default function Profile({
, versão{' '}
{company.countrySource.organization_version}. O
valor é uma cópia identificada; não é atualizado
automaticamente quando o cadastro mestre muda.
automaticamente quando o registo da organização
muda.
</p>
)}
<Editor
@@ -173,9 +174,7 @@ export default function Profile({
/>
</section>
)}
<h2 className="text-2xl font-bold">
Organizações representadas — cadastro mestre
</h2>
<h2 className="text-2xl font-bold">Organizações representadas</h2>
<p>
O país de constituição é independente da residência e da origem
da solicitação. Não se associa uma empresa privada a uma
@@ -290,7 +289,7 @@ function OrganizationEditor({
className={button}
disabled={!organization.canEdit || form.processing}
>
Guardar país no cadastro mestre
Guardar país da organização
</button>
</form>
</section>
+22 -9
View File
@@ -174,12 +174,21 @@ export function money(r: Opportunity) {
: `${new Intl.NumberFormat('pt-MZ', { maximumFractionDigits: 2 }).format(Number(r.estimated_investment_amount))} ${r.estimated_investment_currency}`;
}
export async function api(url: string, body?: unknown) {
const token = decodeURIComponent(
document.cookie
.split('; ')
.find((c) => c.startsWith('XSRF-TOKEN='))
?.slice(11) ?? '',
);
const encodedToken =
body === undefined || typeof document === 'undefined'
? ''
: (document.cookie
.split('; ')
.find((c) => c.startsWith('XSRF-TOKEN='))
?.slice(11) ?? '');
let token = '';
try {
token = decodeURIComponent(encodedToken);
} catch {
throw new Error(
'A sessão não pôde ser validada. Actualize a página e tente novamente.',
);
}
const formData =
typeof FormData !== 'undefined' && body instanceof FormData;
const response = await fetch(url, {
@@ -194,10 +203,14 @@ export async function api(url: string, body?: unknown) {
? {}
: { body: formData ? body : JSON.stringify(body) }),
});
const data = await response.json();
if (!response.ok)
const data = await response.json().catch(() => null);
if (!response.ok || (data === null && response.status !== 204))
throw new Error(
data.message ?? 'Não foi possível concluir a operação.',
typeof data?.message === 'string'
? data.message
: response.status === 419
? 'A sessão expirou. Actualize a página e tente novamente.'
: 'Não foi possível concluir a operação. Tente novamente.',
);
return data;
}
+6 -5
View File
@@ -606,7 +606,7 @@ function Editor({
incorporation_country_code:
'País de constituição da entidade',
declared_origin_country_code:
'País de origem declarado desta solicitação',
'País de origem do pedido (opcional)',
}[key]
}
>
@@ -620,7 +620,7 @@ function Editor({
incorporation_country_code:
'País de constituição da entidade',
declared_origin_country_code:
'País de origem declarado desta solicitação',
'País de origem do pedido (opcional)',
}[key]
}
error={
@@ -664,9 +664,10 @@ function Editor({
</p>
)}
<p>
A origem da solicitação é uma declaração
sua; não é deduzida da residência, da
entidade ou do endereço IP.
Indique o país de onde apresenta este
pedido, se desejar. Pode ser diferente do
país de residência ou de constituição da
entidade.
</p>
{option(
'profile_id',
+2
View File
@@ -454,6 +454,7 @@ export default function Zones({
href={catalogueDetailHref(
`${management ? '/management/investment/zones' : '/zonas'}/${zone.id}`,
exportParams.toString(),
pageUrl,
)}
>
{zone.name}
@@ -464,6 +465,7 @@ export default function Zones({
href={catalogueDetailHref(
`${management ? '/management/investment/zones' : '/zonas'}/${zone.id}`,
exportParams.toString(),
pageUrl,
)}
>
Consultar ficha