@@ -126,6 +126,8 @@ export default function PeopleIndex({
|
||||
insights,
|
||||
filters = {},
|
||||
company,
|
||||
clientMode = false,
|
||||
clients = [],
|
||||
}: {
|
||||
ready: boolean;
|
||||
availableKinds?: string[];
|
||||
@@ -133,6 +135,8 @@ export default function PeopleIndex({
|
||||
insights?: OperationalInsights | null;
|
||||
filters?: Filters;
|
||||
company?: { name: string };
|
||||
clientMode?: boolean;
|
||||
clients?: { id: number; code: string; name: string; version: number }[];
|
||||
administration?: { id: number; kind: string; status: string }[];
|
||||
formFields?: Record<string, Record<string, string>>;
|
||||
kinds: string[];
|
||||
@@ -144,12 +148,15 @@ export default function PeopleIndex({
|
||||
kind: string;
|
||||
status: string;
|
||||
closes_on: string;
|
||||
client?: { code: string; name: string };
|
||||
}[];
|
||||
links: { url: string | null; label: string; active: boolean }[];
|
||||
};
|
||||
}) {
|
||||
const form = useForm({
|
||||
operation_key: crypto.randomUUID(),
|
||||
client_id: '',
|
||||
client_version: '',
|
||||
kind:
|
||||
filters.kind && canPrepare.includes(filters.kind)
|
||||
? filters.kind
|
||||
@@ -182,8 +189,16 @@ export default function PeopleIndex({
|
||||
<div className="mx-auto max-w-6xl space-y-6 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow="Organização"
|
||||
title="Pessoas e contratações"
|
||||
description="Contratação de prestadores individuais e recrutamento de trabalhadores, com critérios próprios e decisão independente."
|
||||
title={
|
||||
clientMode
|
||||
? 'Contratações para clientes'
|
||||
: 'Pessoas e contratações'
|
||||
}
|
||||
description={
|
||||
clientMode
|
||||
? 'Processos da entidade cliente, conduzidos pela prestadora. A decisão final e a confirmação do contrato competem à Direcção da prestadora.'
|
||||
: 'Contratação de prestadores individuais e recrutamento de trabalhadores, com critérios próprios e decisão independente.'
|
||||
}
|
||||
action={
|
||||
ready ? (
|
||||
<ActionBar>
|
||||
@@ -440,6 +455,12 @@ export default function PeopleIndex({
|
||||
<strong>
|
||||
PES-{p.id} · {p.title}
|
||||
</strong>
|
||||
{p.client && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Cliente: {p.client.code} ·{' '}
|
||||
{p.client.name}
|
||||
</p>
|
||||
)}
|
||||
<p>
|
||||
{kinds[p.kind]} ·{' '}
|
||||
{peopleStates[p.status] ?? p.status}{' '}
|
||||
@@ -485,7 +506,16 @@ export default function PeopleIndex({
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.transform((values) => ({
|
||||
...values,
|
||||
...Object.fromEntries(
|
||||
Object.entries(values).filter(
|
||||
([key]) =>
|
||||
clientMode ||
|
||||
![
|
||||
'client_id',
|
||||
'client_version',
|
||||
].includes(key),
|
||||
),
|
||||
),
|
||||
annex: {
|
||||
...values.annex,
|
||||
fields: Object.fromEntries(
|
||||
@@ -503,11 +533,93 @@ export default function PeopleIndex({
|
||||
},
|
||||
}));
|
||||
form.post('/pessoas', {
|
||||
onSuccess: () => form.reset(),
|
||||
onSuccess: () => {
|
||||
form.reset();
|
||||
form.setData(
|
||||
'operation_key',
|
||||
crypto.randomUUID(),
|
||||
);
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
{clientMode && (
|
||||
<div className="space-y-2 rounded-lg border p-4">
|
||||
<label
|
||||
className="grid gap-1"
|
||||
htmlFor="people-client"
|
||||
>
|
||||
Entidade cliente
|
||||
<select
|
||||
id="people-client"
|
||||
name="client_id"
|
||||
className={controlClass}
|
||||
value={form.data.client_id}
|
||||
required
|
||||
onChange={(event) => {
|
||||
const client =
|
||||
clients.find(
|
||||
(row) =>
|
||||
String(
|
||||
row.id,
|
||||
) ===
|
||||
event.target
|
||||
.value,
|
||||
);
|
||||
form.setData(
|
||||
(values) => ({
|
||||
...values,
|
||||
client_id:
|
||||
event.target
|
||||
.value,
|
||||
client_version:
|
||||
client
|
||||
? String(
|
||||
client.version,
|
||||
)
|
||||
: '',
|
||||
}),
|
||||
);
|
||||
}}
|
||||
>
|
||||
<option value="">
|
||||
Escolher cliente
|
||||
</option>
|
||||
{clients.map((client) => (
|
||||
<option
|
||||
key={client.id}
|
||||
value={client.id}
|
||||
>
|
||||
{client.code} ·{' '}
|
||||
{client.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
A identificação do cliente fica
|
||||
preservada neste processo.{' '}
|
||||
<Link
|
||||
href="/empresa/clientes"
|
||||
className="underline"
|
||||
>
|
||||
Consultar cadastro de
|
||||
clientes
|
||||
</Link>
|
||||
</p>
|
||||
{clients.length === 0 && (
|
||||
<p
|
||||
role="status"
|
||||
className="text-sm"
|
||||
>
|
||||
Registe ou active um cliente
|
||||
no cadastro antes de
|
||||
preparar o processo.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<label className="block">
|
||||
Percurso
|
||||
<select
|
||||
|
||||
Reference in New Issue
Block a user