Receber documentos privados e locais de disponibilidade nas candidaturas
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-30 20:52:10 +02:00
parent 2134aa084b
commit bf84575d10
26 changed files with 2756 additions and 49 deletions
+114 -6
View File
@@ -24,7 +24,13 @@ export default function Opportunity({
version: number;
definition: {
fields: Field[];
documents: { key: string; label: string; required: boolean }[];
documents: {
key: string;
label: string;
required: boolean;
formats: string[];
max_kb: number;
}[];
};
};
};
@@ -35,11 +41,16 @@ export default function Opportunity({
phone?: string;
summary: string;
availability: Location;
additional_availability?: Location[];
};
};
email: string;
emailVerified: boolean;
}) {
const locations = [
profile.data.availability,
...(profile.data.additional_availability ?? []),
];
const source: Record<string, string | Location> = {
name: profile.data.name,
full_name: profile.data.name,
@@ -64,6 +75,7 @@ export default function Opportunity({
: '',
]),
) as Record<string, string | Location>,
documents: {} as Record<string, File>,
});
return (
<>
@@ -110,6 +122,80 @@ export default function Opportunity({
{field.label}
{field.required ? ' *' : ''}
</legend>
{field.key === 'availability_location' &&
locations.length > 1 && (
<label className="grid gap-2 sm:col-span-3">
Usar local guardado no perfil
<select
className={controlClass}
value={locations.findIndex(
(location) => {
const answer =
form.data.answers[
field.key
];
return (
typeof answer ===
'object' &&
(
[
'province',
'district',
'locality',
] as const
).every(
(part) =>
answer[
part
] ===
location[
part
],
)
);
},
)}
onChange={(e) => {
const location =
locations[
Number(
e.target.value,
)
];
if (location)
form.setData(
'answers',
{
...form.data
.answers,
[field.key]: {
...location,
},
},
);
}}
>
<option value={-1}>
Local preenchido nesta
candidatura
</option>
{locations.map(
(location, index) => (
<option
value={index}
key={index}
>
{location.province}{' '}
·{' '}
{location.district}{' '}
·{' '}
{location.locality}
</option>
),
)}
</select>
</label>
)}
{(
[
'province',
@@ -193,11 +279,33 @@ export default function Opportunity({
</label>
),
)}
{opportunity.form.definition.documents.length > 0 && (
<p>
O envio de anexos ainda está em desenvolvimento. Não
é possível entregar documentos neste formulário.
</p>
{opportunity.form.definition.documents.map((document) => (
<label key={document.key} className="grid gap-2">
{document.label}
{document.required ? ' *' : ''}
<span className="text-sm">
{document.formats.join(', ')} · até{' '}
{document.max_kb} KB
</span>
<input
type="file"
className={controlClass}
required={document.required}
accept={document.formats
.map((format) => `.${format}`)
.join(',')}
onChange={(e) => {
const next = { ...form.data.documents };
const file = e.target.files?.[0];
if (file) next[document.key] = file;
else delete next[document.key];
form.setData('documents', next);
}}
/>
</label>
))}
{form.progress && (
<p>Envio dos documentos: {form.progress.percentage}%</p>
)}
<Button
disabled={