@@ -98,6 +98,7 @@ 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 [error, setError] = useState('');
|
||||
const [suggestions, setSuggestions] = useState<
|
||||
{ title: string; slug: string }[]
|
||||
@@ -152,6 +153,7 @@ export default function Catalogue({
|
||||
setPoints(null);
|
||||
setAreas([]);
|
||||
setUnlocated([]);
|
||||
setMapContext([]);
|
||||
setTruncated(false);
|
||||
setError('');
|
||||
api(`/api/v1/investment/map?${params}`)
|
||||
@@ -160,6 +162,7 @@ export default function Catalogue({
|
||||
setPoints(data.features);
|
||||
setAreas(data.areas ?? []);
|
||||
setUnlocated(data.unlocated ?? []);
|
||||
setMapContext(data.territorial_context ?? []);
|
||||
setTruncated(Boolean(data.truncated));
|
||||
}
|
||||
})
|
||||
@@ -227,6 +230,7 @@ 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));
|
||||
params.delete('page');
|
||||
return `${catalogueUrl}?${params}`;
|
||||
};
|
||||
@@ -329,7 +333,7 @@ export default function Catalogue({
|
||||
index={index}
|
||||
parent={territoryPath[index - 1]?.id ?? ''}
|
||||
selected={territoryPath[index]}
|
||||
endpoint="/api/v1/catalogs/jurisdictions"
|
||||
endpoint="/api/v1/investment/territory-options"
|
||||
onChange={(value) => {
|
||||
const path = [
|
||||
...territoryPath.slice(0, index),
|
||||
@@ -387,7 +391,7 @@ export default function Catalogue({
|
||||
['zfi_id', 'zfi', 'ZFI'],
|
||||
['park_id', 'industrial_park', 'Parque industrial'],
|
||||
] as const
|
||||
).map(([field, category, label]) => (
|
||||
).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}
|
||||
@@ -425,6 +429,7 @@ export default function Catalogue({
|
||||
'Projecto âncora',
|
||||
] as const
|
||||
)[index];
|
||||
if (form.data.dimension && key !== `${form.data.dimension}_id` && !form.data[key]) return null;
|
||||
return (
|
||||
<Field key={group} label={label}>
|
||||
<select
|
||||
@@ -1086,6 +1091,11 @@ 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>}
|
||||
{truncated && (
|
||||
<p role="alert">
|
||||
O mapa atingiu o limite de 1.000 registos; refine os
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Link, router, useForm } from '@inertiajs/react';
|
||||
import { Frame, Field, input, button, card } from './shared';
|
||||
import PartnershipSourceLinks from '@/components/partnership-source-links';
|
||||
import CountrySelect, { type Country } from '@/components/country-select';
|
||||
|
||||
type RecordData = { version: number; payload: Record<string, string> };
|
||||
type Company = RecordData & { id: string };
|
||||
const labels: Record<string, string> = {
|
||||
phone: 'Telefone',
|
||||
country: 'País',
|
||||
country: 'País anteriormente registado',
|
||||
residence_country_code: 'País de residência do investidor',
|
||||
incorporation_country_code: 'País de constituição da entidade',
|
||||
sector: 'Sector de interesse',
|
||||
experience: 'Experiência relevante',
|
||||
investment_capacity: 'Capacidade de investimento declarada',
|
||||
@@ -19,9 +22,11 @@ const labels: Record<string, string> = {
|
||||
export default function Profile({
|
||||
account,
|
||||
companies,
|
||||
countries,
|
||||
}: {
|
||||
account: RecordData;
|
||||
companies: Company[];
|
||||
countries: Country[];
|
||||
}) {
|
||||
return (
|
||||
<Frame title="Perfil de investimento e empresas">
|
||||
@@ -39,9 +44,10 @@ export default function Profile({
|
||||
<Editor
|
||||
key={'account-' + account.version}
|
||||
record={account}
|
||||
countries={countries}
|
||||
fields={[
|
||||
'phone',
|
||||
'country',
|
||||
'residence_country_code',
|
||||
'sector',
|
||||
'experience',
|
||||
'investment_capacity',
|
||||
@@ -62,9 +68,10 @@ export default function Profile({
|
||||
<Editor
|
||||
key={company.version}
|
||||
record={company}
|
||||
countries={countries}
|
||||
fields={[
|
||||
'name',
|
||||
'country',
|
||||
'incorporation_country_code',
|
||||
'registration',
|
||||
'sector',
|
||||
'role',
|
||||
@@ -90,9 +97,10 @@ export default function Profile({
|
||||
key={'new-' + companies.length}
|
||||
record={{ version: 0, payload: {} }}
|
||||
company
|
||||
countries={countries}
|
||||
fields={[
|
||||
'name',
|
||||
'country',
|
||||
'incorporation_country_code',
|
||||
'registration',
|
||||
'sector',
|
||||
'role',
|
||||
@@ -108,16 +116,18 @@ function Editor({
|
||||
record,
|
||||
fields,
|
||||
company = false,
|
||||
countries,
|
||||
}: {
|
||||
record: RecordData & { id?: string };
|
||||
fields: string[];
|
||||
company?: boolean;
|
||||
countries: Country[];
|
||||
}) {
|
||||
const isCompany = company || !!record.id;
|
||||
const form = useForm({
|
||||
version: record.version,
|
||||
payload: Object.fromEntries(
|
||||
fields.map((key) => [key, record.payload[key] ?? '']),
|
||||
[...fields, 'country'].map((key) => [key, record.payload[key] ?? '']),
|
||||
),
|
||||
});
|
||||
return (
|
||||
@@ -136,8 +146,10 @@ 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>}
|
||||
{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]}
|
||||
@@ -159,6 +171,8 @@ function Editor({
|
||||
})
|
||||
}
|
||||
/>
|
||||
}
|
||||
{form.errors[`payload.${key}`] && <p role="alert" className="text-red-700">{form.errors[`payload.${key}`]}</p>}
|
||||
</Field>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -4,11 +4,15 @@ import { Frame, Field, input, button, card } from './shared';
|
||||
import type { References } from './shared';
|
||||
import { Conversation } from './conversation';
|
||||
import type { Message } from './conversation';
|
||||
import CountrySelect, { type Country } from '@/components/country-select';
|
||||
type Payload = {
|
||||
full_name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
country: string;
|
||||
residence_country_code: string;
|
||||
incorporation_country_code: string;
|
||||
declared_origin_country_code: string;
|
||||
organisation: string;
|
||||
representative_role: string;
|
||||
experience: string;
|
||||
@@ -51,6 +55,7 @@ type Need = {
|
||||
};
|
||||
};
|
||||
type Props = {
|
||||
countries: Country[];
|
||||
zone_origin?: {
|
||||
zone_id: string;
|
||||
zone_version: number;
|
||||
@@ -119,12 +124,16 @@ function Editor({
|
||||
revisions,
|
||||
step,
|
||||
setStep,
|
||||
countries,
|
||||
}: Props & { step: number; setStep: (step: number) => void }) {
|
||||
const initial: Payload = {
|
||||
full_name: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
country: '',
|
||||
residence_country_code: '',
|
||||
incorporation_country_code: '',
|
||||
declared_origin_country_code: '',
|
||||
organisation: '',
|
||||
representative_role: '',
|
||||
experience: '',
|
||||
@@ -349,7 +358,12 @@ function Editor({
|
||||
{text('full_name', 'Nome completo', true)}
|
||||
{text('email', 'Email', true, 'email')}
|
||||
{text('phone', 'Telefone')}
|
||||
{text('country', 'País', true)}
|
||||
{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