@@ -1,9 +1,9 @@
|
||||
import { Link, useForm } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Frame, Field, input, button, card } from "./shared";
|
||||
import type { References } from "./shared";
|
||||
import { Conversation } from "./conversation";
|
||||
import type { Message } from "./conversation";
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import { Frame, Field, input, button, card } from './shared';
|
||||
import type { References } from './shared';
|
||||
import { Conversation } from './conversation';
|
||||
import type { Message } from './conversation';
|
||||
type Payload = {
|
||||
full_name: string;
|
||||
email: string;
|
||||
@@ -54,9 +54,14 @@ type Props = {
|
||||
zone_origin?: {
|
||||
zone_id: string;
|
||||
zone_version: number;
|
||||
intent: "interest" | "dossier" | "meeting";
|
||||
intent: 'interest' | 'dossier' | 'meeting';
|
||||
} | null;
|
||||
submission: { id: string; version: number; payload: Partial<Payload>; status: string };
|
||||
submission: {
|
||||
id: string;
|
||||
version: number;
|
||||
payload: Partial<Payload>;
|
||||
status: string;
|
||||
};
|
||||
references: References;
|
||||
needs: Need[];
|
||||
attachments: { id: string; file_name: string }[];
|
||||
@@ -68,30 +73,37 @@ type Props = {
|
||||
revisions: { version: number; created_at: string }[];
|
||||
};
|
||||
const emptyNeed = (): Need => ({
|
||||
category_id: "",
|
||||
option_id: "",
|
||||
unit_id: "",
|
||||
priority_id: "",
|
||||
quantity: "",
|
||||
deadline: "",
|
||||
category_id: '',
|
||||
option_id: '',
|
||||
unit_id: '',
|
||||
priority_id: '',
|
||||
quantity: '',
|
||||
deadline: '',
|
||||
details: {
|
||||
description: "",
|
||||
location: "",
|
||||
observations: "",
|
||||
qualification: "",
|
||||
specialty: "",
|
||||
experience: "",
|
||||
certifications: "",
|
||||
availability: "",
|
||||
institution: "",
|
||||
training_mode: "",
|
||||
duration: "",
|
||||
status: "",
|
||||
description: '',
|
||||
location: '',
|
||||
observations: '',
|
||||
qualification: '',
|
||||
specialty: '',
|
||||
experience: '',
|
||||
certifications: '',
|
||||
availability: '',
|
||||
institution: '',
|
||||
training_mode: '',
|
||||
duration: '',
|
||||
status: '',
|
||||
},
|
||||
});
|
||||
export default function Submission(props: Props) {
|
||||
const [step, setStep] = useState(0);
|
||||
return <Editor key={props.submission.version} {...props} step={step} setStep={setStep} />;
|
||||
return (
|
||||
<Editor
|
||||
key={props.submission.version}
|
||||
{...props}
|
||||
step={step}
|
||||
setStep={setStep}
|
||||
/>
|
||||
);
|
||||
}
|
||||
function Editor({
|
||||
zone_origin,
|
||||
@@ -109,24 +121,24 @@ function Editor({
|
||||
setStep,
|
||||
}: Props & { step: number; setStep: (step: number) => void }) {
|
||||
const initial: Payload = {
|
||||
full_name: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
country: "",
|
||||
organisation: "",
|
||||
representative_role: "",
|
||||
experience: "",
|
||||
investment_capacity: "",
|
||||
other_details: "",
|
||||
profile_id: "",
|
||||
sector: "",
|
||||
objective: "",
|
||||
participation_id: "",
|
||||
partnership_id: "",
|
||||
estimated_amount: "",
|
||||
currency: "",
|
||||
horizon: "",
|
||||
location: "",
|
||||
full_name: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
country: '',
|
||||
organisation: '',
|
||||
representative_role: '',
|
||||
experience: '',
|
||||
investment_capacity: '',
|
||||
other_details: '',
|
||||
profile_id: '',
|
||||
sector: '',
|
||||
objective: '',
|
||||
participation_id: '',
|
||||
partnership_id: '',
|
||||
estimated_amount: '',
|
||||
currency: '',
|
||||
horizon: '',
|
||||
location: '',
|
||||
cluster_ids: [],
|
||||
corridor_ids: [],
|
||||
project_ids: [],
|
||||
@@ -141,13 +153,13 @@ function Editor({
|
||||
...Object.fromEntries(
|
||||
Object.entries(n).filter(([k]) =>
|
||||
[
|
||||
"category_id",
|
||||
"option_id",
|
||||
"unit_id",
|
||||
"priority_id",
|
||||
"quantity",
|
||||
"deadline",
|
||||
"details",
|
||||
'category_id',
|
||||
'option_id',
|
||||
'unit_id',
|
||||
'priority_id',
|
||||
'quantity',
|
||||
'deadline',
|
||||
'details',
|
||||
].includes(k),
|
||||
),
|
||||
),
|
||||
@@ -158,12 +170,17 @@ function Editor({
|
||||
version: s.version,
|
||||
file: null,
|
||||
});
|
||||
const [note, setNote] = useState("");
|
||||
const readonly = s.status !== "draft" || management;
|
||||
const base = "/investidor/manifestacoes/" + s.id;
|
||||
const [note, setNote] = useState('');
|
||||
const readonly = s.status !== 'draft' || management;
|
||||
const base = '/investidor/manifestacoes/' + s.id;
|
||||
const update = <K extends keyof Payload>(key: K, value: Payload[K]) =>
|
||||
form.setData("payload", { ...form.data.payload, [key]: value });
|
||||
const text = (key: keyof Payload, label: string, required = false, type = "text") => (
|
||||
form.setData('payload', { ...form.data.payload, [key]: value });
|
||||
const text = (
|
||||
key: keyof Payload,
|
||||
label: string,
|
||||
required = false,
|
||||
type = 'text',
|
||||
) => (
|
||||
<Field label={label}>
|
||||
<input
|
||||
className={input}
|
||||
@@ -171,21 +188,29 @@ function Editor({
|
||||
required={required}
|
||||
disabled={readonly}
|
||||
name={key}
|
||||
min={type === "number" ? 0 : undefined}
|
||||
minLength={key === "objective" ? 20 : key === "full_name" ? 3 : undefined}
|
||||
min={type === 'number' ? 0 : undefined}
|
||||
minLength={
|
||||
key === 'objective'
|
||||
? 20
|
||||
: key === 'full_name'
|
||||
? 3
|
||||
: undefined
|
||||
}
|
||||
onBlur={(e) => {
|
||||
if (!e.target.validity.valid)
|
||||
setNote(`Verifique o campo ${label}: ${e.target.validationMessage}`);
|
||||
else setNote("");
|
||||
setNote(
|
||||
`Verifique o campo ${label}: ${e.target.validationMessage}`,
|
||||
);
|
||||
else setNote('');
|
||||
}}
|
||||
value={String(form.data.payload[key] ?? "")}
|
||||
value={String(form.data.payload[key] ?? '')}
|
||||
onChange={(e) => update(key, e.target.value as never)}
|
||||
maxLength={key === "objective" ? 5000 : 2000}
|
||||
maxLength={key === 'objective' ? 5000 : 2000}
|
||||
/>
|
||||
</Field>
|
||||
);
|
||||
const option = (
|
||||
key: "profile_id" | "participation_id" | "partnership_id",
|
||||
key: 'profile_id' | 'participation_id' | 'partnership_id',
|
||||
group: string,
|
||||
label: string,
|
||||
) => (
|
||||
@@ -193,7 +218,7 @@ function Editor({
|
||||
<select
|
||||
className={input}
|
||||
disabled={readonly}
|
||||
value={form.data.payload[key] ?? ""}
|
||||
value={form.data.payload[key] ?? ''}
|
||||
onChange={(e) => update(key, e.target.value)}
|
||||
>
|
||||
<option value="">Seleccionar</option>
|
||||
@@ -201,12 +226,14 @@ function Editor({
|
||||
.filter(
|
||||
(o) =>
|
||||
o.group === group &&
|
||||
(o.active || String(o.id) === String(form.data.payload[key])),
|
||||
(o.active ||
|
||||
String(o.id) ===
|
||||
String(form.data.payload[key])),
|
||||
)
|
||||
.map((o) => (
|
||||
<option value={o.id} key={o.id} disabled={!o.active}>
|
||||
{o.label}
|
||||
{!o.active ? " (inactiva)" : ""}
|
||||
{!o.active ? ' (inactiva)' : ''}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -214,81 +241,104 @@ function Editor({
|
||||
);
|
||||
const updateNeed = (index: number, value: Need) =>
|
||||
form.setData(
|
||||
"needs",
|
||||
'needs',
|
||||
form.data.needs.map((n, i) => (i === index ? value : n)),
|
||||
);
|
||||
const errorStep = (key: string) =>
|
||||
key.startsWith("needs.")
|
||||
key.startsWith('needs.')
|
||||
? 2
|
||||
: /payload\.(full_name|email|phone|country|profile_id|organisation|representative_role|sector|experience|investment_capacity)/.test(
|
||||
key,
|
||||
)
|
||||
? 0
|
||||
: key === "payload.contact_consent"
|
||||
: key === 'payload.contact_consent'
|
||||
? 4
|
||||
: 1;
|
||||
return (
|
||||
<Frame
|
||||
title={
|
||||
receipt ? "Manifestação " + receipt.reference : "Preparar manifestação de interesse"
|
||||
receipt
|
||||
? 'Manifestação ' + receipt.reference
|
||||
: 'Preparar manifestação de interesse'
|
||||
}
|
||||
>
|
||||
<p>
|
||||
{target ??
|
||||
(zone_origin
|
||||
? "Pedido relativo a zona de investimento"
|
||||
: "Interesse geral")}{" "}
|
||||
· Versão {s.version} · {s.status === "draft" ? "Rascunho privado" : "Submetido"}
|
||||
? 'Pedido relativo a zona de investimento'
|
||||
: 'Interesse geral')}{' '}
|
||||
· Versão {s.version} ·{' '}
|
||||
{s.status === 'draft' ? 'Rascunho privado' : 'Submetido'}
|
||||
</p>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/balcao-virtual/painel?submission_id=${s.id}`}
|
||||
>
|
||||
Preparar apoio e acompanhamento deste projecto no Balcão Virtual
|
||||
</Link>
|
||||
{zone_origin && (
|
||||
<p className={card}>
|
||||
<Link className="underline" href={`/zonas/${zone_origin.zone_id}`}>
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/zonas/${zone_origin.zone_id}`}
|
||||
>
|
||||
Consultar zona de origem
|
||||
</Link>{" "}
|
||||
· Versão da ficha {zone_origin.zone_version} ·{" "}
|
||||
</Link>{' '}
|
||||
· Versão da ficha {zone_origin.zone_version} ·{' '}
|
||||
{
|
||||
{
|
||||
interest: "Manifestação de interesse",
|
||||
dossier: "Pedido de dossier",
|
||||
meeting: "Pedido de reunião",
|
||||
interest: 'Manifestação de interesse',
|
||||
dossier: 'Pedido de dossier',
|
||||
meeting: 'Pedido de reunião',
|
||||
}[zone_origin.intent]
|
||||
}
|
||||
. Atendimento assistido, sem decisão administrativa automática.
|
||||
. Atendimento assistido, sem decisão administrativa
|
||||
automática.
|
||||
</p>
|
||||
)}
|
||||
{receipt && (
|
||||
<p role="status" className={card}>
|
||||
Protocolo: <strong>{receipt.reference}</strong> · Estado:{" "}
|
||||
Protocolo: <strong>{receipt.reference}</strong> · Estado:{' '}
|
||||
{(
|
||||
{
|
||||
received: "Recebido",
|
||||
in_review: "Em análise",
|
||||
contacted: "Contactado",
|
||||
closed: "Encerrado",
|
||||
received: 'Recebido',
|
||||
in_review: 'Em análise',
|
||||
contacted: 'Contactado',
|
||||
closed: 'Encerrado',
|
||||
} as Record<string, string>
|
||||
)[receipt.status] ?? receipt.status}
|
||||
</p>
|
||||
)}
|
||||
<nav aria-label="Etapas da manifestação" className="flex flex-wrap gap-2">
|
||||
{["Identificação", "Investimento", "Necessidades", "Anexos", "Rever e enviar"].map(
|
||||
(label, i) => (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
aria-current={step === i ? "step" : undefined}
|
||||
className={step === i ? button : "rounded border px-4 py-2"}
|
||||
onClick={() => setStep(i)}
|
||||
>
|
||||
{i + 1}. {label}
|
||||
</button>
|
||||
),
|
||||
)}
|
||||
<nav
|
||||
aria-label="Etapas da manifestação"
|
||||
className="flex flex-wrap gap-2"
|
||||
>
|
||||
{[
|
||||
'Identificação',
|
||||
'Investimento',
|
||||
'Necessidades',
|
||||
'Anexos',
|
||||
'Rever e enviar',
|
||||
].map((label, i) => (
|
||||
<button
|
||||
key={label}
|
||||
type="button"
|
||||
aria-current={step === i ? 'step' : undefined}
|
||||
className={
|
||||
step === i ? button : 'rounded border px-4 py-2'
|
||||
}
|
||||
onClick={() => setStep(i)}
|
||||
>
|
||||
{i + 1}. {label}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
<p className="text-sm">
|
||||
Etapa {step + 1} de 5. Guarde antes de sair. A informação declarada não é publicada.
|
||||
Etapa {step + 1} de 5. Guarde antes de sair. A informação
|
||||
declarada não é publicada.
|
||||
</p>
|
||||
<form
|
||||
className={card + " space-y-5"}
|
||||
className={card + ' space-y-5'}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.put(base, { preserveScroll: true });
|
||||
@@ -296,44 +346,63 @@ function Editor({
|
||||
>
|
||||
{step === 0 && (
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{text("full_name", "Nome completo", true)}
|
||||
{text("email", "Email", true, "email")}
|
||||
{text("phone", "Telefone")}
|
||||
{text("country", "País", true)}
|
||||
{option("profile_id", "investor_profile", "Perfil do investidor")}
|
||||
{text("organisation", "Organização / empresa")}
|
||||
{text("representative_role", "Função do representante")}
|
||||
{text("sector", "Sector de interesse", true)}
|
||||
{text("experience", "Experiência relevante")}
|
||||
{text('full_name', 'Nome completo', true)}
|
||||
{text('email', 'Email', true, 'email')}
|
||||
{text('phone', 'Telefone')}
|
||||
{text('country', 'País', true)}
|
||||
{option(
|
||||
'profile_id',
|
||||
'investor_profile',
|
||||
'Perfil do investidor',
|
||||
)}
|
||||
{text('organisation', 'Organização / empresa')}
|
||||
{text('representative_role', 'Função do representante')}
|
||||
{text('sector', 'Sector de interesse', true)}
|
||||
{text('experience', 'Experiência relevante')}
|
||||
{text(
|
||||
"investment_capacity",
|
||||
"Capacidade de investimento / especificação do perfil",
|
||||
'investment_capacity',
|
||||
'Capacidade de investimento / especificação do perfil',
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{step === 1 && (
|
||||
<div className="space-y-5">
|
||||
{text(
|
||||
"objective",
|
||||
"Objectivo do investimento (mínimo 20 caracteres)",
|
||||
'objective',
|
||||
'Objectivo do investimento (mínimo 20 caracteres)',
|
||||
true,
|
||||
)}
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{option(
|
||||
"participation_id",
|
||||
"participation",
|
||||
"Modalidade de participação",
|
||||
'participation_id',
|
||||
'participation',
|
||||
'Modalidade de participação',
|
||||
)}
|
||||
{option("partnership_id", "partnership", "Modelo de parceria")}
|
||||
{text("estimated_amount", "Investimento estimado", false, "number")}
|
||||
{text("currency", "Moeda (código de três letras)")}
|
||||
{text("horizon", "Prazo / horizonte", true)}
|
||||
{text("location", "Localização pretendida")}
|
||||
{option(
|
||||
'partnership_id',
|
||||
'partnership',
|
||||
'Modelo de parceria',
|
||||
)}
|
||||
{text(
|
||||
'estimated_amount',
|
||||
'Investimento estimado',
|
||||
false,
|
||||
'number',
|
||||
)}
|
||||
{text('currency', 'Moeda (código de três letras)')}
|
||||
{text('horizon', 'Prazo / horizonte', true)}
|
||||
{text('location', 'Localização pretendida')}
|
||||
</div>
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
{(["clusters", "corridors", "projects"] as const).map((group, i) => {
|
||||
{(
|
||||
['clusters', 'corridors', 'projects'] as const
|
||||
).map((group, i) => {
|
||||
const key = (
|
||||
["cluster_ids", "corridor_ids", "project_ids"] as const
|
||||
[
|
||||
'cluster_ids',
|
||||
'corridor_ids',
|
||||
'project_ids',
|
||||
] as const
|
||||
)[i];
|
||||
return (
|
||||
<fieldset
|
||||
@@ -341,27 +410,45 @@ function Editor({
|
||||
key={group}
|
||||
>
|
||||
<legend>
|
||||
{["Clusters", "Corredores", "Projectos âncora"][i]}
|
||||
{
|
||||
[
|
||||
'Clusters',
|
||||
'Corredores',
|
||||
'Projectos âncora',
|
||||
][i]
|
||||
}
|
||||
</legend>
|
||||
{r[group].map((entity) => (
|
||||
<label key={entity.id} className="flex gap-2">
|
||||
<label
|
||||
key={entity.id}
|
||||
className="flex gap-2"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
disabled={readonly}
|
||||
checked={(
|
||||
form.data.payload[key] ?? []
|
||||
form.data.payload[
|
||||
key
|
||||
] ?? []
|
||||
).includes(entity.id)}
|
||||
onChange={(e) =>
|
||||
update(
|
||||
key,
|
||||
e.target.checked
|
||||
? [
|
||||
...(form.data.payload[key] ??
|
||||
[]),
|
||||
...(form
|
||||
.data
|
||||
.payload[
|
||||
key
|
||||
] ?? []),
|
||||
entity.id,
|
||||
]
|
||||
: form.data.payload[key].filter(
|
||||
(id) => id !== entity.id,
|
||||
: form.data.payload[
|
||||
key
|
||||
].filter(
|
||||
(id) =>
|
||||
id !==
|
||||
entity.id,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -381,22 +468,30 @@ function Editor({
|
||||
Mão de obra, infraestruturas, formação e apoios
|
||||
</h2>
|
||||
<p>
|
||||
Acrescente o que existe no local e o que necessita. As opções são
|
||||
mantidas pela gestão; use Outro para especificar casos adicionais.
|
||||
Acrescente o que existe no local e o que necessita.
|
||||
As opções são mantidas pela gestão; use Outro para
|
||||
especificar casos adicionais.
|
||||
</p>
|
||||
{form.data.needs.map((need, index) => {
|
||||
const category =
|
||||
r.options.find((o) => String(o.id) === String(need.category_id))
|
||||
?.code ?? "";
|
||||
const group = category.startsWith("labour")
|
||||
? "labour"
|
||||
: category.startsWith("infrastructure")
|
||||
? "infrastructure"
|
||||
: category === "education"
|
||||
? "education"
|
||||
: "support";
|
||||
r.options.find(
|
||||
(o) =>
|
||||
String(o.id) ===
|
||||
String(need.category_id),
|
||||
)?.code ?? '';
|
||||
const group = category.startsWith('labour')
|
||||
? 'labour'
|
||||
: category.startsWith('infrastructure')
|
||||
? 'infrastructure'
|
||||
: category === 'education'
|
||||
? 'education'
|
||||
: 'support';
|
||||
const needSelect = (
|
||||
field: "category_id" | "option_id" | "unit_id" | "priority_id",
|
||||
field:
|
||||
| 'category_id'
|
||||
| 'option_id'
|
||||
| 'unit_id'
|
||||
| 'priority_id',
|
||||
optionGroup: string,
|
||||
label: string,
|
||||
) => (
|
||||
@@ -404,13 +499,13 @@ function Editor({
|
||||
<select
|
||||
className={input}
|
||||
disabled={readonly}
|
||||
value={need[field] ?? ""}
|
||||
value={need[field] ?? ''}
|
||||
onChange={(e) =>
|
||||
updateNeed(index, {
|
||||
...need,
|
||||
[field]: e.target.value,
|
||||
...(field === "category_id"
|
||||
? { option_id: "" }
|
||||
...(field === 'category_id'
|
||||
? { option_id: '' }
|
||||
: {}),
|
||||
})
|
||||
}
|
||||
@@ -421,7 +516,10 @@ function Editor({
|
||||
(o) =>
|
||||
o.group === optionGroup &&
|
||||
(o.active ||
|
||||
String(o.id) === String(need[field])),
|
||||
String(o.id) ===
|
||||
String(
|
||||
need[field],
|
||||
)),
|
||||
)
|
||||
.map((o) => (
|
||||
<option value={o.id} key={o.id}>
|
||||
@@ -432,13 +530,30 @@ function Editor({
|
||||
</Field>
|
||||
);
|
||||
return (
|
||||
<fieldset key={index} className="space-y-4 rounded-lg border p-4">
|
||||
<legend className="font-bold">Necessidade {index + 1}</legend>
|
||||
<fieldset
|
||||
key={index}
|
||||
className="space-y-4 rounded-lg border p-4"
|
||||
>
|
||||
<legend className="font-bold">
|
||||
Necessidade {index + 1}
|
||||
</legend>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{needSelect("category_id", "need_category", "Categoria")}
|
||||
{needSelect("option_id", group, "Tipo")}
|
||||
{needSelect("unit_id", "unit", "Unidade")}
|
||||
{needSelect("priority_id", "priority", "Prioridade")}
|
||||
{needSelect(
|
||||
'category_id',
|
||||
'need_category',
|
||||
'Categoria',
|
||||
)}
|
||||
{needSelect('option_id', group, 'Tipo')}
|
||||
{needSelect(
|
||||
'unit_id',
|
||||
'unit',
|
||||
'Unidade',
|
||||
)}
|
||||
{needSelect(
|
||||
'priority_id',
|
||||
'priority',
|
||||
'Prioridade',
|
||||
)}
|
||||
<Field label="Quantidade">
|
||||
<input
|
||||
className={input}
|
||||
@@ -446,11 +561,12 @@ function Editor({
|
||||
min="0"
|
||||
step="0.01"
|
||||
disabled={readonly}
|
||||
value={need.quantity ?? ""}
|
||||
value={need.quantity ?? ''}
|
||||
onChange={(e) =>
|
||||
updateNeed(index, {
|
||||
...need,
|
||||
quantity: e.target.value,
|
||||
quantity:
|
||||
e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
@@ -460,11 +576,12 @@ function Editor({
|
||||
className={input}
|
||||
type="date"
|
||||
disabled={readonly}
|
||||
value={need.deadline ?? ""}
|
||||
value={need.deadline ?? ''}
|
||||
onChange={(e) =>
|
||||
updateNeed(index, {
|
||||
...need,
|
||||
deadline: e.target.value,
|
||||
deadline:
|
||||
e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
@@ -472,48 +589,54 @@ function Editor({
|
||||
</div>
|
||||
{(
|
||||
[
|
||||
"description",
|
||||
"location",
|
||||
"observations",
|
||||
...(group === "labour"
|
||||
'description',
|
||||
'location',
|
||||
'observations',
|
||||
...(group === 'labour'
|
||||
? [
|
||||
"qualification",
|
||||
"specialty",
|
||||
"experience",
|
||||
"certifications",
|
||||
"availability",
|
||||
"institution",
|
||||
'qualification',
|
||||
'specialty',
|
||||
'experience',
|
||||
'certifications',
|
||||
'availability',
|
||||
'institution',
|
||||
]
|
||||
: []),
|
||||
...(group === "education"
|
||||
...(group === 'education'
|
||||
? [
|
||||
"qualification",
|
||||
"institution",
|
||||
"training_mode",
|
||||
"duration",
|
||||
"certifications",
|
||||
'qualification',
|
||||
'institution',
|
||||
'training_mode',
|
||||
'duration',
|
||||
'certifications',
|
||||
]
|
||||
: []),
|
||||
] as (keyof Need["details"])[]
|
||||
] as (keyof Need['details'])[]
|
||||
).map((field) => (
|
||||
<Field
|
||||
key={field}
|
||||
label={
|
||||
{
|
||||
description: "Descrição / especificação",
|
||||
location: "Localização",
|
||||
description:
|
||||
'Descrição / especificação',
|
||||
location: 'Localização',
|
||||
observations:
|
||||
"Observações e referência dos anexos de suporte",
|
||||
qualification: "Nível de qualificação",
|
||||
specialty: "Profissão / especialidade",
|
||||
experience: "Experiência",
|
||||
certifications: "Certificações",
|
||||
availability: "Disponibilidade",
|
||||
'Observações e referência dos anexos de suporte',
|
||||
qualification:
|
||||
'Nível de qualificação',
|
||||
specialty:
|
||||
'Profissão / especialidade',
|
||||
experience: 'Experiência',
|
||||
certifications:
|
||||
'Certificações',
|
||||
availability:
|
||||
'Disponibilidade',
|
||||
institution:
|
||||
"Instituições ou centros de formação",
|
||||
training_mode: "Modalidade de formação",
|
||||
duration: "Duração",
|
||||
status: "Estado",
|
||||
'Instituições ou centros de formação',
|
||||
training_mode:
|
||||
'Modalidade de formação',
|
||||
duration: 'Duração',
|
||||
status: 'Estado',
|
||||
}[field]
|
||||
}
|
||||
>
|
||||
@@ -521,13 +644,16 @@ function Editor({
|
||||
className={input}
|
||||
rows={2}
|
||||
disabled={readonly}
|
||||
value={need.details[field] ?? ""}
|
||||
value={
|
||||
need.details[field] ?? ''
|
||||
}
|
||||
onChange={(e) =>
|
||||
updateNeed(index, {
|
||||
...need,
|
||||
details: {
|
||||
...need.details,
|
||||
[field]: e.target.value,
|
||||
[field]:
|
||||
e.target.value,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -540,8 +666,10 @@ function Editor({
|
||||
className="underline"
|
||||
onClick={() =>
|
||||
form.setData(
|
||||
"needs",
|
||||
form.data.needs.filter((_, i) => i !== index),
|
||||
'needs',
|
||||
form.data.needs.filter(
|
||||
(_, i) => i !== index,
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
@@ -557,7 +685,10 @@ function Editor({
|
||||
className={button}
|
||||
disabled={form.data.needs.length >= 40}
|
||||
onClick={() =>
|
||||
form.setData("needs", [...form.data.needs, emptyNeed()])
|
||||
form.setData('needs', [
|
||||
...form.data.needs,
|
||||
emptyNeed(),
|
||||
])
|
||||
}
|
||||
>
|
||||
Acrescentar necessidade
|
||||
@@ -567,28 +698,33 @@ function Editor({
|
||||
)}
|
||||
{step === 3 && (
|
||||
<p>
|
||||
Guarde primeiro o rascunho e carregue os anexos no formulário abaixo.
|
||||
Identifique o nome do ficheiro nas observações da necessidade a que
|
||||
corresponde.
|
||||
Guarde primeiro o rascunho e carregue os anexos no
|
||||
formulário abaixo. Identifique o nome do ficheiro nas
|
||||
observações da necessidade a que corresponde.
|
||||
</p>
|
||||
)}
|
||||
{step === 4 && (
|
||||
<section className="space-y-5">
|
||||
<h2 className="text-xl font-bold">Rever antes de enviar</h2>
|
||||
<h2 className="text-xl font-bold">
|
||||
Rever antes de enviar
|
||||
</h2>
|
||||
<dl className="space-y-3">
|
||||
{[
|
||||
["Investidor", form.data.payload.full_name],
|
||||
["Email", form.data.payload.email],
|
||||
["Organização", form.data.payload.organisation],
|
||||
["Objectivo", form.data.payload.objective],
|
||||
["Prazo", form.data.payload.horizon],
|
||||
["Necessidades", String(form.data.needs.length)],
|
||||
["Anexos", String(attachments.length)],
|
||||
['Investidor', form.data.payload.full_name],
|
||||
['Email', form.data.payload.email],
|
||||
['Organização', form.data.payload.organisation],
|
||||
['Objectivo', form.data.payload.objective],
|
||||
['Prazo', form.data.payload.horizon],
|
||||
[
|
||||
'Necessidades',
|
||||
String(form.data.needs.length),
|
||||
],
|
||||
['Anexos', String(attachments.length)],
|
||||
].map(([label, value]) => (
|
||||
<div key={label}>
|
||||
<dt className="font-semibold">{label}</dt>
|
||||
<dd className="whitespace-pre-line">
|
||||
{value || "Não indicado"}
|
||||
{value || 'Não indicado'}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
@@ -598,11 +734,14 @@ function Editor({
|
||||
type="checkbox"
|
||||
disabled={readonly}
|
||||
checked={form.data.payload.contact_consent}
|
||||
onChange={(e) => update("contact_consent", e.target.checked)}
|
||||
onChange={(e) =>
|
||||
update('contact_consent', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Autorizo o tratamento destes dados e o contacto pela equipa para
|
||||
analisar e acompanhar esta manifestação. Os anexos são privados. Não
|
||||
constitui consentimento para utilização em IA.
|
||||
Autorizo o tratamento destes dados e o contacto pela
|
||||
equipa para analisar e acompanhar esta manifestação.
|
||||
Os anexos são privados. Não constitui consentimento
|
||||
para utilização em IA.
|
||||
</label>
|
||||
</section>
|
||||
)}
|
||||
@@ -618,8 +757,8 @@ function Editor({
|
||||
.includes(String(o.id)),
|
||||
) &&
|
||||
text(
|
||||
"other_details",
|
||||
"Outro — especifique o perfil, participação ou parceria seleccionados",
|
||||
'other_details',
|
||||
'Outro — especifique o perfil, participação ou parceria seleccionados',
|
||||
true,
|
||||
)}
|
||||
{Object.entries(form.errors).map(([key, value]) => (
|
||||
@@ -650,7 +789,7 @@ function Editor({
|
||||
type="button"
|
||||
className={button}
|
||||
onClick={() => {
|
||||
setNote("");
|
||||
setNote('');
|
||||
setStep(step + 1);
|
||||
}}
|
||||
>
|
||||
@@ -670,12 +809,19 @@ function Editor({
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={form.processing || !form.data.payload.contact_consent}
|
||||
disabled={
|
||||
form.processing ||
|
||||
!form.data.payload.contact_consent
|
||||
}
|
||||
onClick={() =>
|
||||
form.post(base + "/submit", {
|
||||
form.post(base + '/submit', {
|
||||
preserveScroll: true,
|
||||
onError: (errors) =>
|
||||
setStep(errorStep(Object.keys(errors)[0] ?? "")),
|
||||
setStep(
|
||||
errorStep(
|
||||
Object.keys(errors)[0] ?? '',
|
||||
),
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
@@ -685,15 +831,18 @@ function Editor({
|
||||
</div>
|
||||
</form>
|
||||
{step === 3 && (
|
||||
<section className={card + " space-y-4"}>
|
||||
<section className={card + ' space-y-4'}>
|
||||
<h2 className="text-xl font-bold">Anexos privados</h2>
|
||||
<p>
|
||||
PDF ou TXT, até 10 MiB cada, máximo de dez anexos. Guardar um anexo
|
||||
actualiza a versão do rascunho.
|
||||
PDF ou TXT, até 10 MiB cada, máximo de dez anexos.
|
||||
Guardar um anexo actualiza a versão do rascunho.
|
||||
</p>
|
||||
{attachments.map((a) => (
|
||||
<p key={a.id}>
|
||||
<a className="underline" href={base + "/attachments/" + a.id}>
|
||||
<a
|
||||
className="underline"
|
||||
href={base + '/attachments/' + a.id}
|
||||
>
|
||||
{a.file_name}
|
||||
</a>
|
||||
</p>
|
||||
@@ -705,11 +854,11 @@ function Editor({
|
||||
e.preventDefault();
|
||||
if (form.isDirty) {
|
||||
setNote(
|
||||
"Guarde as alterações do formulário antes de carregar o anexo.",
|
||||
'Guarde as alterações do formulário antes de carregar o anexo.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
upload.post(base + "/attachments", {
|
||||
upload.post(base + '/attachments', {
|
||||
forceFormData: true,
|
||||
preserveScroll: true,
|
||||
});
|
||||
@@ -721,16 +870,24 @@ function Editor({
|
||||
accept="application/pdf,text/plain"
|
||||
required
|
||||
onChange={(e) =>
|
||||
upload.setData("file", e.target.files?.[0] ?? null)
|
||||
upload.setData(
|
||||
'file',
|
||||
e.target.files?.[0] ?? null,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{Object.entries(upload.errors).map(([key, value]) => (
|
||||
<p role="alert" key={key}>
|
||||
{value}
|
||||
</p>
|
||||
))}
|
||||
<button className={button} disabled={upload.processing}>
|
||||
{Object.entries(upload.errors).map(
|
||||
([key, value]) => (
|
||||
<p role="alert" key={key}>
|
||||
{value}
|
||||
</p>
|
||||
),
|
||||
)}
|
||||
<button
|
||||
className={button}
|
||||
disabled={upload.processing}
|
||||
>
|
||||
Carregar anexo
|
||||
</button>
|
||||
</form>
|
||||
@@ -738,19 +895,21 @@ function Editor({
|
||||
</section>
|
||||
)}
|
||||
<details className={card}>
|
||||
<summary className="cursor-pointer font-bold">Histórico do pedido</summary>
|
||||
<summary className="cursor-pointer font-bold">
|
||||
Histórico do pedido
|
||||
</summary>
|
||||
<ol className="mt-3 space-y-2">
|
||||
{events.map((e, i) => (
|
||||
<li key={i}>
|
||||
{new Date(e.created_at).toLocaleString("pt-MZ")} —{" "}
|
||||
{new Date(e.created_at).toLocaleString('pt-MZ')} —{' '}
|
||||
{(
|
||||
{
|
||||
draft_created: "Rascunho criado",
|
||||
draft_saved: "Rascunho guardado",
|
||||
attachment_added: "Anexo acrescentado",
|
||||
submitted: "Submetido",
|
||||
draft_created: 'Rascunho criado',
|
||||
draft_saved: 'Rascunho guardado',
|
||||
attachment_added: 'Anexo acrescentado',
|
||||
submitted: 'Submetido',
|
||||
} as Record<string, string>
|
||||
)[e.action] ?? e.action}{" "}
|
||||
)[e.action] ?? e.action}{' '}
|
||||
· versão {e.version}
|
||||
</li>
|
||||
))}
|
||||
@@ -760,7 +919,7 @@ function Editor({
|
||||
id={s.id}
|
||||
messages={messages}
|
||||
revisions={revisions}
|
||||
submitted={s.status === "submitted"}
|
||||
submitted={s.status === 'submitted'}
|
||||
/>
|
||||
</Frame>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user