@@ -3,6 +3,7 @@ import { Link } from '@inertiajs/react';
|
||||
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';
|
||||
|
||||
type Opportunity = {
|
||||
id: string;
|
||||
@@ -10,8 +11,14 @@ type Opportunity = {
|
||||
title: string;
|
||||
sector?: { name: string } | null;
|
||||
};
|
||||
type Props = { record: Opportunity; modalities: string[]; returnUrl?: string };
|
||||
type Props = {
|
||||
record: Opportunity;
|
||||
modalities: string[];
|
||||
returnUrl?: string;
|
||||
countries: Country[];
|
||||
};
|
||||
type Form = {
|
||||
declared_origin_country_code: string;
|
||||
fullName: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
@@ -29,13 +36,15 @@ export default function BusinessInterest({
|
||||
record,
|
||||
modalities,
|
||||
returnUrl = '/negocios',
|
||||
countries,
|
||||
}: Props) {
|
||||
const [form, setForm] = useState<Form>({
|
||||
declared_origin_country_code: '',
|
||||
fullName: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
investorType: 'empresa',
|
||||
country: 'MZ',
|
||||
country: '',
|
||||
sectorInterest: record.sector?.name ?? '',
|
||||
modality: modalities[0] ?? '',
|
||||
investmentRange: '',
|
||||
@@ -114,6 +123,19 @@ export default function BusinessInterest({
|
||||
</section>
|
||||
) : (
|
||||
<form className={`${card} space-y-4`} onSubmit={submit}>
|
||||
<Field label="País de origem declarado desta solicitação">
|
||||
<CountrySelect
|
||||
countries={countries}
|
||||
value={form.declared_origin_country_code}
|
||||
onChange={(value) =>
|
||||
update('declared_origin_country_code', value)
|
||||
}
|
||||
/>
|
||||
<p className="text-sm">
|
||||
Origem opcional e independente do país do
|
||||
investidor.
|
||||
</p>
|
||||
</Field>
|
||||
<Field label="Nome ou denominação">
|
||||
<input
|
||||
className={input}
|
||||
@@ -161,12 +183,12 @@ export default function BusinessInterest({
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="País">
|
||||
<input
|
||||
className={input}
|
||||
<CountrySelect
|
||||
countries={countries}
|
||||
required
|
||||
maxLength={100}
|
||||
allowLegacyValue
|
||||
value={form.country}
|
||||
onChange={(e) => update('country', e.target.value)}
|
||||
onChange={(value) => update('country', value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Sector de interesse">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { router } from '@inertiajs/react';
|
||||
import CountrySelect, { type Country } from '@/components/country-select';
|
||||
import { Frame, Field, input, button, card, api } from './shared';
|
||||
import type { Business } from './business-types';
|
||||
import { businessModalities } from './business-types';
|
||||
@@ -27,6 +28,7 @@ export type FormSchema = Record<
|
||||
}
|
||||
>;
|
||||
type Props = {
|
||||
countries: Country[];
|
||||
record: Business;
|
||||
modalities: string[];
|
||||
formSchema: FormSchema;
|
||||
@@ -207,6 +209,7 @@ function opportunityTypeFor(modality: string): string {
|
||||
}
|
||||
|
||||
export default function BusinessWizard({
|
||||
countries,
|
||||
record,
|
||||
formSchema,
|
||||
objects,
|
||||
@@ -706,6 +709,18 @@ export default function BusinessWizard({
|
||||
*
|
||||
</span>
|
||||
</span>
|
||||
) : field.type === 'country' ? (
|
||||
<CountrySelect
|
||||
countries={countries}
|
||||
value={payload[key] ?? ''}
|
||||
allowLegacyValue={key === 'country'}
|
||||
onChange={(value) =>
|
||||
update(key, value)
|
||||
}
|
||||
label={
|
||||
english ? field.en : field.pt
|
||||
}
|
||||
/>
|
||||
) : field.type === 'territory' ? (
|
||||
<TerritoryField
|
||||
name={english ? field.en : field.pt}
|
||||
|
||||
@@ -9,8 +9,10 @@ import BusinessVerifications from './business-verifications';
|
||||
import type { BusinessVerification } from './business-verifications';
|
||||
import BusinessWizard from './business-wizard';
|
||||
import type { FormSchema } from './business-wizard';
|
||||
import type { Country } from '@/components/country-select';
|
||||
|
||||
type Props = {
|
||||
countries: Country[];
|
||||
formSchema: FormSchema;
|
||||
sectors: { id: number; name: string }[];
|
||||
record: Business;
|
||||
|
||||
@@ -3,11 +3,14 @@ import { useState } from 'react';
|
||||
import { Frame, Field, input, button, card, api } from './shared';
|
||||
import { businessModalities, businessStates } from './business-types';
|
||||
import type { Business } from './business-types';
|
||||
import CountrySelect, { type Country } from '@/components/country-select';
|
||||
|
||||
export default function Businesses({
|
||||
records,
|
||||
management,
|
||||
modalities,
|
||||
filters,
|
||||
countries,
|
||||
}: {
|
||||
records: {
|
||||
data: Business[];
|
||||
@@ -16,11 +19,15 @@ export default function Businesses({
|
||||
};
|
||||
management: boolean;
|
||||
modalities: string[];
|
||||
countries: Country[];
|
||||
filters: { country?: string; origin?: string };
|
||||
}) {
|
||||
const [title, setTitle] = useState('');
|
||||
const [modality, setModality] = useState(modalities[0]);
|
||||
const [error, setError] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [country, setCountry] = useState(filters.country ?? '');
|
||||
const [origin, setOrigin] = useState(filters.origin ?? '');
|
||||
return (
|
||||
<Frame title={management ? 'Revisão de negócios' : 'Os meus negócios'}>
|
||||
<p>
|
||||
@@ -28,6 +35,43 @@ export default function Businesses({
|
||||
titularidade, validade ou transmissibilidade do negócio, activo
|
||||
ou direito.
|
||||
</p>
|
||||
<form
|
||||
className={`${card} flex flex-wrap gap-3`}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
router.get(
|
||||
management
|
||||
? '/management/negocios'
|
||||
: '/investidor/negocios',
|
||||
{ country, origin },
|
||||
);
|
||||
}}
|
||||
>
|
||||
<CountrySelect
|
||||
countries={countries}
|
||||
value={country}
|
||||
onChange={setCountry}
|
||||
label="Filtrar país do proponente"
|
||||
/>
|
||||
<label>
|
||||
Origem declarada
|
||||
<select
|
||||
aria-label="Filtrar origem declarada"
|
||||
className={input}
|
||||
value={origin}
|
||||
onChange={(e) => setOrigin(e.target.value)}
|
||||
>
|
||||
<option value="">Todas</option>
|
||||
<option value="unknown">Não informada</option>
|
||||
{countries.map((c) => (
|
||||
<option key={c.code} value={c.code}>
|
||||
{c.name} ({c.code})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<button className={button}>Filtrar negócios</button>
|
||||
</form>
|
||||
{!management && (
|
||||
<form
|
||||
className={`${card} space-y-4`}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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 type { InvestmentMapArea } from '@/components/interactive-investment-map';
|
||||
import {
|
||||
TerritoryLevel,
|
||||
@@ -98,7 +99,9 @@ export default function Catalogue({
|
||||
{ id: number; title: string; location: string; url: string }[]
|
||||
>([]);
|
||||
const [truncated, setTruncated] = useState(false);
|
||||
const [mapContext, setMapContext] = useState<{ id: string; title: string; kind: string; url: string }[]>([]);
|
||||
const [mapContext, setMapContext] = useState<
|
||||
{ id: string; title: string; kind: string; url: string }[]
|
||||
>([]);
|
||||
const [error, setError] = useState('');
|
||||
const [suggestions, setSuggestions] = useState<
|
||||
{ title: string; slug: string }[]
|
||||
@@ -230,7 +233,14 @@ export default function Catalogue({
|
||||
const dimensionUrl = (dimension: string) => {
|
||||
const params = new URLSearchParams(query());
|
||||
params.set('dimension', dimension);
|
||||
['cluster_id', 'corridor_id', 'zee_id', 'zfi_id', 'park_id', 'project_id'].forEach((key) => params.delete(key));
|
||||
[
|
||||
'cluster_id',
|
||||
'corridor_id',
|
||||
'zee_id',
|
||||
'zfi_id',
|
||||
'park_id',
|
||||
'project_id',
|
||||
].forEach((key) => params.delete(key));
|
||||
params.delete('page');
|
||||
return `${catalogueUrl}?${params}`;
|
||||
};
|
||||
@@ -391,28 +401,39 @@ export default function Catalogue({
|
||||
['zfi_id', 'zfi', 'ZFI'],
|
||||
['park_id', 'industrial_park', 'Parque industrial'],
|
||||
] as const
|
||||
).filter(([field]) => !form.data.dimension || field === `${form.data.dimension}_id` || !!form.data[field]).map(([field, category, label]) => (
|
||||
<Field key={field} label={label}>
|
||||
<select
|
||||
className={input}
|
||||
value={form.data[field]}
|
||||
onChange={(e) =>
|
||||
form.setData(field, e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{(references.zones ?? [])
|
||||
.filter(
|
||||
(zone) => zone.category === category,
|
||||
)
|
||||
.map((zone) => (
|
||||
<option key={zone.id} value={zone.id}>
|
||||
{zone.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
))}
|
||||
)
|
||||
.filter(
|
||||
([field]) =>
|
||||
!form.data.dimension ||
|
||||
field === `${form.data.dimension}_id` ||
|
||||
!!form.data[field],
|
||||
)
|
||||
.map(([field, category, label]) => (
|
||||
<Field key={field} label={label}>
|
||||
<select
|
||||
className={input}
|
||||
value={form.data[field]}
|
||||
onChange={(e) =>
|
||||
form.setData(field, e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{(references.zones ?? [])
|
||||
.filter(
|
||||
(zone) =>
|
||||
zone.category === category,
|
||||
)
|
||||
.map((zone) => (
|
||||
<option
|
||||
key={zone.id}
|
||||
value={zone.id}
|
||||
>
|
||||
{zone.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
))}
|
||||
{(['clusters', 'corridors', 'projects'] as const).map(
|
||||
(group, index) => {
|
||||
const key = (
|
||||
@@ -429,7 +450,12 @@ export default function Catalogue({
|
||||
'Projecto âncora',
|
||||
] as const
|
||||
)[index];
|
||||
if (form.data.dimension && key !== `${form.data.dimension}_id` && !form.data[key]) return null;
|
||||
if (
|
||||
form.data.dimension &&
|
||||
key !== `${form.data.dimension}_id` &&
|
||||
!form.data[key]
|
||||
)
|
||||
return null;
|
||||
return (
|
||||
<Field key={group} label={label}>
|
||||
<select
|
||||
@@ -1091,11 +1117,47 @@ export default function Catalogue({
|
||||
</div>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
{!error && <Map points={points} areas={areas} />}
|
||||
{['map', 'combined'].includes(view) && !error && mapContext.length > 0 && <section className={card} aria-label="Estruturas territoriais consultáveis">
|
||||
<h2 className="text-xl font-bold">Estruturas territoriais e projetos</h2>
|
||||
<p>Estas fichas continuam consultáveis independentemente de terem coordenadas. A lista não atribui implantação às oportunidades nem cria pontos no mapa. Até 30 fichas por conjunto; refine a localização para pesquisar.</p>
|
||||
<ul>{mapContext.map((record) => <li key={record.id}><Link className="underline" href={record.url}>{record.kind}: {record.title}</Link></li>)}</ul>
|
||||
</section>}
|
||||
{['map', 'combined'].includes(view) && (
|
||||
<TerritoryGeometryPreview
|
||||
territoryId={
|
||||
form.data.locality_id ||
|
||||
form.data.admin_post_id ||
|
||||
form.data.district_id ||
|
||||
form.data.province_id
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{['map', 'combined'].includes(view) &&
|
||||
!error &&
|
||||
mapContext.length > 0 && (
|
||||
<section
|
||||
className={card}
|
||||
aria-label="Estruturas territoriais consultáveis"
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
Estruturas territoriais e projetos
|
||||
</h2>
|
||||
<p>
|
||||
Estas fichas continuam consultáveis
|
||||
independentemente de terem coordenadas. A lista não
|
||||
atribui implantação às oportunidades nem cria pontos
|
||||
no mapa. Até 30 fichas por conjunto; refine a
|
||||
localização para pesquisar.
|
||||
</p>
|
||||
<ul>
|
||||
{mapContext.map((record) => (
|
||||
<li key={record.id}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={record.url}
|
||||
>
|
||||
{record.kind}: {record.title}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
{truncated && (
|
||||
<p role="alert">
|
||||
O mapa atingiu o limite de 1.000 registos; refine os
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { Link, router, usePage } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import InvestmentMapPanel from '@/components/investment-map-panel';
|
||||
import { Link, router, usePage } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import InvestmentMapPanel from "@/components/investment-map-panel";
|
||||
import StructureGeographyPanel, {
|
||||
LocationList,
|
||||
} from '@/components/structure-geography';
|
||||
import PartnershipSourceLinks from '@/components/partnership-source-links';
|
||||
import TerritorialSources from '@/components/territorial-source-evidence';
|
||||
import { Frame, card, button, money, groupLabels } from './shared';
|
||||
import type { Opportunity, Context } from './shared';
|
||||
} from "@/components/structure-geography";
|
||||
import PartnershipSourceLinks from "@/components/partnership-source-links";
|
||||
import TerritorialSources from "@/components/territorial-source-evidence";
|
||||
import { Frame, card, button, money, groupLabels } from "./shared";
|
||||
import type { Opportunity, Context } from "./shared";
|
||||
export default function Detail({
|
||||
record: r,
|
||||
context: c,
|
||||
zone_origin,
|
||||
returnUrl = '/oportunidades',
|
||||
returnUrl = "/oportunidades",
|
||||
dossierOrigin,
|
||||
}: {
|
||||
record: Opportunity;
|
||||
@@ -22,7 +22,7 @@ export default function Detail({
|
||||
dossierOrigin?: { id: string; title: string } | null;
|
||||
}) {
|
||||
const { auth } = usePage<{ auth: { user: unknown } }>().props;
|
||||
const [sharing, setSharing] = useState('');
|
||||
const [sharing, setSharing] = useState("");
|
||||
return (
|
||||
<Frame title={r.title}>
|
||||
<PartnershipSourceLinks type="investment" id={r.id} />
|
||||
@@ -52,7 +52,7 @@ export default function Detail({
|
||||
)}
|
||||
<p className="text-xl">{r.summary}</p>
|
||||
<TerritorialSources sources={c.source_evidence} />
|
||||
<section className={card + ' space-y-3'}>
|
||||
<section className={card + " space-y-3"}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Implantação declarada da oportunidade
|
||||
</h2>
|
||||
@@ -70,15 +70,18 @@ export default function Detail({
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<InvestmentMapPanel filters={{ opportunity_id: r.id }} />
|
||||
<InvestmentMapPanel
|
||||
filters={{ opportunity_id: r.id }}
|
||||
territoryId={c.primary_territory_path?.at(-1)?.id}
|
||||
/>
|
||||
{c.primary_territory_path &&
|
||||
c.primary_territory_path.length > 0 && (
|
||||
<p>
|
||||
Território principal cadastrado (implantação por
|
||||
confirmar):{' '}
|
||||
confirmar):{" "}
|
||||
{c.primary_territory_path
|
||||
.map((node) => node.name)
|
||||
.join(' → ')}
|
||||
.join(" → ")}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-4">
|
||||
@@ -86,12 +89,12 @@ export default function Detail({
|
||||
<button
|
||||
className={button}
|
||||
onClick={() =>
|
||||
router.post('/investidor/manifestacoes', {
|
||||
router.post("/investidor/manifestacoes", {
|
||||
opportunity_id: r.id,
|
||||
...(zone_origin
|
||||
? {
|
||||
zone_id: zone_origin.id,
|
||||
intent: 'interest',
|
||||
intent: "interest",
|
||||
}
|
||||
: {}),
|
||||
})
|
||||
@@ -115,16 +118,16 @@ export default function Detail({
|
||||
onClick={() => {
|
||||
if (!navigator.clipboard) {
|
||||
setSharing(
|
||||
'Copie a ligação na barra de endereço do navegador.',
|
||||
"Copie a ligação na barra de endereço do navegador.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
navigator.clipboard
|
||||
.writeText(window.location.href)
|
||||
.then(() => setSharing('Ligação copiada.'))
|
||||
.then(() => setSharing("Ligação copiada."))
|
||||
.catch(() =>
|
||||
setSharing(
|
||||
'Copie a ligação na barra de endereço do navegador.',
|
||||
"Copie a ligação na barra de endereço do navegador.",
|
||||
),
|
||||
);
|
||||
}}
|
||||
@@ -145,11 +148,11 @@ export default function Detail({
|
||||
href={`/zonas?category=${z.category}&q=${encodeURIComponent(z.name)}`}
|
||||
>
|
||||
{z.name}
|
||||
</Link>{' '}
|
||||
·{' '}
|
||||
{z.association_type === 'official'
|
||||
? 'Associação documental validada'
|
||||
: 'Relação ' + z.association_type}{' '}
|
||||
</Link>{" "}
|
||||
·{" "}
|
||||
{z.association_type === "official"
|
||||
? "Associação documental validada"
|
||||
: "Relação " + z.association_type}{" "}
|
||||
· Fonte: {z.source_reference}
|
||||
</p>
|
||||
))}
|
||||
@@ -161,42 +164,42 @@ export default function Detail({
|
||||
)}
|
||||
<div className="grid gap-6 lg:grid-cols-3">
|
||||
<section
|
||||
className={card + ' whitespace-pre-line lg:col-span-2'}
|
||||
className={card + " whitespace-pre-line lg:col-span-2"}
|
||||
>
|
||||
<h2 className="mb-3 text-xl font-bold">O investimento</h2>
|
||||
{r.description || 'Descrição por completar.'}
|
||||
{r.description || "Descrição por completar."}
|
||||
</section>
|
||||
<dl className={card + ' space-y-4'}>
|
||||
<dl className={card + " space-y-4"}>
|
||||
{[
|
||||
['Promotor', r.promoter_name],
|
||||
['Investimento', money(r)],
|
||||
['Maturidade', r.maturity_label],
|
||||
['Parceria', r.financing_modality],
|
||||
['Impacto', r.expected_impact],
|
||||
['Calendário', c.profile?.target_date],
|
||||
["Promotor", r.promoter_name],
|
||||
["Investimento", money(r)],
|
||||
["Maturidade", r.maturity_label],
|
||||
["Parceria", r.financing_modality],
|
||||
["Impacto", r.expected_impact],
|
||||
["Calendário", c.profile?.target_date],
|
||||
].map(([key, value]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-bold">{key}</dt>
|
||||
<dd>{value || 'Não indicado'}</dd>
|
||||
<dd>{value || "Não indicado"}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</div>
|
||||
{c.profile && (
|
||||
<section className={card + ' space-y-4'}>
|
||||
<section className={card + " space-y-4"}>
|
||||
<h2 className="text-xl font-bold">
|
||||
Viabilidade e preparação
|
||||
</h2>
|
||||
{[
|
||||
['Modelo de negócio', c.profile.business_model],
|
||||
['Requisitos', c.profile.requirements],
|
||||
['Riscos', c.profile.risks],
|
||||
['Fonte', c.profile.source_reference],
|
||||
["Modelo de negócio", c.profile.business_model],
|
||||
["Requisitos", c.profile.requirements],
|
||||
["Riscos", c.profile.risks],
|
||||
["Fonte", c.profile.source_reference],
|
||||
].map(([label, text]) => (
|
||||
<div key={label}>
|
||||
<h3 className="font-bold">{label}</h3>
|
||||
<p className="whitespace-pre-line">
|
||||
{text || 'Não indicado'}
|
||||
{text || "Não indicado"}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
@@ -209,16 +212,16 @@ export default function Detail({
|
||||
)}
|
||||
<section className="grid gap-4 md:grid-cols-4">
|
||||
{(
|
||||
['clusters', 'corridors', 'projects', 'locations'] as const
|
||||
["clusters", "corridors", "projects", "locations"] as const
|
||||
).map((key, i) => (
|
||||
<div className={card} key={key}>
|
||||
<h2 className="font-bold">
|
||||
{
|
||||
[
|
||||
'Clusters',
|
||||
'Corredores',
|
||||
'Projectos âncora',
|
||||
'Territórios',
|
||||
"Clusters",
|
||||
"Corredores",
|
||||
"Projectos âncora",
|
||||
"Territórios",
|
||||
][i]
|
||||
}
|
||||
</h2>
|
||||
@@ -238,14 +241,14 @@ export default function Detail({
|
||||
<Link
|
||||
className="underline"
|
||||
href={
|
||||
'/oportunidades?' +
|
||||
"/oportunidades?" +
|
||||
[
|
||||
'cluster_id',
|
||||
'corridor_id',
|
||||
'project_id',
|
||||
'geo_location_id',
|
||||
"cluster_id",
|
||||
"corridor_id",
|
||||
"project_id",
|
||||
"geo_location_id",
|
||||
][i] +
|
||||
'=' +
|
||||
"=" +
|
||||
entity.id
|
||||
}
|
||||
>
|
||||
@@ -257,7 +260,7 @@ export default function Detail({
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
{(['projects', 'clusters'] as const).flatMap((key) =>
|
||||
{(["projects", "clusters"] as const).flatMap((key) =>
|
||||
c[key]
|
||||
.filter(
|
||||
(entity) => entity.geography && entity.dossiers?.length,
|
||||
@@ -266,7 +269,7 @@ export default function Detail({
|
||||
<StructureGeographyPanel
|
||||
key={`${key}-${entity.id}`}
|
||||
geography={entity.geography!}
|
||||
cluster={key === 'clusters'}
|
||||
cluster={key === "clusters"}
|
||||
dossierId={entity.dossiers![0].id}
|
||||
/>
|
||||
)),
|
||||
|
||||
@@ -127,7 +127,10 @@ function Editor({
|
||||
const form = useForm({
|
||||
version: record.version,
|
||||
payload: Object.fromEntries(
|
||||
[...fields, 'country'].map((key) => [key, record.payload[key] ?? '']),
|
||||
[...fields, 'country'].map((key) => [
|
||||
key,
|
||||
record.payload[key] ?? '',
|
||||
]),
|
||||
),
|
||||
});
|
||||
return (
|
||||
@@ -146,33 +149,56 @@ function Editor({
|
||||
}}
|
||||
>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{record.payload.country && <p>País anteriormente registado: {record.payload.country}. Conservado sem atribuir automaticamente residência, constituição ou origem da solicitação.</p>}
|
||||
{record.payload.country && (
|
||||
<p>
|
||||
País anteriormente registado: {record.payload.country}.
|
||||
Conservado sem atribuir automaticamente residência,
|
||||
constituição ou origem da solicitação.
|
||||
</p>
|
||||
)}
|
||||
{fields.map((key) => (
|
||||
<Field key={key} label={labels[key]}>
|
||||
{key.endsWith('_country_code') ? <CountrySelect id={key + (record.id ?? 'account')} countries={countries} value={form.data.payload[key]} onChange={(value) => form.setData('payload', { ...form.data.payload, [key]: value })} /> :
|
||||
<input
|
||||
className={input}
|
||||
value={form.data.payload[key]}
|
||||
required={
|
||||
isCompany &&
|
||||
['name', 'country', 'role'].includes(key)
|
||||
}
|
||||
maxLength={
|
||||
key === 'description' || key === 'experience'
|
||||
? 2000
|
||||
: key === 'investment_capacity'
|
||||
? 1000
|
||||
: 200
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
}
|
||||
{form.errors[`payload.${key}`] && <p role="alert" className="text-red-700">{form.errors[`payload.${key}`]}</p>}
|
||||
{key.endsWith('_country_code') ? (
|
||||
<CountrySelect
|
||||
id={key + (record.id ?? 'account')}
|
||||
countries={countries}
|
||||
value={form.data.payload[key]}
|
||||
onChange={(value) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
className={input}
|
||||
value={form.data.payload[key]}
|
||||
required={
|
||||
isCompany &&
|
||||
['name', 'country', 'role'].includes(key)
|
||||
}
|
||||
maxLength={
|
||||
key === 'description' ||
|
||||
key === 'experience'
|
||||
? 2000
|
||||
: key === 'investment_capacity'
|
||||
? 1000
|
||||
: 200
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{form.errors[`payload.${key}`] && (
|
||||
<p role="alert" className="text-red-700">
|
||||
{form.errors[`payload.${key}`]}
|
||||
</p>
|
||||
)}
|
||||
</Field>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -358,12 +358,57 @@ function Editor({
|
||||
{text('full_name', 'Nome completo', true)}
|
||||
{text('email', 'Email', true, 'email')}
|
||||
{text('phone', 'Telefone')}
|
||||
{form.data.payload.country && <p>País anteriormente registado: {form.data.payload.country}. Não foi convertido em residência, constituição ou origem.</p>}
|
||||
{(['residence_country_code', 'incorporation_country_code', 'declared_origin_country_code'] as const).map((key) => <Field key={key} label={{ residence_country_code: 'País de residência', incorporation_country_code: 'País de constituição da entidade', declared_origin_country_code: 'País de origem declarado desta solicitação' }[key]}>
|
||||
<CountrySelect disabled={readonly} id={key} countries={countries} value={form.data.payload[key] ?? ''} onChange={(value) => form.setData('payload', { ...form.data.payload, [key]: value })} />
|
||||
{form.errors[`payload.${key}`] && <p role="alert">{form.errors[`payload.${key}`]}</p>}
|
||||
</Field>)}
|
||||
<p>A origem da solicitação é uma declaração sua; não é deduzida da residência, da entidade ou do endereço IP.</p>
|
||||
{form.data.payload.country && (
|
||||
<p>
|
||||
País anteriormente registado:{' '}
|
||||
{form.data.payload.country}. Não foi convertido
|
||||
em residência, constituição ou origem.
|
||||
</p>
|
||||
)}
|
||||
{(
|
||||
[
|
||||
'residence_country_code',
|
||||
'incorporation_country_code',
|
||||
'declared_origin_country_code',
|
||||
] as const
|
||||
).map((key) => (
|
||||
<Field
|
||||
key={key}
|
||||
label={
|
||||
{
|
||||
residence_country_code:
|
||||
'País de residência',
|
||||
incorporation_country_code:
|
||||
'País de constituição da entidade',
|
||||
declared_origin_country_code:
|
||||
'País de origem declarado desta solicitação',
|
||||
}[key]
|
||||
}
|
||||
>
|
||||
<CountrySelect
|
||||
disabled={readonly}
|
||||
id={key}
|
||||
countries={countries}
|
||||
value={form.data.payload[key] ?? ''}
|
||||
onChange={(value) =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
{form.errors[`payload.${key}`] && (
|
||||
<p role="alert">
|
||||
{form.errors[`payload.${key}`]}
|
||||
</p>
|
||||
)}
|
||||
</Field>
|
||||
))}
|
||||
<p>
|
||||
A origem da solicitação é uma declaração sua; não é
|
||||
deduzida da residência, da entidade ou do endereço
|
||||
IP.
|
||||
</p>
|
||||
{option(
|
||||
'profile_id',
|
||||
'investor_profile',
|
||||
|
||||
Reference in New Issue
Block a user