@@ -1,19 +1,19 @@
|
||||
import { Link, router, useForm } from "@inertiajs/react";
|
||||
import { Frame, Field, input, button, card } from "./shared";
|
||||
import { Link, router, useForm } from '@inertiajs/react';
|
||||
import { Frame, Field, input, button, card } from './shared';
|
||||
import PartnershipSourceLinks from '@/components/partnership-source-links';
|
||||
|
||||
type RecordData = { version: number; payload: Record<string, string> };
|
||||
type Company = RecordData & { id: string };
|
||||
const labels: Record<string, string> = {
|
||||
phone: "Telefone",
|
||||
country: "País",
|
||||
sector: "Sector de interesse",
|
||||
experience: "Experiência relevante",
|
||||
investment_capacity: "Capacidade de investimento declarada",
|
||||
name: "Nome da empresa",
|
||||
registration: "Referência de registo / NUIT",
|
||||
role: "Função ou relação com a empresa",
|
||||
description: "Actividade e observações",
|
||||
phone: 'Telefone',
|
||||
country: 'País',
|
||||
sector: 'Sector de interesse',
|
||||
experience: 'Experiência relevante',
|
||||
investment_capacity: 'Capacidade de investimento declarada',
|
||||
name: 'Nome da empresa',
|
||||
registration: 'Referência de registo / NUIT',
|
||||
role: 'Função ou relação com a empresa',
|
||||
description: 'Actividade e observações',
|
||||
};
|
||||
|
||||
export default function Profile({
|
||||
@@ -29,43 +29,54 @@ export default function Profile({
|
||||
Voltar à área do investidor
|
||||
</Link>
|
||||
<p>
|
||||
Estes dados são privados e servem para preencher novas manifestações. Nome e email
|
||||
são mantidos nas{" "}
|
||||
Estes dados são privados e servem para preencher novas
|
||||
manifestações. Nome e email são mantidos nas{' '}
|
||||
<Link className="underline" href="/settings/profile">
|
||||
definições da conta
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
<Editor
|
||||
key={"account-" + account.version}
|
||||
key={'account-' + account.version}
|
||||
record={account}
|
||||
fields={["phone", "country", "sector", "experience", "investment_capacity"]}
|
||||
fields={[
|
||||
'phone',
|
||||
'country',
|
||||
'sector',
|
||||
'experience',
|
||||
'investment_capacity',
|
||||
]}
|
||||
/>
|
||||
<h2 className="text-2xl font-bold">Empresas declaradas</h2>
|
||||
<p>
|
||||
Declarar uma empresa não comprova representação legal nem concede acesso aos
|
||||
registos de outras pessoas. A equipa pode pedir evidência durante o atendimento.
|
||||
Declarar uma empresa não comprova representação legal nem
|
||||
concede acesso aos registos de outras pessoas. A equipa pode
|
||||
pedir evidência durante o atendimento.
|
||||
</p>
|
||||
{companies.map((company) => (
|
||||
<section key={company.id} className={card}>
|
||||
<PartnershipSourceLinks type="company" id={company.id}/>
|
||||
<h3 className="text-xl font-bold">{company.payload.name}</h3>
|
||||
<PartnershipSourceLinks type="company" id={company.id} />
|
||||
<h3 className="text-xl font-bold">
|
||||
{company.payload.name}
|
||||
</h3>
|
||||
<Editor
|
||||
key={company.version}
|
||||
record={company}
|
||||
fields={[
|
||||
"name",
|
||||
"country",
|
||||
"registration",
|
||||
"sector",
|
||||
"role",
|
||||
"description",
|
||||
'name',
|
||||
'country',
|
||||
'registration',
|
||||
'sector',
|
||||
'role',
|
||||
'description',
|
||||
]}
|
||||
/>
|
||||
<button
|
||||
className={button + " mt-4"}
|
||||
className={button + ' mt-4'}
|
||||
onClick={() =>
|
||||
router.post("/investidor/manifestacoes", { company_id: company.id })
|
||||
router.post('/investidor/manifestacoes', {
|
||||
company_id: company.id,
|
||||
})
|
||||
}
|
||||
>
|
||||
Preparar manifestação desta empresa
|
||||
@@ -76,16 +87,16 @@ export default function Profile({
|
||||
<section className={card}>
|
||||
<h3 className="text-xl font-bold">Acrescentar empresa</h3>
|
||||
<Editor
|
||||
key={"new-" + companies.length}
|
||||
key={'new-' + companies.length}
|
||||
record={{ version: 0, payload: {} }}
|
||||
company
|
||||
fields={[
|
||||
"name",
|
||||
"country",
|
||||
"registration",
|
||||
"sector",
|
||||
"role",
|
||||
"description",
|
||||
'name',
|
||||
'country',
|
||||
'registration',
|
||||
'sector',
|
||||
'role',
|
||||
'description',
|
||||
]}
|
||||
/>
|
||||
</section>
|
||||
@@ -105,7 +116,9 @@ function Editor({
|
||||
const isCompany = company || !!record.id;
|
||||
const form = useForm({
|
||||
version: record.version,
|
||||
payload: Object.fromEntries(fields.map((key) => [key, record.payload[key] ?? ""])),
|
||||
payload: Object.fromEntries(
|
||||
fields.map((key) => [key, record.payload[key] ?? '']),
|
||||
),
|
||||
});
|
||||
return (
|
||||
<form
|
||||
@@ -115,10 +128,11 @@ function Editor({
|
||||
const options = { preserveScroll: true };
|
||||
if (isCompany)
|
||||
form.post(
|
||||
"/investidor/companies" + (record.id ? "/" + record.id : ""),
|
||||
'/investidor/companies' +
|
||||
(record.id ? '/' + record.id : ''),
|
||||
options,
|
||||
);
|
||||
else form.put("/investidor/profile", options);
|
||||
else form.put('/investidor/profile', options);
|
||||
}}
|
||||
>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
@@ -127,16 +141,19 @@ function Editor({
|
||||
<input
|
||||
className={input}
|
||||
value={form.data.payload[key]}
|
||||
required={isCompany && ["name", "country", "role"].includes(key)}
|
||||
required={
|
||||
isCompany &&
|
||||
['name', 'country', 'role'].includes(key)
|
||||
}
|
||||
maxLength={
|
||||
key === "description" || key === "experience"
|
||||
key === 'description' || key === 'experience'
|
||||
? 2000
|
||||
: key === "investment_capacity"
|
||||
: key === 'investment_capacity'
|
||||
? 1000
|
||||
: 200
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData("payload", {
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
@@ -151,7 +168,9 @@ function Editor({
|
||||
</p>
|
||||
))}
|
||||
<button className={button} disabled={form.processing}>
|
||||
{isCompany ? "Guardar declaração da empresa" : "Guardar perfil de investimento"}
|
||||
{isCompany
|
||||
? 'Guardar declaração da empresa'
|
||||
: 'Guardar perfil de investimento'}
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user