Reconciliar fontes instaladas 423bd512d8c5 com main
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useInterestDraft } from '@/hooks/use-interest-draft';
|
||||
import { useRef, useState } from 'react';
|
||||
import { Link } from '@inertiajs/react';
|
||||
import type { FormEvent } from 'react';
|
||||
@@ -38,7 +39,7 @@ export default function BusinessInterest({
|
||||
returnUrl = '/negocios',
|
||||
countries,
|
||||
}: Props) {
|
||||
const [form, setForm] = useState<Form>({
|
||||
const draft = useInterestDraft<Form>('business:' + record.id, {
|
||||
declared_origin_country_code: '',
|
||||
fullName: '',
|
||||
email: '',
|
||||
@@ -52,11 +53,12 @@ export default function BusinessInterest({
|
||||
privacyConsent: false,
|
||||
shareWithProponent: false,
|
||||
});
|
||||
const {form, setForm} = draft;
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [fieldErrors, setFieldErrors] = useState<Partial<Record<keyof Form, string>>>({});
|
||||
const [receipt, setReceipt] = useState('');
|
||||
const key = useRef(newSubmissionKey());
|
||||
const key = useRef(draft.key);
|
||||
const update = <K extends keyof Form>(field: K, value: Form[K]) => {
|
||||
setForm((current) => ({ ...current, [field]: value }));
|
||||
setFieldErrors((current) => ({ ...current, [field]: undefined }));
|
||||
@@ -102,6 +104,7 @@ export default function BusinessInterest({
|
||||
existingBusinessId: record.id,
|
||||
}),
|
||||
});
|
||||
if (response.status === 401) { draft.authenticate(); return; }
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
const errors: Partial<Record<keyof Form, string>> = {};
|
||||
@@ -117,6 +120,7 @@ export default function BusinessInterest({
|
||||
return;
|
||||
}
|
||||
setFieldErrors({});
|
||||
draft.clear();
|
||||
setReceipt(data.data.reference);
|
||||
key.current = newSubmissionKey();
|
||||
} catch (cause) {
|
||||
@@ -140,7 +144,7 @@ export default function BusinessInterest({
|
||||
{receipt ? (
|
||||
<section className={card} role="status">
|
||||
<h2 className="text-xl font-bold">Pedido recebido</h2>
|
||||
<p>Referência: {receipt}</p>
|
||||
<p>Referência: {receipt}</p><Link href="/investidor/manifestacoes" className="underline">Acompanhar manifestações</Link>
|
||||
<p>
|
||||
A equipa fará a triagem antes de qualquer partilha com o
|
||||
proponente.
|
||||
|
||||
@@ -32,6 +32,7 @@ type Props = {
|
||||
record: Business;
|
||||
modalities: string[];
|
||||
formSchema: FormSchema;
|
||||
modalityFormType?: string | null;
|
||||
objects: BusinessObject[];
|
||||
objectKinds: string[];
|
||||
sectors: { id: number; name: string }[];
|
||||
@@ -176,42 +177,11 @@ function TerritoryField({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
function opportunityTypeFor(modality: string): string {
|
||||
if (
|
||||
[
|
||||
'investment_project',
|
||||
'company_sale',
|
||||
'asset_sale',
|
||||
'business_partnership',
|
||||
'financing_request',
|
||||
'concession_opportunity',
|
||||
'supply_opportunity',
|
||||
].includes(modality)
|
||||
)
|
||||
return modality;
|
||||
if (['participation_sale'].includes(modality)) return 'company_sale';
|
||||
if (['asset_lease'].includes(modality)) return 'asset_sale';
|
||||
if (['capital_increase', 'financial_investor'].includes(modality))
|
||||
return 'financing_request';
|
||||
if (['strategic_partner', 'joint_venture'].includes(modality))
|
||||
return 'business_partnership';
|
||||
if (
|
||||
[
|
||||
'expansion',
|
||||
'agricultural_investment',
|
||||
'internationalization',
|
||||
].includes(modality)
|
||||
)
|
||||
return 'investment_project';
|
||||
if (['buyer_search', 'position_assignment'].includes(modality))
|
||||
return 'company_sale';
|
||||
return 'investment_project';
|
||||
}
|
||||
|
||||
export default function BusinessWizard({
|
||||
countries,
|
||||
record,
|
||||
formSchema,
|
||||
modalityFormType,
|
||||
objects,
|
||||
objectKinds,
|
||||
sectors,
|
||||
@@ -223,7 +193,7 @@ export default function BusinessWizard({
|
||||
...record.payload,
|
||||
opportunity_type:
|
||||
record.payload.opportunity_type ??
|
||||
opportunityTypeFor(record.modality),
|
||||
modalityFormType ?? '',
|
||||
wizard_version: '2',
|
||||
};
|
||||
if (
|
||||
@@ -236,9 +206,7 @@ export default function BusinessWizard({
|
||||
}
|
||||
return initial;
|
||||
});
|
||||
const [modality, setModality] = useState(
|
||||
record.payload.opportunity_type ?? opportunityTypeFor(record.modality),
|
||||
);
|
||||
const modality = record.modality;
|
||||
const [sectorId, setSectorId] = useState(record.sector_id ?? null);
|
||||
const [sectorSearch, setSectorSearch] = useState('');
|
||||
const [publicTitle, setPublicTitle] = useState(record.public_title ?? '');
|
||||
@@ -397,7 +365,6 @@ export default function BusinessWizard({
|
||||
);
|
||||
const update = (key: string, value: string) => {
|
||||
setError('');
|
||||
if (key === 'opportunity_type') setModality(value);
|
||||
setPayload((current) => {
|
||||
const next = { ...current, [key]: value };
|
||||
if (key === 'geography_scope' && value === 'multiple') {
|
||||
@@ -533,6 +500,8 @@ export default function BusinessWizard({
|
||||
)}
|
||||
>
|
||||
<div lang={english ? 'en' : 'pt'} className="space-y-5">
|
||||
<p>{t('Modalidade registada', 'Registered modality')}: {businessModalities[record.modality] ?? record.modality}</p>
|
||||
{!modalityFormType && <p role="status">{t('Pode guardar e recuperar esta preparação. O formulário específico de submissão desta modalidade ainda não está disponível; os dados e a modalidade original serão preservados.', 'You can save and recover this draft. Its specific submission form is not available yet; the original modality and data are preserved.')}</p>}
|
||||
<a className="underline" href={`/investidor/negocios/${record.id}/classificacao`}>{t('Classificação multidimensional deste anúncio', 'Multidimensional classification of this listing')}</a>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { Country } from '@/components/country-select';
|
||||
type Props = {
|
||||
countries: Country[];
|
||||
formSchema: FormSchema;
|
||||
modalityFormType?: string | null;
|
||||
sectors: { id: number; name: string }[];
|
||||
record: Business;
|
||||
canEdit: boolean;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { usePortalQuery } from '@/hooks/use-portal-query';
|
||||
import SearchState from '@/components/search-state';
|
||||
import CatalogueNavigation from '@/components/catalogue-navigation';
|
||||
import { ClassificationFilters } from '@/components/opportunity-classification';
|
||||
import { Link, router, useForm, usePage } from '@inertiajs/react';
|
||||
@@ -114,9 +116,7 @@ export default function Catalogue({
|
||||
{ id: string; title: string; kind: string; url: string }[]
|
||||
>([]);
|
||||
const [error, setError] = useState('');
|
||||
const [suggestions, setSuggestions] = useState<
|
||||
{ title: string; slug: string }[]
|
||||
>([]);
|
||||
const [mapAttempt, setMapAttempt] = useState(0);
|
||||
const filterKey = JSON.stringify(filters);
|
||||
const draftFilterKey = JSON.stringify(form.data);
|
||||
const lastRequest = useRef(draftFilterKey);
|
||||
@@ -189,29 +189,9 @@ export default function Catalogue({
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [view, filterKey]);
|
||||
useEffect(() => {
|
||||
if (form.data.q.length < 2) {
|
||||
setSuggestions([]);
|
||||
return;
|
||||
}
|
||||
let active = true;
|
||||
const timer = setTimeout(() => {
|
||||
api(
|
||||
`/api/v1/investment/suggest?q=${encodeURIComponent(form.data.q)}`,
|
||||
)
|
||||
.then((data) => {
|
||||
if (active) setSuggestions(data.opportunities);
|
||||
})
|
||||
.catch(() => {
|
||||
if (active) setSuggestions([]);
|
||||
});
|
||||
}, 300);
|
||||
return () => {
|
||||
active = false;
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}, [form.data.q]);
|
||||
}, [view, filterKey, mapAttempt]);
|
||||
const suggestionQuery = usePortalQuery<{opportunities:{title:string;slug:string}[]}>(`/api/v1/investment/suggest?q=${encodeURIComponent(form.data.q)}`, 300);
|
||||
const currentSuggestions = form.data.q.length >= 2 ? suggestionQuery.data?.opportunities ?? [] : [];
|
||||
const query = () => {
|
||||
const params = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(filters)) {
|
||||
@@ -369,13 +349,14 @@ export default function Catalogue({
|
||||
aria-describedby="search-suggestions"
|
||||
/>
|
||||
</Field>
|
||||
{suggestions.length > 0 && (
|
||||
{form.data.q.length >= 2 && <SearchState loading={suggestionQuery.loading} error={suggestionQuery.error} total={currentSuggestions.length} retry={suggestionQuery.retry} />}
|
||||
{currentSuggestions.length > 0 && (
|
||||
<ul
|
||||
id="search-suggestions"
|
||||
aria-label="Sugestões de pesquisa"
|
||||
className="space-y-2"
|
||||
>
|
||||
{suggestions.map((s) => (
|
||||
{currentSuggestions.map((s) => (
|
||||
<li key={s.slug}>
|
||||
<Link
|
||||
href={`/oportunidades/${s.slug}`}
|
||||
@@ -1130,7 +1111,7 @@ export default function Catalogue({
|
||||
Favoritos e pedidos
|
||||
</Link>
|
||||
</div>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<SearchState loading={points === null && !error} error={error} total={(points?.length ?? 0) + unlocated.length} retry={() => setMapAttempt(value => value + 1)} />
|
||||
{!error && <Map points={points} areas={areas} />}
|
||||
{['map', 'combined'].includes(view) && (
|
||||
<TerritoryGeometryPreview
|
||||
|
||||
@@ -28,8 +28,10 @@ export default function EditContext({
|
||||
return (
|
||||
<Management title={'Contexto: ' + record.title}>
|
||||
<p>
|
||||
As relações e características são parte da ficha publicada.
|
||||
Guardar devolve-a a rascunho para revisão.
|
||||
Associações territoriais e produtivas ligam esta oportunidade a
|
||||
corredores, clusters e projectos; não substituem o registo de
|
||||
onde se localiza. As relações e características são parte da
|
||||
ficha publicada. Guardar devolve-a a rascunho para revisão.
|
||||
</p>
|
||||
<Link
|
||||
href={`/management/opportunities/${record.id}/edit`}
|
||||
@@ -37,6 +39,18 @@ export default function EditContext({
|
||||
>
|
||||
Editar e publicar a ficha principal
|
||||
</Link>
|
||||
<p>
|
||||
As localizações documentadas são preparadas nos recursos da
|
||||
ficha, reutilizando a hierarquia existente. As referências
|
||||
anteriores abaixo são preservadas; não constituem confirmação de
|
||||
implantação ou de regime especial.
|
||||
</p>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/management/opportunities/${record.id}/resources`}
|
||||
>
|
||||
Onde se localiza — consultar ou documentar locais
|
||||
</Link>
|
||||
<form
|
||||
className="space-y-6"
|
||||
onSubmit={(e) => {
|
||||
@@ -78,7 +92,7 @@ export default function EditContext({
|
||||
'Clusters',
|
||||
'Corredores',
|
||||
'Projectos âncora',
|
||||
'Localizações',
|
||||
'Referências territoriais anteriores',
|
||||
][i]
|
||||
}
|
||||
</legend>
|
||||
|
||||
@@ -22,7 +22,8 @@ export default function Detail({
|
||||
returnUrl?: string;
|
||||
dossierOrigin?: { id: string; title: string } | null;
|
||||
}) {
|
||||
const { auth } = usePage<{ auth: { user: unknown } }>().props;
|
||||
const page = usePage<{ auth: { user: unknown } }>();
|
||||
const { auth } = page.props;
|
||||
const [sharing, setSharing] = useState('');
|
||||
return (
|
||||
<Frame title={r.title}>
|
||||
@@ -61,9 +62,7 @@ export default function Detail({
|
||||
<ClassificationSummary rows={c.classification ?? []} />
|
||||
<TerritorialSources sources={c.source_evidence} />
|
||||
<section className={card + ' space-y-3'}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Implantação declarada da oportunidade
|
||||
</h2>
|
||||
<h2 className="text-xl font-bold">Onde se localiza</h2>
|
||||
<p>
|
||||
As relações cadastradas não confirmam disponibilidade ou
|
||||
capacidade. Locais dos projetos associados, áreas de impacto
|
||||
@@ -111,7 +110,7 @@ export default function Detail({
|
||||
Preparar manifestação de interesse
|
||||
</button>
|
||||
) : (
|
||||
<Link className={button} href="/login">
|
||||
<Link className={button} href={`/participar/entrar?return=${encodeURIComponent(page.url)}`}>
|
||||
Entrar para preparar manifestação
|
||||
</Link>
|
||||
)}
|
||||
@@ -237,7 +236,7 @@ export default function Detail({
|
||||
'Clusters',
|
||||
'Corredores',
|
||||
'Projectos âncora',
|
||||
'Territórios',
|
||||
'Referências territoriais anteriores',
|
||||
][i]
|
||||
}
|
||||
</h2>
|
||||
|
||||
@@ -9,6 +9,9 @@ import { Conversation } from './conversation';
|
||||
import type { Message } from './conversation';
|
||||
import CountrySelect, { type Country } from '@/components/country-select';
|
||||
type Payload = {
|
||||
simple_participation?: boolean;
|
||||
opportunity_title?: string;
|
||||
opportunity_reference?: string;
|
||||
full_name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
@@ -82,7 +85,7 @@ type Props = {
|
||||
needs: Need[];
|
||||
attachments: { id: string; file_name: string }[];
|
||||
events: { action: string; version: number; created_at: string }[];
|
||||
receipt: { reference: string; status: string } | null;
|
||||
receipt: { reference: string; status: string; next_action?: string | null; next_action_due_at?: string | null } | null;
|
||||
target: string | null;
|
||||
management: boolean;
|
||||
messages: Message[];
|
||||
@@ -338,6 +341,16 @@ function Editor({
|
||||
)[receipt.status] ?? receipt.status}
|
||||
</p>
|
||||
)}
|
||||
{receipt?.next_action && <p role="status">Próxima acção: {receipt.next_action} {receipt.next_action_due_at && new Date(receipt.next_action_due_at).toLocaleDateString("pt-MZ")}</p>}
|
||||
{s.status === 'submitted' && s.payload.simple_participation ? <section className={card}>
|
||||
<h2 className="text-xl font-bold">Dados da manifestação</h2>
|
||||
<dl className="mt-3 space-y-3">{[
|
||||
['Nome', s.payload.full_name], ['Email', s.payload.email],
|
||||
['Telefone', s.payload.phone], ['País declarado', s.payload.country],
|
||||
['Sector', s.payload.sector], ['Oportunidade', target],
|
||||
['Mensagem', s.payload.objective],
|
||||
].filter(([,value]) => value).map(([label,value]) => <div key={label}><dt className="font-semibold">{label}</dt><dd className="whitespace-pre-wrap">{value}</dd></div>)}</dl>
|
||||
</section> : <>
|
||||
<nav
|
||||
aria-label="Etapas da manifestação"
|
||||
className="flex flex-wrap gap-2"
|
||||
@@ -1117,6 +1130,7 @@ function Editor({
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
</>}
|
||||
<details className={card}>
|
||||
<summary className="cursor-pointer font-bold">
|
||||
Histórico do pedido
|
||||
@@ -1130,7 +1144,7 @@ function Editor({
|
||||
draft_created: 'Rascunho criado',
|
||||
draft_saved: 'Rascunho guardado',
|
||||
attachment_added: 'Anexo acrescentado',
|
||||
submitted: 'Submetido',
|
||||
submitted: 'Submetido', received: 'Recebido', in_review: 'Em análise', contacted: 'Contactado', closed: 'Encerrado',
|
||||
} as Record<string, string>
|
||||
)[e.action] ?? e.action}{' '}
|
||||
· versão {e.version}
|
||||
|
||||
@@ -123,7 +123,15 @@ export default function Zones({
|
||||
Parques industriais
|
||||
</Link>
|
||||
</nav>
|
||||
<form method="get" className={card + ' grid gap-4 md:grid-cols-3'}>
|
||||
<form method="get" onSubmit={event => {
|
||||
event.preventDefault();
|
||||
const form = event.currentTarget;
|
||||
const url = new URL(form.action);
|
||||
const params = new URLSearchParams();
|
||||
for (const [name, value] of new FormData(form)) if (typeof value === 'string') params.append(name, value);
|
||||
url.search = params.toString();
|
||||
router.get(url.toString(), {}, {preserveState: true, preserveScroll: true});
|
||||
}} className={card + ' grid gap-4 md:grid-cols-3'}>
|
||||
<Field label="Pesquisar por nome ou código">
|
||||
<input
|
||||
className={input}
|
||||
|
||||
Reference in New Issue
Block a user