Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -29,14 +29,30 @@ import OpportunityChoices from '@/components/investment-opportunity-choices';
|
||||
import InvestmentRequirements from '@/components/investment-requirements';
|
||||
import type { OpportunityChoice } from '@/lib/investor-context';
|
||||
import type { CorridorOption } from '@/components/investment-opportunity-choices';
|
||||
import CountrySelect, { type Country } from '@/components/country-select';
|
||||
import CurrencySelect from '@/components/currency-select';
|
||||
import InvestmentBudgetRange from '@/components/investment-budget-range';
|
||||
import DemographicContext from '@/components/demographic-context';
|
||||
import { preparationSearch } from '@/lib/preparation-intent';
|
||||
type Options = {
|
||||
opportunities: { key: string; title: string; kind: string }[];
|
||||
opportunities: {
|
||||
key: string;
|
||||
title: string;
|
||||
kind: string;
|
||||
relevance?: string;
|
||||
}[];
|
||||
countries?: Country[];
|
||||
sectors: { id: number; name: string }[];
|
||||
parks: { id: string; name: string; version_no: number }[];
|
||||
search_limited: boolean;
|
||||
};
|
||||
type Slot = 'portfolio' | 'opportunity' | 'sector' | 'territory' | 'park';
|
||||
export default function ContextEditor({
|
||||
export default function ContextEditor(
|
||||
props: Parameters<typeof ScopedContextEditor>[0],
|
||||
) {
|
||||
return <ScopedContextEditor key={props.initial.case.id} {...props} />;
|
||||
}
|
||||
function ScopedContextEditor({
|
||||
initial,
|
||||
options: initialOptions,
|
||||
source,
|
||||
@@ -47,6 +63,7 @@ export default function ContextEditor({
|
||||
entryLocationDifferences = [],
|
||||
entryComplements = [],
|
||||
entryTerritory = null,
|
||||
entryIdea = {},
|
||||
}: {
|
||||
initial: ContextView;
|
||||
options: Options;
|
||||
@@ -56,6 +73,7 @@ export default function ContextEditor({
|
||||
entrySources?: string[];
|
||||
entryComplements?: Complement[];
|
||||
entryTerritory?: ContextReference | null;
|
||||
entryIdea?: Record<string, string>;
|
||||
entryLocationDifferences?: {
|
||||
title: string;
|
||||
saved: string;
|
||||
@@ -78,7 +96,21 @@ export default function ContextEditor({
|
||||
>([]);
|
||||
const [complementError, setComplementError] = useState('');
|
||||
const [choices, setChoices] = useState<OpportunityChoice[]>(
|
||||
requestedChoices ?? initial.context.opportunity_choices ?? [],
|
||||
requestedChoices ??
|
||||
(initial.context.opportunity_choices?.length
|
||||
? initial.context.opportunity_choices
|
||||
: initial.context.selection.opportunity?.kind === 'opportunity'
|
||||
? [
|
||||
{
|
||||
opportunity: initial.context.selection.opportunity,
|
||||
territory:
|
||||
initial.context.selection.territory ?? null,
|
||||
territory_path: territorySelection,
|
||||
location_reason: '',
|
||||
location_state: 'undetermined',
|
||||
},
|
||||
]
|
||||
: []),
|
||||
);
|
||||
const [manageChoices, setManageChoices] = useState(
|
||||
requestedChoices !== null ||
|
||||
@@ -149,8 +181,17 @@ export default function ContextEditor({
|
||||
const [preparation, setPreparation] = useState(initial.private_investment);
|
||||
const [options, setOptions] = useState(initialOptions);
|
||||
const [query, setQuery] = useState('');
|
||||
const [relatedOpen, setRelatedOpen] = useState(false);
|
||||
const [relatedSearch, setRelatedSearch] = useState<string | null>(null);
|
||||
const [consultationPath, setConsultationPath] =
|
||||
useState(territorySelection);
|
||||
const [changes, setChanges] = useState<Partial<Record<Slot, string>>>(
|
||||
() => ({
|
||||
...(entryIdea.sector_id &&
|
||||
!initial.context.selection.sector &&
|
||||
!draft?.selection?.sector
|
||||
? { sector: 'sector:' + entryIdea.sector_id }
|
||||
: {}),
|
||||
...draft?.selection,
|
||||
...(entryTerritory &&
|
||||
!draft?.selection?.territory &&
|
||||
@@ -159,7 +200,7 @@ export default function ContextEditor({
|
||||
: {}),
|
||||
...(source?.kind === 'portfolio'
|
||||
? { portfolio: source.key }
|
||||
: draft?.selection
|
||||
: draft?.selection || source?.kind === 'territory'
|
||||
? {}
|
||||
: source
|
||||
? {
|
||||
@@ -171,7 +212,20 @@ export default function ContextEditor({
|
||||
}),
|
||||
);
|
||||
const [declarations, setDeclarations] = useState<Record<string, string>>(
|
||||
draft?.declarations ?? {},
|
||||
() => ({
|
||||
...Object.fromEntries(
|
||||
Object.entries(entryIdea).filter(
|
||||
([key]) =>
|
||||
[
|
||||
'project_title',
|
||||
'investment_budget_min',
|
||||
'investment_budget_max',
|
||||
'currency',
|
||||
].includes(key) && !initial.context.fields[key],
|
||||
),
|
||||
),
|
||||
...draft?.declarations,
|
||||
}),
|
||||
);
|
||||
const [documentLinks, setDocumentLinks] = useState<
|
||||
Record<string, string | null>
|
||||
@@ -188,21 +242,32 @@ export default function ContextEditor({
|
||||
const [message, setMessage] = useState('');
|
||||
const [corridors, setCorridors] = useState<CorridorOption[]>([]);
|
||||
const [parks, setParks] = useState<Options['parks']>([]);
|
||||
const [corridorLoading, setCorridorLoading] = useState(true);
|
||||
const [corridorLoading, setCorridorLoading] = useState(
|
||||
choices.length > 0 || consultationPath.length > 0,
|
||||
);
|
||||
const [corridorError, setCorridorError] = useState('');
|
||||
const [corridorRetry, setCorridorRetry] = useState(0);
|
||||
const [draftStatus, setDraftStatus] = useState('');
|
||||
const [draftRetry, setDraftRetry] = useState(0);
|
||||
const queue = useRef<Promise<unknown>>(Promise.resolve());
|
||||
const firstCorridor =
|
||||
choices[0]?.corridor_key ??
|
||||
corridors.find((c) => c.name === choices[0]?.coverage)?.key;
|
||||
const firstTerritory = choices[0]?.territory?.id;
|
||||
choices[0]?.corridor_key !== undefined
|
||||
? choices[0].corridor_key
|
||||
: corridors.find((c) => c.name === choices[0]?.coverage)?.key;
|
||||
const firstTerritory =
|
||||
choices[0]?.territory?.id ?? consultationPath.at(-1)?.id;
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
if (!choices.length && !firstTerritory) {
|
||||
setCorridorLoading(false);
|
||||
setCorridorError('');
|
||||
setParks([]);
|
||||
return;
|
||||
}
|
||||
setCorridorLoading(true);
|
||||
setCorridorError('');
|
||||
const params = new URLSearchParams();
|
||||
if (!choices.length) params.set('include_corridors', '0');
|
||||
if (firstCorridor) params.set('corridor', firstCorridor);
|
||||
if (firstTerritory) params.set('territory', firstTerritory);
|
||||
void contextApi<{
|
||||
@@ -222,10 +287,9 @@ export default function ContextEditor({
|
||||
park &&
|
||||
!data.parks.some((p) => 'park:' + p.id === park)
|
||||
) {
|
||||
setChanges((old) => ({ ...old, park: '' }));
|
||||
setPlan(null);
|
||||
// Keep the previous association until the investor reviews it.
|
||||
setMessage(
|
||||
'A zona ou parque anterior foi retirado porque não tem enquadramento compatível com a localização escolhida.',
|
||||
'Reveja a zona ou parque anterior: a compatibilidade com esta escolha ainda nao foi confirmada.',
|
||||
);
|
||||
}
|
||||
})
|
||||
@@ -238,7 +302,7 @@ export default function ContextEditor({
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [firstCorridor, firstTerritory, corridorRetry]);
|
||||
}, [firstCorridor, firstTerritory, corridorRetry, choices.length]);
|
||||
const draftBody = JSON.stringify({
|
||||
complements: complements.map(complementInput),
|
||||
entry_sources: entrySources,
|
||||
@@ -512,8 +576,8 @@ export default function ContextEditor({
|
||||
</Link>
|
||||
<p>{view.case.title}</p>
|
||||
<p>
|
||||
Confirme as oportunidades e a localização, complete os dados
|
||||
disponíveis e reveja antes de guardar.
|
||||
Confirme a sua ideia, o sector e a localização. Complete
|
||||
apenas o que falta; associar anúncios é opcional.
|
||||
</p>
|
||||
<SelectedComplements
|
||||
items={complements}
|
||||
@@ -616,7 +680,9 @@ export default function ContextEditor({
|
||||
</p>
|
||||
)}
|
||||
{corridorLoading && (
|
||||
<p role="status">A carregar opções do corredor…</p>
|
||||
<p role="status">
|
||||
A consultar associações documentadas…
|
||||
</p>
|
||||
)}
|
||||
<p role="status">{draftStatus}</p>
|
||||
{draft?.needs_review && (
|
||||
@@ -635,16 +701,20 @@ export default function ContextEditor({
|
||||
Tentar guardar novamente
|
||||
</button>
|
||||
)}
|
||||
<OpportunityChoices
|
||||
corridors={corridors}
|
||||
choices={choices}
|
||||
disabled={busy || corridorLoading || !!corridorError}
|
||||
onChange={(next) => {
|
||||
setChoices(next);
|
||||
setManageChoices(true);
|
||||
setPlan(null);
|
||||
}}
|
||||
/>
|
||||
{!!choices.length && (
|
||||
<OpportunityChoices
|
||||
corridors={corridors}
|
||||
choices={choices}
|
||||
disabled={
|
||||
busy || corridorLoading || !!corridorError
|
||||
}
|
||||
onChange={(next) => {
|
||||
setChoices(next);
|
||||
setManageChoices(true);
|
||||
setPlan(null);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{(changes.portfolio ||
|
||||
view.context.selection.portfolio) && (
|
||||
<p className="rounded border p-3">
|
||||
@@ -694,145 +764,165 @@ export default function ContextEditor({
|
||||
contextId={view.case.id}
|
||||
/>
|
||||
)}
|
||||
<label className="block">
|
||||
Acrescentar uma oportunidade à escolha
|
||||
<select
|
||||
className={input}
|
||||
value=""
|
||||
disabled={busy}
|
||||
onChange={(e) => {
|
||||
const o = options.opportunities.find(
|
||||
(o) => o.key === e.target.value,
|
||||
);
|
||||
if (
|
||||
o &&
|
||||
!choices.some(
|
||||
(c) => c.opportunity.key === o.key,
|
||||
<details
|
||||
open={relatedOpen}
|
||||
onToggle={(e) => setRelatedOpen(e.currentTarget.open)}
|
||||
className="rounded border p-3"
|
||||
>
|
||||
<summary className="cursor-pointer font-semibold">
|
||||
Oportunidades relacionadas (opcional)
|
||||
</summary>
|
||||
<p>
|
||||
Pode preparar a sua ideia sem associar um anuncio ou
|
||||
corredor. Pesquise apenas se uma oportunidade puder
|
||||
apoiar este investimento.
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<label className="min-w-0 flex-1">
|
||||
Pesquisar oportunidades
|
||||
<input
|
||||
className={input}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={busy}
|
||||
onClick={() => {
|
||||
setBusy(true);
|
||||
void contextApi<Options>(
|
||||
'/investimentos/fontes-contexto?' +
|
||||
preparationSearch(
|
||||
query,
|
||||
selected('sector'),
|
||||
consultationPath,
|
||||
),
|
||||
)
|
||||
) {
|
||||
setChoices([
|
||||
...choices,
|
||||
{
|
||||
opportunity: {
|
||||
...o,
|
||||
id: o.key.split(':')[1],
|
||||
href: '/oportunidades',
|
||||
version: null,
|
||||
sha256: '',
|
||||
fields: {},
|
||||
},
|
||||
territory: null,
|
||||
location_reason: '',
|
||||
location_state: 'undetermined',
|
||||
},
|
||||
]);
|
||||
setManageChoices(true);
|
||||
setPlan(null);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<option value="">Seleccionar ficha</option>
|
||||
{options.opportunities
|
||||
.filter(
|
||||
(o) =>
|
||||
o.kind === 'opportunity' &&
|
||||
.then((data) => {
|
||||
setOptions(data);
|
||||
setRelatedSearch(
|
||||
preparationSearch(
|
||||
query,
|
||||
selected('sector'),
|
||||
consultationPath,
|
||||
),
|
||||
);
|
||||
})
|
||||
.catch((e) => setError(e.message))
|
||||
.finally(() => setBusy(false));
|
||||
}}
|
||||
>
|
||||
Pesquisar
|
||||
</button>
|
||||
</div>
|
||||
<label className="block">
|
||||
Acrescentar uma oportunidade à escolha
|
||||
<select
|
||||
className={input}
|
||||
value=""
|
||||
disabled={busy}
|
||||
onChange={(e) => {
|
||||
const o = options.opportunities.find(
|
||||
(o) => o.key === e.target.value,
|
||||
);
|
||||
if (o?.kind === 'business') {
|
||||
change('opportunity', o.key);
|
||||
setManageChoices(false);
|
||||
setPlan(null);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
o &&
|
||||
!selected('opportunity').startsWith(
|
||||
'business:',
|
||||
) &&
|
||||
!choices.some(
|
||||
(c) => c.opportunity.key === o.key,
|
||||
),
|
||||
)
|
||||
) {
|
||||
setChoices([
|
||||
...choices,
|
||||
{
|
||||
opportunity: {
|
||||
...o,
|
||||
id: o.key.split(':')[1],
|
||||
href: '/oportunidades',
|
||||
version: null,
|
||||
sha256: '',
|
||||
fields: {},
|
||||
},
|
||||
territory: null,
|
||||
location_reason: '',
|
||||
location_state: 'undetermined',
|
||||
},
|
||||
]);
|
||||
setManageChoices(true);
|
||||
setPlan(null);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<option value="">Seleccionar ficha</option>
|
||||
{(relatedSearch ===
|
||||
preparationSearch(
|
||||
query,
|
||||
selected('sector'),
|
||||
consultationPath,
|
||||
)
|
||||
.map((o) => (
|
||||
<option key={o.key} value={o.key}>
|
||||
{o.title}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<h2 className="text-xl font-bold">Dados do investimento</h2>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<label className="min-w-0 flex-1">
|
||||
Pesquisar oportunidades
|
||||
<input
|
||||
className={input}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
/>
|
||||
? options.opportunities
|
||||
: []
|
||||
)
|
||||
.filter(
|
||||
(o) =>
|
||||
!choices.some(
|
||||
(c) =>
|
||||
c.opportunity.key === o.key,
|
||||
),
|
||||
)
|
||||
.map((o) => (
|
||||
<option
|
||||
key={o.key}
|
||||
value={o.key}
|
||||
disabled={
|
||||
o.kind === 'business'
|
||||
? choices.length > 0
|
||||
: selected(
|
||||
'opportunity',
|
||||
).startsWith('business:')
|
||||
}
|
||||
>
|
||||
{o.title} —{' '}
|
||||
{o.relevance ??
|
||||
'Correspondência pelo título; confirme o sector e a localização.'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={busy}
|
||||
onClick={() => {
|
||||
setBusy(true);
|
||||
void contextApi<Options>(
|
||||
'/investimentos/fontes-contexto?q=' +
|
||||
encodeURIComponent(query),
|
||||
)
|
||||
.then(setOptions)
|
||||
.catch((e) => setError(e.message))
|
||||
.finally(() => setBusy(false));
|
||||
}}
|
||||
>
|
||||
Pesquisar
|
||||
</button>
|
||||
</div>
|
||||
<label className="grid min-w-0 gap-1">
|
||||
Referência individual (sem selecção múltipla)
|
||||
<select
|
||||
className={input + ' max-w-full min-w-0'}
|
||||
value={selected('opportunity')}
|
||||
disabled={busy || manageChoices}
|
||||
onChange={(e) =>
|
||||
change('opportunity', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Sem oportunidade associada</option>
|
||||
{source &&
|
||||
['opportunity', 'business'].includes(
|
||||
source.kind,
|
||||
) &&
|
||||
!options.opportunities.some(
|
||||
(x) => x.key === source.key,
|
||||
) && (
|
||||
<option value={source.key}>
|
||||
{source.title}
|
||||
</option>
|
||||
)}
|
||||
{view.context.selection.opportunity &&
|
||||
!options.opportunities.some(
|
||||
(x) =>
|
||||
x.key ===
|
||||
view.context.selection.opportunity!.key,
|
||||
) && (
|
||||
<option
|
||||
value={
|
||||
view.context.selection.opportunity
|
||||
.key
|
||||
}
|
||||
>
|
||||
{
|
||||
view.context.selection.opportunity
|
||||
.title
|
||||
}{' '}
|
||||
— referência guardada
|
||||
</option>
|
||||
)}
|
||||
{options.opportunities.map((o) => (
|
||||
<option key={o.key} value={o.key}>
|
||||
{o.title} ·{' '}
|
||||
{o.kind === 'business'
|
||||
? 'Negócios'
|
||||
: 'Catálogo'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{options.search_limited && (
|
||||
<p>
|
||||
Resultados limitados por página de pesquisa;
|
||||
especifique o título para encontrar outras
|
||||
oportunidades.
|
||||
</p>
|
||||
)}
|
||||
{selected('opportunity').startsWith('business:') && (
|
||||
<p>
|
||||
{options.opportunities.find(
|
||||
(o) => o.key === selected('opportunity'),
|
||||
)?.title ??
|
||||
view.context.selection.opportunity?.title}
|
||||
<button
|
||||
type="button"
|
||||
className="ml-3 underline"
|
||||
disabled={busy}
|
||||
onClick={() => change('opportunity', '')}
|
||||
>
|
||||
Retirar esta referencia
|
||||
</button>
|
||||
</p>
|
||||
)}
|
||||
{options.search_limited && (
|
||||
<p>
|
||||
Resultados limitados por página de pesquisa;
|
||||
especifique o título para encontrar outras
|
||||
oportunidades.
|
||||
</p>
|
||||
)}
|
||||
</details>
|
||||
<label className="grid min-w-0 gap-1">
|
||||
Sector
|
||||
<select
|
||||
@@ -866,7 +956,8 @@ export default function ContextEditor({
|
||||
</select>
|
||||
</label>
|
||||
{!manageChoices && (
|
||||
<>
|
||||
<details className="rounded border p-3">
|
||||
<summary>Zonas e parques (opcional)</summary>
|
||||
<label className="grid min-w-0 gap-1">
|
||||
{choices.length > 1
|
||||
? 'Zona ou parque da primeira oportunidade'
|
||||
@@ -877,7 +968,7 @@ export default function ContextEditor({
|
||||
busy ||
|
||||
corridorLoading ||
|
||||
!!corridorError ||
|
||||
(!!firstCorridor && !firstTerritory)
|
||||
!firstTerritory
|
||||
}
|
||||
value={selected('park')}
|
||||
onChange={(e) =>
|
||||
@@ -887,10 +978,7 @@ export default function ContextEditor({
|
||||
<option value="">
|
||||
Sem ZEE, ZFI ou parque seleccionado
|
||||
</option>
|
||||
{(firstCorridor
|
||||
? parks
|
||||
: options.parks
|
||||
).map((p) => (
|
||||
{parks.map((p) => (
|
||||
<option
|
||||
key={p.id}
|
||||
value={'park:' + p.id}
|
||||
@@ -911,7 +999,7 @@ export default function ContextEditor({
|
||||
: 'A consulta não confirma disponibilidade de lotes, admissão ou incentivos.'}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
</details>
|
||||
)}
|
||||
{!manageChoices && (
|
||||
<>
|
||||
@@ -922,15 +1010,16 @@ export default function ContextEditor({
|
||||
initial={territorySelection}
|
||||
disabled={busy || manageChoices}
|
||||
endpoint="/api/v1/investment/territory-options"
|
||||
onChange={(path) =>
|
||||
onChange={(path) => {
|
||||
setConsultationPath(path);
|
||||
change(
|
||||
'territory',
|
||||
path.length
|
||||
? 'territory:' +
|
||||
path[path.length - 1].id
|
||||
: '',
|
||||
)
|
||||
}
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{view.context.selection.territory && (
|
||||
<p>
|
||||
@@ -942,117 +1031,11 @@ export default function ContextEditor({
|
||||
)}
|
||||
</section>
|
||||
<section className={card + ' space-y-3'}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Declarações deste investimento
|
||||
</h2>
|
||||
<p>
|
||||
Estes campos pertencem ao processo. Alterá-los não muda
|
||||
o cadastro da oportunidade nem o perfil da organização.
|
||||
</p>
|
||||
<p>
|
||||
Origem do investidor, residência fiscal e constituição
|
||||
da entidade são declarações distintas. A localização não
|
||||
confirma benefícios. A prévia identifica o impacto antes
|
||||
de guardar.
|
||||
</p>
|
||||
{[
|
||||
['currency', 'Moeda do projecto', null],
|
||||
[
|
||||
'expected_start_date',
|
||||
'Data prevista de início',
|
||||
null,
|
||||
],
|
||||
[
|
||||
'investor_origin',
|
||||
'Origem do investidor',
|
||||
[
|
||||
['national', 'Nacional'],
|
||||
['foreign', 'Estrangeiro'],
|
||||
['mixed', 'Misto'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'person_type',
|
||||
'Tipo de entidade',
|
||||
[
|
||||
['singular', 'Pessoa singular'],
|
||||
['collective', 'Pessoa colectiva'],
|
||||
['consortium', 'Consórcio'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'entity_stage',
|
||||
'Situação da entidade',
|
||||
[
|
||||
['existing', 'Existente'],
|
||||
['being_formed', 'Em constituição'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'tax_residency_country',
|
||||
'País de residência fiscal declarado (ISO de duas letras)',
|
||||
null,
|
||||
],
|
||||
].map(([key, label, choices]) => (
|
||||
<label className="grid gap-1" key={String(key)}>
|
||||
{String(label)}
|
||||
{Array.isArray(choices) ? (
|
||||
<select
|
||||
className={input}
|
||||
disabled={busy}
|
||||
value={
|
||||
declarations[String(key)] ??
|
||||
view.context.fields[String(key)] ??
|
||||
''
|
||||
}
|
||||
onChange={(e) => {
|
||||
setDeclarations({
|
||||
...declarations,
|
||||
[String(key)]: e.target.value,
|
||||
});
|
||||
setPlan(null);
|
||||
}}
|
||||
>
|
||||
<option value="">Por indicar</option>
|
||||
{choices.map(([value, text]) => (
|
||||
<option key={value} value={value}>
|
||||
{text}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : (
|
||||
<input
|
||||
className={input}
|
||||
disabled={busy}
|
||||
type={
|
||||
key === 'expected_start_date'
|
||||
? 'date'
|
||||
: 'text'
|
||||
}
|
||||
maxLength={
|
||||
key === 'currency'
|
||||
? 3
|
||||
: key === 'tax_residency_country'
|
||||
? 2
|
||||
: 10
|
||||
}
|
||||
value={
|
||||
declarations[String(key)] ??
|
||||
view.context.fields[String(key)] ??
|
||||
''
|
||||
}
|
||||
onChange={(e) => {
|
||||
setDeclarations({
|
||||
...declarations,
|
||||
[String(key)]: e.target.value,
|
||||
});
|
||||
setPlan(null);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
{['project_title', 'project_summary'].map((k) => (
|
||||
'project_title',
|
||||
'products_services',
|
||||
'project_summary',
|
||||
].map((k) => (
|
||||
<label className="grid gap-1" key={k}>
|
||||
{contextFieldNames[k]}
|
||||
<textarea
|
||||
@@ -1063,7 +1046,13 @@ export default function ContextEditor({
|
||||
''
|
||||
}
|
||||
disabled={busy}
|
||||
maxLength={k === 'project_title' ? 200 : 5000}
|
||||
maxLength={
|
||||
k === 'project_title'
|
||||
? 200
|
||||
: k === 'products_services'
|
||||
? 2000
|
||||
: 5000
|
||||
}
|
||||
onChange={(e) => {
|
||||
setDeclarations({
|
||||
...declarations,
|
||||
@@ -1074,6 +1063,181 @@ export default function ContextEditor({
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</section>
|
||||
<InvestmentBudgetRange
|
||||
values={{ ...view.context.fields, ...declarations }}
|
||||
onChange={(field, value) => {
|
||||
setDeclarations((old) => ({ ...old, [field]: value }));
|
||||
setPlan(null);
|
||||
}}
|
||||
/>
|
||||
<DemographicContext territoryId={consultationPath.at(-1)?.id} />
|
||||
<section className={card + ' space-y-3'}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Declarações deste investimento
|
||||
</h2>
|
||||
<details className="rounded border p-3">
|
||||
<summary>
|
||||
Enquadramento da entidade e fiscal, quando
|
||||
necessário
|
||||
</summary>
|
||||
<p>
|
||||
Estes campos pertencem ao processo. Alterá-los não
|
||||
muda o cadastro da oportunidade nem o perfil da
|
||||
organização.
|
||||
</p>
|
||||
<p>
|
||||
Origem do investidor, residência fiscal e
|
||||
constituição da entidade são declarações distintas.
|
||||
A localização não confirma benefícios. A prévia
|
||||
identifica o impacto antes de guardar.
|
||||
</p>
|
||||
{[
|
||||
[
|
||||
'expected_start_date',
|
||||
'Data prevista de início',
|
||||
null,
|
||||
],
|
||||
[
|
||||
'investor_origin',
|
||||
'Origem do investidor',
|
||||
[
|
||||
['national', 'Nacional'],
|
||||
['foreign', 'Estrangeiro'],
|
||||
['mixed', 'Misto'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'person_type',
|
||||
'Tipo de entidade',
|
||||
[
|
||||
['singular', 'Pessoa singular'],
|
||||
['collective', 'Pessoa colectiva'],
|
||||
['consortium', 'Consórcio'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'entity_stage',
|
||||
'Situação da entidade',
|
||||
[
|
||||
['existing', 'Existente'],
|
||||
['being_formed', 'Em constituição'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'tax_residency_country',
|
||||
'País de residência fiscal',
|
||||
null,
|
||||
],
|
||||
].map(([key, label, choices]) => (
|
||||
<label className="grid gap-1" key={String(key)}>
|
||||
{String(label)}
|
||||
{key === 'currency' ? (
|
||||
<CurrencySelect
|
||||
label="Moeda do projecto"
|
||||
disabled={busy}
|
||||
value={
|
||||
declarations.currency ??
|
||||
view.context.fields.currency ??
|
||||
''
|
||||
}
|
||||
error={
|
||||
(declarations.currency ??
|
||||
view.context.fields.currency) &&
|
||||
!/^[A-Z]{3}$/.test(
|
||||
declarations.currency ??
|
||||
view.context.fields
|
||||
.currency ??
|
||||
'',
|
||||
)
|
||||
? 'Seleccione a moeda na lista para confirmar este valor anterior.'
|
||||
: undefined
|
||||
}
|
||||
onChange={(value) => {
|
||||
setDeclarations({
|
||||
...declarations,
|
||||
currency: value,
|
||||
});
|
||||
setPlan(null);
|
||||
}}
|
||||
/>
|
||||
) : key === 'tax_residency_country' ? (
|
||||
<CountrySelect
|
||||
label="País de residência fiscal"
|
||||
countries={options.countries ?? []}
|
||||
disabled={busy}
|
||||
value={
|
||||
declarations.tax_residency_country ??
|
||||
view.context.fields
|
||||
.tax_residency_country ??
|
||||
''
|
||||
}
|
||||
onChange={(value) => {
|
||||
setDeclarations({
|
||||
...declarations,
|
||||
tax_residency_country: value,
|
||||
});
|
||||
setPlan(null);
|
||||
}}
|
||||
/>
|
||||
) : Array.isArray(choices) ? (
|
||||
<select
|
||||
className={input}
|
||||
disabled={busy}
|
||||
value={
|
||||
declarations[String(key)] ??
|
||||
view.context.fields[String(key)] ??
|
||||
''
|
||||
}
|
||||
onChange={(e) => {
|
||||
setDeclarations({
|
||||
...declarations,
|
||||
[String(key)]: e.target.value,
|
||||
});
|
||||
setPlan(null);
|
||||
}}
|
||||
>
|
||||
<option value="">Por indicar</option>
|
||||
{choices.map(([value, text]) => (
|
||||
<option key={value} value={value}>
|
||||
{text}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : (
|
||||
<input
|
||||
className={input}
|
||||
disabled={busy}
|
||||
type={
|
||||
key === 'expected_start_date'
|
||||
? 'date'
|
||||
: 'text'
|
||||
}
|
||||
maxLength={
|
||||
key === 'currency'
|
||||
? 3
|
||||
: key ===
|
||||
'tax_residency_country'
|
||||
? 2
|
||||
: 10
|
||||
}
|
||||
value={
|
||||
declarations[String(key)] ??
|
||||
view.context.fields[String(key)] ??
|
||||
''
|
||||
}
|
||||
onChange={(e) => {
|
||||
setDeclarations({
|
||||
...declarations,
|
||||
[String(key)]: e.target.value,
|
||||
});
|
||||
setPlan(null);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
</details>
|
||||
<details>
|
||||
<summary>
|
||||
Substituições explícitas de declarações
|
||||
|
||||
Reference in New Issue
Block a user