oportunidades 3
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-09 15:00:37 +02:00
parent 9d6176f55b
commit e662230df7
32 changed files with 865 additions and 37 deletions
+19 -5
View File
@@ -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>