@@ -0,0 +1,182 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
Panel,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
type Assignment = {
|
||||
user_id: number;
|
||||
scopes: string[];
|
||||
expires_at: string | null;
|
||||
};
|
||||
function Person({
|
||||
person,
|
||||
scopes,
|
||||
assigned,
|
||||
version,
|
||||
processId,
|
||||
}: {
|
||||
person: { id: number; name: string };
|
||||
scopes: Record<string, string>;
|
||||
assigned?: Assignment;
|
||||
version: number;
|
||||
processId: number;
|
||||
}) {
|
||||
const expiry = assigned?.expires_at
|
||||
? new Date(assigned.expires_at.replace(' ', 'T') + 'Z')
|
||||
: null;
|
||||
const localExpiry = expiry
|
||||
? new Date(expiry.getTime() - expiry.getTimezoneOffset() * 60000)
|
||||
.toISOString()
|
||||
.slice(0, 16)
|
||||
: '';
|
||||
const form = useForm({
|
||||
version,
|
||||
user_id: person.id,
|
||||
scopes: assigned?.scopes ?? [],
|
||||
expires_at: localExpiry,
|
||||
reason: '',
|
||||
});
|
||||
return (
|
||||
<details className="rounded-lg border p-4">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
{person.name} · {assigned?.scopes.length ?? 0} atribuição(ões)
|
||||
</summary>
|
||||
<form
|
||||
className="mt-4 space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
expires_at: data.expires_at
|
||||
? new Date(data.expires_at).toISOString()
|
||||
: null,
|
||||
}));
|
||||
form.post(`/pessoas/${processId}/acessos`, {
|
||||
preserveState: 'errors',
|
||||
preserveScroll: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{Object.entries(scopes).map(([key, label]) => (
|
||||
<label className="flex gap-3" key={key}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.scopes.includes(key)}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'scopes',
|
||||
e.target.checked
|
||||
? [...form.data.scopes, key]
|
||||
: form.data.scopes.filter(
|
||||
(s) => s !== key,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
{label}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<label className="block">
|
||||
Validade até (opcional)
|
||||
<input
|
||||
className={controlClass}
|
||||
type="datetime-local"
|
||||
value={form.data.expires_at}
|
||||
onChange={(e) =>
|
||||
form.setData('expires_at', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Motivo
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={4000}
|
||||
value={form.data.reason}
|
||||
onChange={(e) => form.setData('reason', e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<p className="text-sm">
|
||||
Retirar todas as opções revoga o acesso. Seleccionar uma
|
||||
intervenção inclui a consulta do processo; dados
|
||||
financeiros, entrevistas e minuta têm permissões próprias. A
|
||||
atribuição não elimina as regras de independência.
|
||||
</p>
|
||||
<Button disabled={form.processing}>Guardar atribuição</Button>
|
||||
</form>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
export default function Access({
|
||||
process,
|
||||
version,
|
||||
scopes,
|
||||
users,
|
||||
assignments,
|
||||
canView,
|
||||
}: {
|
||||
process: { id: number; kind: string; status: string };
|
||||
version: number;
|
||||
scopes: Record<string, string>;
|
||||
users: { id: number; name: string }[];
|
||||
assignments: Assignment[];
|
||||
canView: boolean;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Head title="Equipa do processo" />
|
||||
<div className="mx-auto max-w-5xl space-y-6 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow={
|
||||
process.kind === 'staff'
|
||||
? 'Recrutamento'
|
||||
: 'Serviços individuais'
|
||||
}
|
||||
title={`Equipa do processo #${process.id}`}
|
||||
description="Configurar a equipa não concede acesso automático a candidaturas, entrevistas ou condições financeiras."
|
||||
/>
|
||||
<Link href="/pessoas" className="underline">
|
||||
Voltar a Pessoas e contratações
|
||||
</Link>
|
||||
{canView && (
|
||||
<Link
|
||||
href={`/pessoas/${process.id}`}
|
||||
className="ml-4 underline"
|
||||
>
|
||||
Consultar processo
|
||||
</Link>
|
||||
)}
|
||||
<Panel title="Atribuições nominativas">
|
||||
<p className="mb-4 text-sm">
|
||||
Escolha pessoas com perfil compatível na parametrização
|
||||
da empresa. Separe preparação, avaliação e decisão.
|
||||
Versão {version}.
|
||||
</p>
|
||||
<div className="space-y-3">
|
||||
{users.map((person) => (
|
||||
<Person
|
||||
key={`${person.id}-${version}`}
|
||||
person={person}
|
||||
scopes={scopes}
|
||||
assigned={assignments.find(
|
||||
(a) => a.user_id === person.id,
|
||||
)}
|
||||
version={version}
|
||||
processId={process.id}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Panel>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,938 @@
|
||||
import { Head, Link, router, useForm } from '@inertiajs/react';
|
||||
import {
|
||||
PageTitle,
|
||||
Panel,
|
||||
FormErrors,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { peopleStates } from '@/lib/people-hiring';
|
||||
import { PeopleOperationalInsights } from '@/components/people-operational-insights';
|
||||
import type { OperationalInsights } from '@/components/people-operational-insights';
|
||||
|
||||
const kinds: Record<string, string> = {
|
||||
service: 'Prestador individual',
|
||||
staff: 'Trabalhador para o quadro',
|
||||
};
|
||||
type WorkItem = {
|
||||
id: string;
|
||||
process_id: number;
|
||||
reference: string;
|
||||
title: string;
|
||||
kind: string;
|
||||
status: string;
|
||||
action: string;
|
||||
label: string;
|
||||
due_on: string | null;
|
||||
href: string;
|
||||
};
|
||||
type Workdesk = {
|
||||
updated_at: string;
|
||||
counts: Record<
|
||||
| 'processes'
|
||||
| 'active'
|
||||
| 'contract_drafts'
|
||||
| 'tasks'
|
||||
| 'approvals'
|
||||
| 'overdue',
|
||||
number
|
||||
>;
|
||||
tasks: WorkItem[];
|
||||
approvals: WorkItem[];
|
||||
alerts: {
|
||||
id?: string;
|
||||
process_id: number;
|
||||
title: string;
|
||||
label: string;
|
||||
due_on: string;
|
||||
href: string;
|
||||
}[];
|
||||
};
|
||||
type Filters = {
|
||||
kind?: string;
|
||||
search?: string;
|
||||
status?: string;
|
||||
from?: string;
|
||||
to?: string;
|
||||
};
|
||||
function Queue({
|
||||
id,
|
||||
title,
|
||||
items,
|
||||
empty,
|
||||
}: {
|
||||
id: string;
|
||||
title: string;
|
||||
items: WorkItem[];
|
||||
empty: string;
|
||||
}) {
|
||||
return (
|
||||
<div id={id} className="scroll-mt-24">
|
||||
<Panel title={title}>
|
||||
{items.length ? (
|
||||
<div className="overflow-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="p-2">Acção pendente</th>
|
||||
<th className="p-2">Processo</th>
|
||||
<th className="p-2">Percurso e estado</th>
|
||||
<th className="p-2">Prazo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{items.map((item) => (
|
||||
<tr key={item.id} className="border-t">
|
||||
<td className="p-2">
|
||||
<Link
|
||||
className="font-medium underline"
|
||||
href={item.href}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="p-2">
|
||||
{item.reference} · {item.title}
|
||||
</td>
|
||||
<td className="p-2">
|
||||
{kinds[item.kind]} ·{' '}
|
||||
{peopleStates[item.status]}
|
||||
</td>
|
||||
<td className="p-2">
|
||||
{item.due_on ?? 'Não definido'}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
) : (
|
||||
<p>{empty}</p>
|
||||
)}
|
||||
</Panel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default function PeopleIndex({
|
||||
ready,
|
||||
kinds: allowed,
|
||||
canPrepare,
|
||||
processes,
|
||||
administration = [],
|
||||
formFields = {},
|
||||
availableKinds = allowed,
|
||||
workdesk,
|
||||
insights,
|
||||
filters = {},
|
||||
company,
|
||||
}: {
|
||||
ready: boolean;
|
||||
availableKinds?: string[];
|
||||
workdesk?: Workdesk | null;
|
||||
insights?: OperationalInsights | null;
|
||||
filters?: Filters;
|
||||
company?: { name: string };
|
||||
administration?: { id: number; kind: string; status: string }[];
|
||||
formFields?: Record<string, Record<string, string>>;
|
||||
kinds: string[];
|
||||
canPrepare: string[];
|
||||
processes: null | {
|
||||
data: {
|
||||
id: number;
|
||||
title: string;
|
||||
kind: string;
|
||||
status: string;
|
||||
closes_on: string;
|
||||
}[];
|
||||
links: { url: string | null; label: string; active: boolean }[];
|
||||
};
|
||||
}) {
|
||||
const form = useForm({
|
||||
operation_key: crypto.randomUUID(),
|
||||
kind:
|
||||
filters.kind && canPrepare.includes(filters.kind)
|
||||
? filters.kind
|
||||
: (canPrepare[0] ?? allowed[0]),
|
||||
title: '',
|
||||
purpose: '',
|
||||
closes_on: '',
|
||||
minimum_reviews: '1',
|
||||
criteria: [{ label: '', weight: '100' }],
|
||||
annex: {
|
||||
fields: {} as Record<string, string>,
|
||||
requirements: [] as {
|
||||
description: string;
|
||||
classification: string;
|
||||
verification: string;
|
||||
equivalences: string;
|
||||
}[],
|
||||
},
|
||||
});
|
||||
const filtering = useForm({
|
||||
kind: filters.kind ?? '',
|
||||
search: filters.search ?? '',
|
||||
status: filters.status ?? '',
|
||||
from: filters.from ?? '',
|
||||
to: filters.to ?? '',
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<Head title="Pessoas e contratações" />
|
||||
<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."
|
||||
action={
|
||||
ready ? (
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => router.reload()}
|
||||
>
|
||||
Actualizar
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
{!ready ? (
|
||||
<Panel title="Instalação pendente">
|
||||
<p>O módulo ainda não foi instalado neste ambiente.</p>
|
||||
</Panel>
|
||||
) : (
|
||||
<>
|
||||
{company && (
|
||||
<p className="text-sm font-medium">
|
||||
Entidade activa: {company.name}
|
||||
</p>
|
||||
)}
|
||||
<Panel title="Pesquisar e filtrar processos autorizados">
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
filtering.get('/pessoas', {
|
||||
preserveState: true,
|
||||
preserveScroll: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={filtering.errors} />
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
<label>
|
||||
Pesquisa por título ou referência
|
||||
<input
|
||||
className={controlClass}
|
||||
type="search"
|
||||
maxLength={100}
|
||||
value={filtering.data.search}
|
||||
onChange={(e) =>
|
||||
filtering.setData(
|
||||
'search',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Percurso
|
||||
<select
|
||||
className={controlClass}
|
||||
value={filtering.data.kind}
|
||||
onChange={(e) =>
|
||||
filtering.setData(
|
||||
'kind',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Todos os autorizados
|
||||
</option>
|
||||
{availableKinds.map((kind) => (
|
||||
<option key={kind} value={kind}>
|
||||
{kinds[kind]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Estado
|
||||
<select
|
||||
className={controlClass}
|
||||
value={filtering.data.status}
|
||||
onChange={(e) =>
|
||||
filtering.setData(
|
||||
'status',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{Object.entries(peopleStates).map(
|
||||
([key, label]) => (
|
||||
<option
|
||||
key={key}
|
||||
value={key}
|
||||
>
|
||||
{label}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Criado desde
|
||||
<input
|
||||
type="date"
|
||||
className={controlClass}
|
||||
value={filtering.data.from}
|
||||
onChange={(e) =>
|
||||
filtering.setData(
|
||||
'from',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Criado até
|
||||
<input
|
||||
type="date"
|
||||
className={controlClass}
|
||||
min={
|
||||
filtering.data.from || undefined
|
||||
}
|
||||
value={filtering.data.to}
|
||||
onChange={(e) =>
|
||||
filtering.setData(
|
||||
'to',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<Button disabled={filtering.processing}>
|
||||
Aplicar filtros
|
||||
</Button>
|
||||
<Link className="underline" href="/pessoas">
|
||||
Limpar filtros
|
||||
</Link>
|
||||
</div>
|
||||
</form>
|
||||
</Panel>
|
||||
{insights && (
|
||||
<PeopleOperationalInsights data={insights} />
|
||||
)}
|
||||
{workdesk && (
|
||||
<>
|
||||
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-5">
|
||||
{(
|
||||
[
|
||||
[
|
||||
'processes',
|
||||
'Processos autorizados',
|
||||
],
|
||||
[
|
||||
'contract_drafts',
|
||||
'Minutas preparadas',
|
||||
],
|
||||
['tasks', 'As minhas tarefas'],
|
||||
['approvals', 'Aprovações'],
|
||||
['overdue', 'Prazos vencidos'],
|
||||
] as const
|
||||
).map(([key, label]) => (
|
||||
<div
|
||||
className="rounded-xl border p-4"
|
||||
key={key}
|
||||
>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{label}
|
||||
</p>
|
||||
<strong className="text-2xl">
|
||||
{workdesk.counts[key]}
|
||||
</strong>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Actualizado em{' '}
|
||||
{new Date(
|
||||
workdesk.updated_at,
|
||||
).toLocaleString('pt-MZ')}
|
||||
. Contagens limitadas aos filtros e aos seus
|
||||
acessos. Tarefas e aprovações contam acções
|
||||
distintas, não pessoas nem processos
|
||||
duplicados.
|
||||
</p>
|
||||
<Queue
|
||||
id="people-tasks"
|
||||
title="As minhas tarefas"
|
||||
items={workdesk.tasks}
|
||||
empty="Sem tarefas operacionais pendentes para os filtros e atribuições actuais."
|
||||
/>
|
||||
<Queue
|
||||
id="people-approvals"
|
||||
title="Aprovações"
|
||||
items={workdesk.approvals}
|
||||
empty="Sem decisões formais pendentes para os filtros e atribuições actuais."
|
||||
/>
|
||||
{workdesk.alerts.length > 0 && (
|
||||
<Panel title="Prazos a acompanhar">
|
||||
<ul className="space-y-2">
|
||||
{workdesk.alerts.map((alert) => (
|
||||
<li
|
||||
key={
|
||||
alert.id ??
|
||||
`${alert.process_id}-${alert.label}`
|
||||
}
|
||||
>
|
||||
<Link
|
||||
className="underline"
|
||||
href={alert.href}
|
||||
>
|
||||
{alert.title} ·{' '}
|
||||
{alert.label} ·{' '}
|
||||
{alert.due_on}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Panel>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{administration.length > 0 && (
|
||||
<Panel
|
||||
title="Organizar equipas"
|
||||
description="Acesso à configuração das atribuições, sem consultar conteúdo dos processos."
|
||||
>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
{administration.map((p) => (
|
||||
<Link
|
||||
key={p.id}
|
||||
href={`/pessoas/${p.id}/acessos`}
|
||||
className="underline"
|
||||
>
|
||||
Processo #{p.id} · {kinds[p.kind]}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</Panel>
|
||||
)}
|
||||
<Panel title="Processos">
|
||||
<div className="space-y-3">
|
||||
{processes?.data.map((p) => (
|
||||
<Link
|
||||
className="block rounded-lg border p-4"
|
||||
key={p.id}
|
||||
href={`/pessoas/${p.id}`}
|
||||
>
|
||||
<strong>
|
||||
PES-{p.id} · {p.title}
|
||||
</strong>
|
||||
<p>
|
||||
{kinds[p.kind]} ·{' '}
|
||||
{peopleStates[p.status] ?? p.status}{' '}
|
||||
· candidaturas até {p.closes_on}
|
||||
</p>
|
||||
</Link>
|
||||
))}
|
||||
{!processes?.data.length && (
|
||||
<p>Sem processos acessíveis.</p>
|
||||
)}
|
||||
</div>
|
||||
<nav
|
||||
aria-label="Páginas de processos"
|
||||
className="mt-4 flex gap-3"
|
||||
>
|
||||
{processes?.links.map(
|
||||
(link, i) =>
|
||||
link.url && (
|
||||
<Link
|
||||
key={i}
|
||||
href={link.url}
|
||||
aria-current={
|
||||
link.active
|
||||
? 'page'
|
||||
: undefined
|
||||
}
|
||||
className="underline"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: link.label,
|
||||
}}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
</nav>
|
||||
</Panel>
|
||||
{canPrepare.length > 0 && (
|
||||
<Panel
|
||||
title="Preparar novo processo"
|
||||
description="A abertura exige outra pessoa. Critérios e mínimo de avaliações ficam preservados neste processo; não são herdados das compras."
|
||||
>
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.transform((values) => ({
|
||||
...values,
|
||||
annex: {
|
||||
...values.annex,
|
||||
fields: Object.fromEntries(
|
||||
Object.keys(
|
||||
formFields[
|
||||
values.kind
|
||||
] ?? {},
|
||||
).map((key) => [
|
||||
key,
|
||||
values.annex.fields[
|
||||
key
|
||||
] ?? '',
|
||||
]),
|
||||
),
|
||||
},
|
||||
}));
|
||||
form.post('/pessoas', {
|
||||
onSuccess: () => form.reset(),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<label className="block">
|
||||
Percurso
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.kind}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'kind',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
{canPrepare.map((kind) => (
|
||||
<option key={kind} value={kind}>
|
||||
{kinds[kind]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="block">
|
||||
Título da necessidade ou vaga
|
||||
<input
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={3}
|
||||
maxLength={200}
|
||||
value={form.data.title}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'title',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Objectivo, perfil e âmbito
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={5000}
|
||||
value={form.data.purpose}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'purpose',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<label>
|
||||
Fecho de candidaturas
|
||||
<input
|
||||
className={controlClass}
|
||||
type="date"
|
||||
required
|
||||
value={form.data.closes_on}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'closes_on',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Avaliadores independentes por
|
||||
candidatura
|
||||
<input
|
||||
className={controlClass}
|
||||
type="number"
|
||||
min="1"
|
||||
max="20"
|
||||
required
|
||||
value={
|
||||
form.data.minimum_reviews
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'minimum_reviews',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<fieldset className="space-y-3">
|
||||
<legend className="font-medium">
|
||||
Critérios de avaliação — soma de
|
||||
100%
|
||||
</legend>
|
||||
{form.data.criteria.map(
|
||||
(criterion, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="grid gap-3 md:grid-cols-[1fr_8rem_auto]"
|
||||
>
|
||||
<label>
|
||||
Critério
|
||||
<input
|
||||
className={
|
||||
controlClass
|
||||
}
|
||||
required
|
||||
maxLength={150}
|
||||
value={
|
||||
criterion.label
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'criteria',
|
||||
form.data.criteria.map(
|
||||
(
|
||||
row,
|
||||
i,
|
||||
) =>
|
||||
i ===
|
||||
index
|
||||
? {
|
||||
...row,
|
||||
label: e
|
||||
.target
|
||||
.value,
|
||||
}
|
||||
: row,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Peso (%)
|
||||
<input
|
||||
className={
|
||||
controlClass
|
||||
}
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
required
|
||||
value={
|
||||
criterion.weight
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'criteria',
|
||||
form.data.criteria.map(
|
||||
(
|
||||
row,
|
||||
i,
|
||||
) =>
|
||||
i ===
|
||||
index
|
||||
? {
|
||||
...row,
|
||||
weight: e
|
||||
.target
|
||||
.value,
|
||||
}
|
||||
: row,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={
|
||||
form.data.criteria
|
||||
.length === 1
|
||||
}
|
||||
onClick={() =>
|
||||
form.setData(
|
||||
'criteria',
|
||||
form.data.criteria.filter(
|
||||
(_, i) =>
|
||||
i !==
|
||||
index,
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
Retirar
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={
|
||||
form.data.criteria.length >= 20
|
||||
}
|
||||
onClick={() =>
|
||||
form.setData('criteria', [
|
||||
...form.data.criteria,
|
||||
{ label: '', weight: '' },
|
||||
])
|
||||
}
|
||||
>
|
||||
Adicionar critério
|
||||
</Button>
|
||||
</fieldset>
|
||||
<fieldset className="space-y-4">
|
||||
<legend className="font-semibold">
|
||||
{form.data.kind === 'staff'
|
||||
? 'Anexo A — Ficha da função'
|
||||
: 'Anexo C — Necessidade de serviço'}
|
||||
</legend>
|
||||
<p className="text-sm">
|
||||
Complete os campos aplicáveis. O
|
||||
título e o objectivo acima
|
||||
identificam a necessidade. Ao criar,
|
||||
assume a preparação deste processo;
|
||||
atribua depois a equipa.
|
||||
</p>
|
||||
{Object.entries(
|
||||
formFields[form.data.kind] ?? {},
|
||||
).map(([key, label]) => (
|
||||
<label key={key} className="block">
|
||||
{label}
|
||||
<textarea
|
||||
className={controlClass}
|
||||
maxLength={5000}
|
||||
value={
|
||||
form.data.annex.fields[
|
||||
key
|
||||
] ?? ''
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData('annex', {
|
||||
...form.data.annex,
|
||||
fields: {
|
||||
...form.data
|
||||
.annex
|
||||
.fields,
|
||||
[key]: e.target
|
||||
.value,
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
<fieldset className="space-y-4">
|
||||
<legend className="font-semibold">
|
||||
Requisitos obrigatórios e desejáveis
|
||||
</legend>
|
||||
<p className="text-sm">
|
||||
Registe como verificar cada
|
||||
requisito e as equivalências
|
||||
aceites. A falta de comprovativo não
|
||||
gera exclusão automática.
|
||||
</p>
|
||||
{form.data.annex.requirements.map(
|
||||
(r, index) => (
|
||||
<div
|
||||
className="space-y-3 rounded border p-4"
|
||||
key={index}
|
||||
>
|
||||
{(
|
||||
[
|
||||
'description',
|
||||
'verification',
|
||||
'equivalences',
|
||||
] as const
|
||||
).map((key) => (
|
||||
<label
|
||||
key={key}
|
||||
className="block"
|
||||
>
|
||||
{
|
||||
{
|
||||
description:
|
||||
'Requisito e relação com a função ou serviço',
|
||||
verification:
|
||||
'Método de verificação',
|
||||
equivalences:
|
||||
'Equivalências e adaptações aplicáveis',
|
||||
}[key]
|
||||
}
|
||||
<textarea
|
||||
className={
|
||||
controlClass
|
||||
}
|
||||
required={
|
||||
key !==
|
||||
'equivalences'
|
||||
}
|
||||
maxLength={
|
||||
key ===
|
||||
'description'
|
||||
? 1000
|
||||
: 2000
|
||||
}
|
||||
value={r[key]}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'annex',
|
||||
{
|
||||
...form
|
||||
.data
|
||||
.annex,
|
||||
requirements:
|
||||
form.data.annex.requirements.map(
|
||||
(
|
||||
row,
|
||||
i,
|
||||
) =>
|
||||
i ===
|
||||
index
|
||||
? {
|
||||
...row,
|
||||
[key]: e
|
||||
.target
|
||||
.value,
|
||||
}
|
||||
: row,
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
<label>
|
||||
Classificação
|
||||
<select
|
||||
className={
|
||||
controlClass
|
||||
}
|
||||
value={
|
||||
r.classification
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'annex',
|
||||
{
|
||||
...form
|
||||
.data
|
||||
.annex,
|
||||
requirements:
|
||||
form.data.annex.requirements.map(
|
||||
(
|
||||
row,
|
||||
i,
|
||||
) =>
|
||||
i ===
|
||||
index
|
||||
? {
|
||||
...row,
|
||||
classification:
|
||||
e
|
||||
.target
|
||||
.value,
|
||||
}
|
||||
: row,
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="mandatory">
|
||||
Obrigatório
|
||||
</option>
|
||||
<option value="desirable">
|
||||
Desejável
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
form.setData(
|
||||
'annex',
|
||||
{
|
||||
...form.data
|
||||
.annex,
|
||||
requirements:
|
||||
form.data.annex.requirements.filter(
|
||||
(
|
||||
_,
|
||||
i,
|
||||
) =>
|
||||
i !==
|
||||
index,
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
>
|
||||
Retirar requisito
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
form.setData('annex', {
|
||||
...form.data.annex,
|
||||
requirements: [
|
||||
...form.data.annex
|
||||
.requirements,
|
||||
{
|
||||
description: '',
|
||||
classification:
|
||||
'mandatory',
|
||||
verification: '',
|
||||
equivalences: '',
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
>
|
||||
Adicionar requisito
|
||||
</Button>
|
||||
</fieldset>
|
||||
<Button disabled={form.processing}>
|
||||
Guardar para conferência da abertura
|
||||
</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import {
|
||||
PageTitle,
|
||||
Panel,
|
||||
FormErrors,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
export type RegistryPerson = {
|
||||
id: number;
|
||||
name: string;
|
||||
reference: string;
|
||||
profile_summary: string;
|
||||
active: boolean;
|
||||
version: number;
|
||||
canEdit: boolean;
|
||||
};
|
||||
|
||||
function PersonForm({ person }: { person?: RegistryPerson }) {
|
||||
const form = useForm({
|
||||
operation_key: crypto.randomUUID(),
|
||||
version: person?.version ?? 1,
|
||||
name: person?.name ?? '',
|
||||
reference: person?.reference ?? '',
|
||||
profile_summary: person?.profile_summary ?? '',
|
||||
active: person?.active ?? true,
|
||||
reason: '',
|
||||
});
|
||||
return (
|
||||
<form
|
||||
className="space-y-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.post(`/pessoas/cadastro${person ? `/${person.id}` : ''}`, {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
if (!person) {
|
||||
form.reset();
|
||||
form.setData('operation_key', crypto.randomUUID());
|
||||
}
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<label className="grid gap-1">
|
||||
Nome
|
||||
<input
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={3}
|
||||
maxLength={200}
|
||||
value={form.data.name}
|
||||
onChange={(event) =>
|
||||
form.setData('name', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Referência do cadastro
|
||||
{!person && ' (opcional; gerada se vazia)'}
|
||||
<input
|
||||
className={controlClass}
|
||||
maxLength={120}
|
||||
required={!!person}
|
||||
value={form.data.reference}
|
||||
onChange={(event) =>
|
||||
form.setData('reference', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1">
|
||||
Resumo do perfil reutilizável
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={5000}
|
||||
value={form.data.profile_summary}
|
||||
onChange={(event) =>
|
||||
form.setData('profile_summary', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{person && (
|
||||
<label className="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.active}
|
||||
onChange={(event) =>
|
||||
form.setData('active', event.target.checked)
|
||||
}
|
||||
/>
|
||||
Disponível para novas candidaturas
|
||||
</label>
|
||||
)}
|
||||
<label className="grid gap-1">
|
||||
Motivo
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={4000}
|
||||
value={form.data.reason}
|
||||
onChange={(event) =>
|
||||
form.setData('reason', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<Button disabled={form.processing}>
|
||||
{person ? 'Guardar nova versão' : 'Registar pessoa'}
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default function PeopleRegistry({
|
||||
ready,
|
||||
canCreate,
|
||||
records,
|
||||
filters,
|
||||
}: {
|
||||
ready: boolean;
|
||||
canCreate: boolean;
|
||||
records: {
|
||||
data: RegistryPerson[];
|
||||
total: number;
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
} | null;
|
||||
filters: { search?: string; status?: string };
|
||||
}) {
|
||||
const search = useForm({
|
||||
search: filters.search ?? '',
|
||||
status: filters.status ?? 'active',
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<Head title="Cadastro de pessoas" />
|
||||
<div className="mx-auto max-w-5xl space-y-6 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow="Pessoas e contratações"
|
||||
title="Cadastro reutilizável de pessoas"
|
||||
description="Registe o perfil uma vez e seleccione-o nas candidaturas seguintes. Cada processo conserva a versão utilizada."
|
||||
/>
|
||||
<p className="text-sm">
|
||||
São apresentados os seus registos e o cadastro partilhado
|
||||
que a empresa o autorizou a consultar. Actualizar ou
|
||||
arquivar não altera candidaturas e decisões anteriores.
|
||||
Nomes iguais não são fundidos automaticamente.
|
||||
</p>
|
||||
{!ready ? (
|
||||
<Panel title="Instalação pendente">
|
||||
<p>
|
||||
O cadastro ainda não foi instalado neste ambiente.
|
||||
</p>
|
||||
</Panel>
|
||||
) : (
|
||||
<>
|
||||
<Panel title="Pesquisar cadastro">
|
||||
<form
|
||||
className="flex flex-wrap gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
search.get('/pessoas/cadastro', {
|
||||
preserveState: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<input
|
||||
aria-label="Nome ou referência"
|
||||
className={controlClass}
|
||||
maxLength={100}
|
||||
value={search.data.search}
|
||||
onChange={(event) =>
|
||||
search.setData(
|
||||
'search',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
<select
|
||||
aria-label="Estado"
|
||||
className={controlClass}
|
||||
value={search.data.status}
|
||||
onChange={(event) =>
|
||||
search.setData(
|
||||
'status',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="active">Disponíveis</option>
|
||||
<option value="archived">Arquivados</option>
|
||||
<option value="all">Todos</option>
|
||||
</select>
|
||||
<Button>Pesquisar</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
{records?.data.map((person) => (
|
||||
<Panel
|
||||
key={`${person.id}-${person.version}`}
|
||||
title={`${person.name} · versão ${person.version}`}
|
||||
>
|
||||
<p className="mb-4 text-sm break-all">
|
||||
{person.reference} ·{' '}
|
||||
{person.active ? 'Disponível' : 'Arquivado'}
|
||||
</p>
|
||||
{person.canEdit ? (
|
||||
<PersonForm person={person} />
|
||||
) : (
|
||||
<p className="whitespace-pre-wrap">
|
||||
{person.profile_summary}
|
||||
</p>
|
||||
)}
|
||||
</Panel>
|
||||
))}
|
||||
{!records?.total && <p>Sem pessoas neste âmbito.</p>}
|
||||
<div className="flex gap-4">
|
||||
{records?.prev_page_url && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={records.prev_page_url}
|
||||
>
|
||||
Anterior
|
||||
</Link>
|
||||
)}
|
||||
{records?.next_page_url && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={records.next_page_url}
|
||||
>
|
||||
Seguinte
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
{canCreate && (
|
||||
<Panel title="Nova pessoa">
|
||||
<PersonForm />
|
||||
</Panel>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,852 @@
|
||||
import { Head, Link, useForm, usePage } from '@inertiajs/react';
|
||||
import {
|
||||
PageTitle,
|
||||
Panel,
|
||||
FormErrors,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { PeopleClarifications } from '@/components/people-clarifications';
|
||||
import type { ClarificationData } from '@/components/people-clarifications';
|
||||
import { EvidenceBrief } from '@/components/evidence-brief';
|
||||
import type { EvidenceBriefData } from '@/components/evidence-brief';
|
||||
import { AiPreparationPreview } from '@/components/ai-preparation-preview';
|
||||
import type { AiPreparation } from '@/components/ai-preparation-preview';
|
||||
import { PeopleRegistryChoice } from '@/components/people-registry-choice';
|
||||
import type { RegistryChoice } from '@/components/people-registry-choice';
|
||||
|
||||
type Process = {
|
||||
id: number;
|
||||
title: string;
|
||||
purpose: string;
|
||||
kind: string;
|
||||
status: string;
|
||||
version: number;
|
||||
closes_on: string;
|
||||
rules: {
|
||||
submission_form?: {
|
||||
id: number;
|
||||
version: number;
|
||||
definition: {
|
||||
available: boolean;
|
||||
fields: { key: string; label: string; required: boolean }[];
|
||||
documents: { key: string; label: string; required: boolean }[];
|
||||
};
|
||||
};
|
||||
minimum_reviews: number;
|
||||
criteria: { label: string; weight: number }[];
|
||||
annex?: {
|
||||
version: number;
|
||||
template: string;
|
||||
fields: Record<string, string | null>;
|
||||
requirements: {
|
||||
description: string;
|
||||
classification: string;
|
||||
verification: string;
|
||||
equivalences?: string | null;
|
||||
}[];
|
||||
};
|
||||
};
|
||||
selection: null | {
|
||||
rows: Candidate[];
|
||||
reason: string;
|
||||
outcome?: string;
|
||||
decision_reason?: string;
|
||||
};
|
||||
selected_application_id: number | null;
|
||||
contract: null | {
|
||||
reference: string;
|
||||
starts_on: string;
|
||||
terms: string;
|
||||
status: string;
|
||||
};
|
||||
};
|
||||
type Candidate = {
|
||||
electronic_source?: {
|
||||
submission_id: number;
|
||||
reference: string;
|
||||
profile_version: number;
|
||||
};
|
||||
registry_source?: { id: number; reference: string; version: number };
|
||||
id: number;
|
||||
name: string;
|
||||
reference: string;
|
||||
summary: string;
|
||||
received_on: string;
|
||||
evaluation_count: number;
|
||||
score_minor: number | null;
|
||||
reviews: {
|
||||
id: number;
|
||||
reviewed_by: number;
|
||||
reason: string;
|
||||
created_at: string;
|
||||
answers: {
|
||||
score: string;
|
||||
evidence: string;
|
||||
evidence_type?: string;
|
||||
clarification?: string | null;
|
||||
}[];
|
||||
}[];
|
||||
};
|
||||
const states: Record<string, string> = {
|
||||
draft: 'Abertura por conferir',
|
||||
open: 'Recepção de candidaturas',
|
||||
assessment: 'Avaliação',
|
||||
selection_review: 'Selecção por conferir',
|
||||
selected: 'Selecção aprovada',
|
||||
contract_draft: 'Minuta contratual preparada',
|
||||
};
|
||||
const commands: Record<string, string> = {
|
||||
open: 'Conferir e abrir',
|
||||
apply: 'Registar candidatura',
|
||||
close: 'Encerrar recepção e iniciar avaliação',
|
||||
evaluate: 'Registar avaliação',
|
||||
select: 'Propor selecção',
|
||||
confirm: 'Conferir selecção',
|
||||
contract: 'Preparar minuta contratual',
|
||||
};
|
||||
|
||||
function Action({
|
||||
process: p,
|
||||
candidates,
|
||||
command,
|
||||
registry,
|
||||
}: {
|
||||
process: Process;
|
||||
candidates: Candidate[];
|
||||
command: string;
|
||||
registry?: RegistryChoice;
|
||||
}) {
|
||||
const requestedApplication =
|
||||
new URL(usePage().url, 'http://local').searchParams.get(
|
||||
'candidatura',
|
||||
) ?? '';
|
||||
const form = useForm({
|
||||
version: p.version,
|
||||
operation_key: crypto.randomUUID(),
|
||||
reason: '',
|
||||
no_conflict: false,
|
||||
name: '',
|
||||
person_id: '',
|
||||
person_version: '',
|
||||
save_person: !!registry?.ready && registry.canCreate,
|
||||
person_reference: '',
|
||||
reference: '',
|
||||
summary: '',
|
||||
received_on: '',
|
||||
application_id: candidates.some(
|
||||
(candidate) => String(candidate.id) === requestedApplication,
|
||||
)
|
||||
? requestedApplication
|
||||
: '',
|
||||
outcome: 'approved',
|
||||
starts_on: '',
|
||||
terms: '',
|
||||
answers: p.rules.criteria.map(() => ({
|
||||
score: '',
|
||||
evidence: '',
|
||||
evidence_type: '',
|
||||
clarification: '',
|
||||
})),
|
||||
});
|
||||
const candidateChoice = ['evaluate', 'select'].includes(command);
|
||||
return (
|
||||
<Panel title={commands[command]}>
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.post(`/pessoas/${p.id}/${command}`, {
|
||||
preserveState: 'errors',
|
||||
preserveScroll: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
{command === 'apply' && (
|
||||
<>
|
||||
{registry?.ready && (
|
||||
<PeopleRegistryChoice
|
||||
processId={p.id}
|
||||
data={registry}
|
||||
selected={form.data.person_id}
|
||||
choose={(person) => {
|
||||
form.setData((data) => ({
|
||||
...data,
|
||||
person_id: person
|
||||
? String(person.id)
|
||||
: '',
|
||||
person_version: person
|
||||
? String(person.version)
|
||||
: '',
|
||||
name: person?.name ?? '',
|
||||
summary: person?.profile_summary ?? '',
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<label className="block">
|
||||
Nome da pessoa
|
||||
<input
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={3}
|
||||
maxLength={200}
|
||||
value={form.data.name}
|
||||
readOnly={!!form.data.person_id}
|
||||
onChange={(e) =>
|
||||
form.setData('name', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{registry?.ready &&
|
||||
registry.canCreate &&
|
||||
!form.data.person_id && (
|
||||
<>
|
||||
<label className="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.save_person}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'save_person',
|
||||
event.target.checked,
|
||||
)
|
||||
}
|
||||
/>
|
||||
Guardar também no meu cadastro para
|
||||
reutilizar
|
||||
</label>
|
||||
{form.data.save_person && (
|
||||
<label className="block">
|
||||
Referência do cadastro (opcional)
|
||||
<input
|
||||
className={controlClass}
|
||||
maxLength={120}
|
||||
value={
|
||||
form.data.person_reference
|
||||
}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'person_reference',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<label className="block">
|
||||
Referência documental da candidatura
|
||||
<input
|
||||
className={controlClass}
|
||||
required
|
||||
maxLength={200}
|
||||
value={form.data.reference}
|
||||
onChange={(e) =>
|
||||
form.setData('reference', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Recebida em
|
||||
<input
|
||||
className={controlClass}
|
||||
type="date"
|
||||
required
|
||||
value={form.data.received_on}
|
||||
onChange={(e) =>
|
||||
form.setData('received_on', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Resumo profissional pertinente
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={5000}
|
||||
value={form.data.summary}
|
||||
onChange={(e) =>
|
||||
form.setData('summary', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
{candidateChoice && (
|
||||
<label className="block">
|
||||
Candidatura
|
||||
<select
|
||||
className={controlClass}
|
||||
required
|
||||
value={form.data.application_id}
|
||||
onChange={(e) =>
|
||||
form.setData('application_id', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
{candidates.map((c) => (
|
||||
<option key={c.id} value={c.id}>
|
||||
{c.name} · {c.reference}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{command === 'evaluate' &&
|
||||
p.rules.criteria.map((criterion, index) => (
|
||||
<fieldset
|
||||
key={index}
|
||||
className="space-y-3 rounded-lg border p-4"
|
||||
>
|
||||
<legend>
|
||||
{criterion.label} · {criterion.weight}%
|
||||
</legend>
|
||||
<label className="block">
|
||||
Pontuação (0 a 10)
|
||||
<input
|
||||
className={controlClass}
|
||||
type="number"
|
||||
min="0"
|
||||
max="10"
|
||||
step="0.01"
|
||||
required
|
||||
value={form.data.answers[index].score}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'answers',
|
||||
form.data.answers.map((a, i) =>
|
||||
i === index
|
||||
? {
|
||||
...a,
|
||||
score: e.target.value,
|
||||
}
|
||||
: a,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Evidência e fundamento
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={2000}
|
||||
value={form.data.answers[index].evidence}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'answers',
|
||||
form.data.answers.map((a, i) =>
|
||||
i === index
|
||||
? {
|
||||
...a,
|
||||
evidence:
|
||||
e.target.value,
|
||||
}
|
||||
: a,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Tipo de evidência
|
||||
<select
|
||||
className={controlClass}
|
||||
required
|
||||
value={
|
||||
form.data.answers[index].evidence_type
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'answers',
|
||||
form.data.answers.map((a, i) =>
|
||||
i === index
|
||||
? {
|
||||
...a,
|
||||
evidence_type:
|
||||
e.target.value,
|
||||
}
|
||||
: a,
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccione</option>
|
||||
<option value="reported">
|
||||
Relatada pela pessoa candidata
|
||||
</option>
|
||||
<option value="observed">
|
||||
Observada na entrevista ou exercício
|
||||
</option>
|
||||
<option value="verified">
|
||||
Comprovada por fonte verificável
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="block">
|
||||
Esclarecimentos necessários
|
||||
<textarea
|
||||
className={controlClass}
|
||||
maxLength={2000}
|
||||
value={
|
||||
form.data.answers[index].clarification
|
||||
}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'answers',
|
||||
form.data.answers.map((a, i) =>
|
||||
i === index
|
||||
? {
|
||||
...a,
|
||||
clarification:
|
||||
e.target.value,
|
||||
}
|
||||
: a,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
))}
|
||||
{command === 'confirm' && (
|
||||
<label className="block">
|
||||
Decisão
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.outcome}
|
||||
onChange={(e) =>
|
||||
form.setData('outcome', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="approved">Aprovar selecção</option>
|
||||
<option value="returned">
|
||||
Devolver para análise
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{command === 'contract' && (
|
||||
<>
|
||||
<p className="text-sm">
|
||||
Preparação interna de minuta. Não comprova
|
||||
assinatura, admissão efectiva nem prestação de
|
||||
serviço.
|
||||
</p>
|
||||
<label className="block">
|
||||
Referência da minuta
|
||||
<input
|
||||
className={controlClass}
|
||||
required
|
||||
maxLength={200}
|
||||
value={form.data.reference}
|
||||
onChange={(e) =>
|
||||
form.setData('reference', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Início proposto
|
||||
<input
|
||||
className={controlClass}
|
||||
type="date"
|
||||
required
|
||||
value={form.data.starts_on}
|
||||
onChange={(e) =>
|
||||
form.setData('starts_on', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Condições propostas
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={20}
|
||||
maxLength={10000}
|
||||
value={form.data.terms}
|
||||
onChange={(e) =>
|
||||
form.setData('terms', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
<label className="block">
|
||||
Fundamento{' '}
|
||||
{command === 'select'
|
||||
? '(inclua a justificação de eventual empate)'
|
||||
: ''}
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={5000}
|
||||
value={form.data.reason}
|
||||
onChange={(e) => form.setData('reason', e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
{['open', 'evaluate', 'select', 'confirm', 'contract'].includes(
|
||||
command,
|
||||
) && (
|
||||
<label className="flex gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
required
|
||||
checked={form.data.no_conflict}
|
||||
onChange={(e) =>
|
||||
form.setData('no_conflict', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Declaro não ter conflito de interesses neste processo e
|
||||
nesta intervenção.
|
||||
</label>
|
||||
)}
|
||||
<Button disabled={form.processing}>{commands[command]}</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
|
||||
export default function PeopleShow({
|
||||
process: p,
|
||||
candidates,
|
||||
canPrepare,
|
||||
canViewElectronicSources = false,
|
||||
canReview,
|
||||
canApprove = false,
|
||||
canContract = false,
|
||||
canManage = false,
|
||||
formFields = {},
|
||||
clarifications,
|
||||
brief,
|
||||
aiPreparation,
|
||||
registry,
|
||||
history,
|
||||
}: {
|
||||
process: Process;
|
||||
candidates: Candidate[];
|
||||
canPrepare: boolean;
|
||||
canViewElectronicSources?: boolean;
|
||||
canReview: boolean;
|
||||
canApprove?: boolean;
|
||||
canContract?: boolean;
|
||||
canManage?: boolean;
|
||||
formFields?: Record<string, string>;
|
||||
clarifications?: ClarificationData;
|
||||
brief?: EvidenceBriefData | null;
|
||||
aiPreparation?: AiPreparation;
|
||||
registry?: RegistryChoice;
|
||||
history: {
|
||||
id: number;
|
||||
action: string;
|
||||
user_id: number;
|
||||
created_at: string;
|
||||
}[];
|
||||
}) {
|
||||
const actions = [
|
||||
...(canReview && p.status === 'draft' ? ['open'] : []),
|
||||
...(canPrepare && p.status === 'open' ? ['apply', 'close'] : []),
|
||||
...(canReview && p.status === 'assessment' ? ['evaluate'] : []),
|
||||
...(canPrepare && p.status === 'assessment' ? ['select'] : []),
|
||||
...(canApprove && p.status === 'selection_review' ? ['confirm'] : []),
|
||||
...(canContract && p.status === 'selected' ? ['contract'] : []),
|
||||
];
|
||||
const rows =
|
||||
p.selection &&
|
||||
['selection_review', 'selected', 'contract_draft'].includes(p.status)
|
||||
? p.selection.rows
|
||||
: candidates;
|
||||
return (
|
||||
<>
|
||||
<Head title={p.title} />
|
||||
<div className="mx-auto max-w-6xl space-y-6 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow={
|
||||
p.kind === 'service'
|
||||
? 'Prestador individual'
|
||||
: 'Recrutamento de trabalhador'
|
||||
}
|
||||
title={p.title}
|
||||
description={`${states[p.status] ?? p.status} · PES-${p.id}`}
|
||||
action={
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => window.print()}
|
||||
>
|
||||
Imprimir relatório
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<Link className="underline" href="/pessoas">
|
||||
Voltar a Pessoas e contratações
|
||||
</Link>
|
||||
{(canPrepare || canViewElectronicSources) && (
|
||||
<Link
|
||||
className="block underline"
|
||||
href={`/pessoas/${p.id}/recebidas`}
|
||||
>
|
||||
Publicação e candidaturas electrónicas recebidas
|
||||
</Link>
|
||||
)}
|
||||
{canManage && (
|
||||
<Link
|
||||
className="underline print:hidden"
|
||||
href={`/pessoas/${p.id}/acessos`}
|
||||
>
|
||||
Organizar equipa e permissões deste processo
|
||||
</Link>
|
||||
)}
|
||||
{p.rules.submission_form && (
|
||||
<Panel
|
||||
title={`Formulário de candidatura — versão ${p.rules.submission_form.version}`}
|
||||
>
|
||||
<p>
|
||||
Definição preservada na preparação deste processo.
|
||||
Portal externo em desenvolvimento.
|
||||
</p>
|
||||
<p>
|
||||
{p.rules.submission_form.definition.available
|
||||
? 'Modalidade prevista para recepção.'
|
||||
: 'Modalidade indisponível para novas submissões externas.'}
|
||||
</p>
|
||||
<ul>
|
||||
{p.rules.submission_form.definition.fields.map(
|
||||
(field) => (
|
||||
<li key={field.key}>
|
||||
{field.label} ·{' '}
|
||||
{field.required
|
||||
? 'Obrigatório'
|
||||
: 'Opcional'}
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
{p.rules.submission_form.definition.documents.map(
|
||||
(document) => (
|
||||
<li key={document.key}>
|
||||
{document.label} ·{' '}
|
||||
{document.required
|
||||
? 'Obrigatório'
|
||||
: 'Opcional'}
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
</ul>
|
||||
</Panel>
|
||||
)}
|
||||
{p.rules.annex && (
|
||||
<Panel
|
||||
title={`Anexo ${p.rules.annex.template} — versão ${p.rules.annex.version}`}
|
||||
>
|
||||
<dl className="space-y-3">
|
||||
{Object.entries(p.rules.annex.fields)
|
||||
.filter(([, value]) => value)
|
||||
.map(([key, value]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-medium">
|
||||
{formFields[key] ?? key}
|
||||
</dt>
|
||||
<dd className="whitespace-pre-wrap">
|
||||
{value}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
<h3 className="mt-5 font-semibold">
|
||||
Requisitos e verificação
|
||||
</h3>
|
||||
{p.rules.annex.requirements.map((r, index) => (
|
||||
<section
|
||||
key={index}
|
||||
className="mt-3 rounded border p-3"
|
||||
>
|
||||
<strong>
|
||||
{r.classification === 'mandatory'
|
||||
? 'Obrigatório'
|
||||
: 'Desejável'}{' '}
|
||||
· {r.description}
|
||||
</strong>
|
||||
<p>Verificação: {r.verification}</p>
|
||||
{r.equivalences && (
|
||||
<p>
|
||||
Equivalências e adaptações:{' '}
|
||||
{r.equivalences}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
))}
|
||||
</Panel>
|
||||
)}
|
||||
{brief && <EvidenceBrief data={brief} />}
|
||||
{aiPreparation && <AiPreparationPreview data={aiPreparation} />}
|
||||
<Panel
|
||||
id="people-report-scope"
|
||||
title="Âmbito e critérios preservados"
|
||||
>
|
||||
<p className="whitespace-pre-wrap">{p.purpose}</p>
|
||||
<p className="my-3">
|
||||
Candidaturas até {p.closes_on} ·{' '}
|
||||
{p.rules.minimum_reviews} avaliador(es) independente(s)
|
||||
por pessoa.
|
||||
</p>
|
||||
<ul className="list-disc pl-5">
|
||||
{p.rules.criteria.map((c, i) => (
|
||||
<li key={i}>
|
||||
{c.label} · {c.weight}%
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Panel>
|
||||
<Panel
|
||||
id="people-report-candidates"
|
||||
title="Candidaturas e avaliação"
|
||||
description="Pontuações pela média das avaliações elegíveis. Empates exigem escolha fundamentada, sem selecção automática."
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{rows.map((c) => (
|
||||
<section
|
||||
className="rounded-lg border p-4"
|
||||
key={c.id}
|
||||
>
|
||||
{c.registry_source && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Cadastro {c.registry_source.reference} ·
|
||||
versão utilizada{' '}
|
||||
{c.registry_source.version}
|
||||
</p>
|
||||
)}
|
||||
{c.electronic_source && (
|
||||
<p className="text-sm">
|
||||
Submissão electrónica{' '}
|
||||
{c.electronic_source.reference} · perfil
|
||||
v{c.electronic_source.profile_version}
|
||||
{canViewElectronicSources && (
|
||||
<Link
|
||||
className="ml-2 underline"
|
||||
href={`/pessoas/${p.id}/recebidas?submission=${c.electronic_source.submission_id}`}
|
||||
>
|
||||
Consultar dados enviados
|
||||
</Link>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
<strong>
|
||||
{c.name} · {c.reference}
|
||||
</strong>
|
||||
<p>
|
||||
Recebida em {c.received_on} ·{' '}
|
||||
{c.evaluation_count} avaliação(ões) ·{' '}
|
||||
{c.score_minor === null
|
||||
? 'Por concluir'
|
||||
: `${(c.score_minor / 100).toFixed(2)} / 10`}
|
||||
{c.id === p.selected_application_id
|
||||
? p.status === 'selection_review'
|
||||
? ' · Candidatura proposta'
|
||||
: ' · Pessoa seleccionada'
|
||||
: ''}
|
||||
</p>
|
||||
<p className="text-sm whitespace-pre-wrap">
|
||||
{c.summary}
|
||||
</p>
|
||||
{c.reviews.map((r) => (
|
||||
<details key={r.id} className="mt-3">
|
||||
<summary>
|
||||
Avaliação #{r.id} · pessoa #
|
||||
{r.reviewed_by} · {r.created_at}
|
||||
</summary>
|
||||
<p>{r.reason}</p>
|
||||
{r.answers.map((a, i) => (
|
||||
<p key={i}>
|
||||
{p.rules.criteria[i]?.label}:{' '}
|
||||
{a.score}/10 · {a.evidence}
|
||||
<span className="block">
|
||||
Evidência:{' '}
|
||||
{{
|
||||
reported: 'relatada',
|
||||
observed: 'observada',
|
||||
verified: 'comprovada',
|
||||
}[a.evidence_type ?? ''] ??
|
||||
'não classificada no registo inicial'}
|
||||
{a.clarification
|
||||
? ` · Esclarecimento registado na avaliação: ${a.clarification}`
|
||||
: ''}
|
||||
</span>
|
||||
</p>
|
||||
))}
|
||||
</details>
|
||||
))}
|
||||
</section>
|
||||
))}
|
||||
{!rows.length && <p>Sem candidaturas registadas.</p>}
|
||||
</div>
|
||||
</Panel>
|
||||
{p.selection && (
|
||||
<Panel
|
||||
id="people-report-selection"
|
||||
title="Fundamento da selecção"
|
||||
>
|
||||
<p className="whitespace-pre-wrap">
|
||||
{p.selection.reason}
|
||||
</p>
|
||||
{p.selection.decision_reason && (
|
||||
<p className="mt-3 whitespace-pre-wrap">
|
||||
Conferência: {p.selection.decision_reason}
|
||||
</p>
|
||||
)}
|
||||
</Panel>
|
||||
)}
|
||||
{p.contract && (
|
||||
<Panel
|
||||
id="people-report-contract"
|
||||
title="Minuta contratual — preparação interna"
|
||||
>
|
||||
<p>
|
||||
{p.contract.reference} · início proposto{' '}
|
||||
{p.contract.starts_on}
|
||||
</p>
|
||||
<p className="whitespace-pre-wrap">
|
||||
{p.contract.terms}
|
||||
</p>
|
||||
<p className="mt-3 text-sm">
|
||||
Não comprova assinatura ou contratação concluída.
|
||||
</p>
|
||||
</Panel>
|
||||
)}
|
||||
<PeopleClarifications processId={p.id} data={clarifications} />
|
||||
<div className="space-y-6 print:hidden">
|
||||
{actions.map((command) => (
|
||||
<div
|
||||
id={`people-${command}`}
|
||||
className="scroll-mt-24"
|
||||
key={`${command}-${p.version}`}
|
||||
>
|
||||
<Action
|
||||
key={`${command}-${p.version}`}
|
||||
registry={registry}
|
||||
process={p}
|
||||
candidates={candidates}
|
||||
command={command}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Panel title="Histórico">
|
||||
<ol className="space-y-2 text-sm">
|
||||
{history.map((h) => (
|
||||
<li key={h.id}>
|
||||
{h.created_at} · {h.action} · pessoa #
|
||||
{h.user_id}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</Panel>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { FormErrors, PageTitle, controlClass } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
function TriageForm({
|
||||
processId,
|
||||
processVersion,
|
||||
submissionId,
|
||||
}: {
|
||||
processId: number;
|
||||
processVersion: number;
|
||||
submissionId: number;
|
||||
}) {
|
||||
const form = useForm({
|
||||
process_version: processVersion,
|
||||
operation_key: crypto.randomUUID(),
|
||||
outcome: 'accepted_for_analysis',
|
||||
reason: '',
|
||||
public_message: '',
|
||||
no_conflict: false,
|
||||
});
|
||||
return (
|
||||
<form
|
||||
className="space-y-3 border-t pt-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.post(
|
||||
`/pessoas/${processId}/recebidas/${submissionId}/triagem`,
|
||||
{ preserveState: false, preserveScroll: true },
|
||||
);
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<label className="grid gap-2">
|
||||
Decisão de triagem
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.outcome}
|
||||
onChange={(e) => form.setData('outcome', e.target.value)}
|
||||
>
|
||||
<option value="accepted_for_analysis">
|
||||
Aceite para análise
|
||||
</option>
|
||||
<option value="not_accepted">
|
||||
Não aceite para análise
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<p>
|
||||
Aceitar para análise aproveita os dados recebidos na avaliação.
|
||||
Não inclui automaticamente na base nem selecciona ou contrata a
|
||||
pessoa.
|
||||
</p>
|
||||
<label className="grid gap-2">
|
||||
Motivo interno (reservado)
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={4000}
|
||||
value={form.data.reason}
|
||||
onChange={(e) => form.setData('reason', e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-2">
|
||||
Comunicação destinada ao candidato
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={2000}
|
||||
value={form.data.public_message}
|
||||
onChange={(e) =>
|
||||
form.setData('public_message', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
required
|
||||
checked={form.data.no_conflict}
|
||||
onChange={(e) =>
|
||||
form.setData('no_conflict', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Declaro não ter conflito para esta intervenção.
|
||||
</label>
|
||||
<Button disabled={form.processing}>
|
||||
Registar decisão de triagem
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Submissions({
|
||||
process,
|
||||
publication,
|
||||
submissions,
|
||||
publicUrl,
|
||||
canPrepare = false,
|
||||
canTriage = false,
|
||||
}: {
|
||||
process: { id: number; title: string; version: number };
|
||||
canPrepare?: boolean;
|
||||
canTriage?: boolean;
|
||||
publication: null | {
|
||||
version: number;
|
||||
active: boolean;
|
||||
description: string;
|
||||
};
|
||||
submissions: {
|
||||
data: {
|
||||
id: number;
|
||||
decision?: null | {
|
||||
outcome: string;
|
||||
reason: string;
|
||||
public_message: string;
|
||||
created_at: string;
|
||||
people_application_id: number | null;
|
||||
};
|
||||
reference: string;
|
||||
received_at: string;
|
||||
snapshot: {
|
||||
opportunity: {
|
||||
form: {
|
||||
definition: {
|
||||
fields: { key: string; label: string }[];
|
||||
};
|
||||
};
|
||||
};
|
||||
profile: { data: { name: string; summary: string } };
|
||||
answers: Record<string, unknown>;
|
||||
};
|
||||
}[];
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
};
|
||||
publicUrl: string;
|
||||
}) {
|
||||
const form = useForm({
|
||||
version: publication?.version ?? 0,
|
||||
active: publication?.active ?? false,
|
||||
description: publication?.description ?? '',
|
||||
reason: '',
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<Head title="Candidaturas electrónicas recebidas" />
|
||||
<main className="mx-auto max-w-4xl space-y-6 p-6">
|
||||
<PageTitle
|
||||
title={process.title}
|
||||
eyebrow="Recepção electrónica"
|
||||
description="Publicação, recepção e triagem. Aceitação para análise não equivale a inclusão na base, selecção ou contratação."
|
||||
/>
|
||||
<Link className="underline" href={`/pessoas/${process.id}`}>
|
||||
Processo interno
|
||||
</Link>
|
||||
{canPrepare && (
|
||||
<form
|
||||
className="space-y-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.post(`/pessoas/${process.id}/publicacao`, {
|
||||
preserveState: false,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.active}
|
||||
onChange={(e) =>
|
||||
form.setData('active', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Disponibilizar oportunidade aos candidatos
|
||||
</label>
|
||||
<label className="grid gap-2">
|
||||
Descrição pública
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={5000}
|
||||
value={form.data.description}
|
||||
onChange={(e) =>
|
||||
form.setData('description', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-2">
|
||||
Motivo
|
||||
<textarea
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={4000}
|
||||
value={form.data.reason}
|
||||
onChange={(e) =>
|
||||
form.setData('reason', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<Button disabled={form.processing}>
|
||||
Guardar publicação
|
||||
</Button>
|
||||
</form>
|
||||
)}
|
||||
{canPrepare && publication?.active && (
|
||||
<Link className="underline" href={publicUrl}>
|
||||
Ver oportunidade na área do candidato
|
||||
</Link>
|
||||
)}
|
||||
<h2 className="text-xl font-semibold">
|
||||
Candidaturas recebidas
|
||||
</h2>
|
||||
{submissions.data.map((row) => (
|
||||
<article
|
||||
className="space-y-2 border-t py-4"
|
||||
key={row.reference}
|
||||
>
|
||||
<h3>
|
||||
{row.reference} · {row.snapshot.profile.data.name}
|
||||
</h3>
|
||||
<p>
|
||||
{row.received_at} ·{' '}
|
||||
{row.decision
|
||||
? row.decision.outcome ===
|
||||
'accepted_for_analysis'
|
||||
? 'Aceite para análise'
|
||||
: 'Não aceite para análise'
|
||||
: 'Recebida, por triar'}
|
||||
</p>
|
||||
<p>{row.snapshot.profile.data.summary}</p>
|
||||
<dl>
|
||||
{Object.entries(row.snapshot.answers).map(
|
||||
([key, value]) => (
|
||||
<div key={key}>
|
||||
<dt>
|
||||
{row.snapshot.opportunity.form.definition.fields.find(
|
||||
(field) => field.key === key,
|
||||
)?.label ?? 'Resposta'}
|
||||
</dt>
|
||||
<dd>
|
||||
{typeof value === 'object'
|
||||
? Object.values(
|
||||
value ?? {},
|
||||
).join(' · ')
|
||||
: typeof value === 'string' ||
|
||||
typeof value === 'number'
|
||||
? value
|
||||
: 'Não indicado'}
|
||||
</dd>
|
||||
</div>
|
||||
),
|
||||
)}
|
||||
</dl>
|
||||
{row.decision && (
|
||||
<section className="space-y-2">
|
||||
<p>Motivo interno: {row.decision.reason}</p>
|
||||
<p>
|
||||
Comunicação ao candidato:{' '}
|
||||
{row.decision.public_message}
|
||||
</p>
|
||||
{row.decision.people_application_id && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/pessoas/${process.id}?candidatura=${row.decision.people_application_id}`}
|
||||
>
|
||||
Abrir candidatura na avaliação
|
||||
</Link>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
{canTriage && !row.decision && (
|
||||
<TriageForm
|
||||
processId={process.id}
|
||||
processVersion={process.version}
|
||||
submissionId={row.id}
|
||||
/>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
{submissions.data.length === 0 && (
|
||||
<p>Nenhuma candidatura electrónica recebida.</p>
|
||||
)}
|
||||
<nav className="flex gap-4">
|
||||
{submissions.prev_page_url && (
|
||||
<Link href={submissions.prev_page_url}>Anterior</Link>
|
||||
)}
|
||||
{submissions.next_page_url && (
|
||||
<Link href={submissions.next_page_url}>Seguinte</Link>
|
||||
)}
|
||||
</nav>
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user