@@ -1,4 +1,7 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { useProcurementPreparationIdentity } from '@/hooks/use-procurement-preparation-identity';
|
||||
import { hasPreparationChanges } from '@/lib/requisition-history';
|
||||
import { Printer } from 'lucide-react';
|
||||
import SupplierImprovements from '@/components/supplier-improvements';
|
||||
import type { ImprovementData } from '@/components/supplier-improvements';
|
||||
@@ -33,6 +36,7 @@ type Evaluation = {
|
||||
payload: EvaluationPayload;
|
||||
review_reason: string | null;
|
||||
reviewed_at: string | null;
|
||||
reviewed_by?: number | null;
|
||||
};
|
||||
type History = {
|
||||
id: number;
|
||||
@@ -83,11 +87,27 @@ export default function SupplierEvaluation({
|
||||
improvements: ImprovementData;
|
||||
responses: ResponseData;
|
||||
}) {
|
||||
const form = useForm({ version: e.version, payload: e.payload });
|
||||
const command = useForm({ version: e.version, reason: '' });
|
||||
const preparation = useProcurementPreparationIdentity(
|
||||
`supplier-evaluation:${e.id}:${e.version}`,
|
||||
);
|
||||
const form = useForm(`${preparation}:evidence`, {
|
||||
version: e.version,
|
||||
payload: e.payload,
|
||||
});
|
||||
const command = useForm(`${preparation}:decision`, {
|
||||
version: e.version,
|
||||
reason: '',
|
||||
});
|
||||
const base = `/fornecedores/avaliacoes/${e.id}`;
|
||||
const dirty =
|
||||
JSON.stringify(form.data.payload) !== JSON.stringify(e.payload);
|
||||
const dirty = hasPreparationChanges(
|
||||
{ payload: e.payload },
|
||||
{ payload: form.data.payload },
|
||||
);
|
||||
const evidenceRef = usePreparationDirty(dirty, canEdit);
|
||||
const decisionRef = usePreparationDirty(
|
||||
command.data.reason !== '',
|
||||
canReview,
|
||||
);
|
||||
const waiting = e.payload.criteria.filter((row) =>
|
||||
['pending', 'insufficient'].includes(row.result),
|
||||
).length;
|
||||
@@ -139,6 +159,75 @@ export default function SupplierEvaluation({
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<details className="rounded-xl border bg-card p-4 print:hidden">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
Ir para uma área da avaliação
|
||||
</summary>
|
||||
<nav
|
||||
aria-label="Áreas da avaliação do fornecedor"
|
||||
className="mt-4"
|
||||
>
|
||||
<ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{[
|
||||
[
|
||||
'evaluation-evidence',
|
||||
canEdit
|
||||
? 'Preparar evidências'
|
||||
: 'Âmbito e evidências',
|
||||
],
|
||||
...(e.review_reason
|
||||
? [
|
||||
[
|
||||
'evaluation-last-review',
|
||||
'Última decisão documentada',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(canReview
|
||||
? [
|
||||
[
|
||||
'evaluation-review',
|
||||
'Conferência independente',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(canRevise
|
||||
? [
|
||||
[
|
||||
'evaluation-revision',
|
||||
'Preparar nova revisão',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(!reportOnly
|
||||
? [
|
||||
[
|
||||
'evaluation-history',
|
||||
'Histórico de alterações e decisões',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
[
|
||||
'evaluation-improvements',
|
||||
'Medidas de melhoria',
|
||||
],
|
||||
[
|
||||
'evaluation-responses',
|
||||
'Contraditório do fornecedor',
|
||||
],
|
||||
].map(([id, label]) => (
|
||||
<li key={id}>
|
||||
<a
|
||||
href={`#${id}`}
|
||||
className="font-medium underline underline-offset-4"
|
||||
>
|
||||
{label}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
</details>
|
||||
{notice && (
|
||||
<p
|
||||
role="status"
|
||||
@@ -181,8 +270,13 @@ export default function SupplierEvaluation({
|
||||
só a qualificação, suspensão ou elegibilidade do fornecedor.
|
||||
</p>
|
||||
{canEdit ? (
|
||||
<Panel title="Preparar e conservar evidências">
|
||||
<Panel
|
||||
id="evaluation-evidence"
|
||||
title="Preparar e conservar evidências"
|
||||
>
|
||||
<form
|
||||
ref={evidenceRef}
|
||||
data-preparation-dirty={dirty ? 'true' : undefined}
|
||||
className="space-y-5"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
@@ -241,7 +335,10 @@ export default function SupplierEvaluation({
|
||||
</Panel>
|
||||
) : (
|
||||
<>
|
||||
<Panel title="Âmbito e evidências">
|
||||
<Panel
|
||||
id="evaluation-evidence"
|
||||
title="Âmbito e evidências"
|
||||
>
|
||||
<div className="space-y-4 text-sm">
|
||||
<p>
|
||||
Componente:{' '}
|
||||
@@ -321,18 +418,41 @@ export default function SupplierEvaluation({
|
||||
</>
|
||||
)}
|
||||
{e.review_reason && (
|
||||
<Panel title="Última decisão documentada">
|
||||
<p className="text-sm whitespace-pre-wrap">
|
||||
{e.review_reason}
|
||||
</p>
|
||||
<p className="mt-2 text-xs text-muted-foreground">
|
||||
{e.reviewed_at}
|
||||
</p>
|
||||
</Panel>
|
||||
<div className="print:break-inside-avoid">
|
||||
<Panel
|
||||
id="evaluation-last-review"
|
||||
title="Última decisão documentada"
|
||||
>
|
||||
{e.reviewed_by != null && (
|
||||
<p className="mb-2 text-sm">
|
||||
Revisor:{' '}
|
||||
{people[e.reviewed_by] ??
|
||||
`#${e.reviewed_by}`}
|
||||
</p>
|
||||
)}
|
||||
<p className="text-sm whitespace-pre-wrap">
|
||||
{e.review_reason}
|
||||
</p>
|
||||
<p className="mt-2 text-xs text-muted-foreground">
|
||||
{e.reviewed_at
|
||||
? new Date(e.reviewed_at).toLocaleString(
|
||||
'pt-MZ',
|
||||
)
|
||||
: 'Data não indicada no original'}
|
||||
</p>
|
||||
</Panel>
|
||||
</div>
|
||||
)}
|
||||
{canReview && (
|
||||
<Panel title="Conferência independente">
|
||||
<Panel
|
||||
id="evaluation-review"
|
||||
title="Conferência independente"
|
||||
>
|
||||
<form
|
||||
ref={decisionRef}
|
||||
data-preparation-dirty={
|
||||
command.data.reason !== '' ? 'true' : undefined
|
||||
}
|
||||
className="space-y-4"
|
||||
onSubmit={(event) => event.preventDefault()}
|
||||
>
|
||||
@@ -402,7 +522,10 @@ export default function SupplierEvaluation({
|
||||
</p>
|
||||
)}
|
||||
{canRevise && (
|
||||
<Panel title="Rectificar sem apagar a avaliação aprovada">
|
||||
<Panel
|
||||
id="evaluation-revision"
|
||||
title="Rectificar sem apagar a avaliação aprovada"
|
||||
>
|
||||
<p className="mb-3 text-sm">
|
||||
A rectificação cria outro rascunho, com número de
|
||||
revisão próprio. A versão aprovada anterior mantém o
|
||||
@@ -426,7 +549,10 @@ export default function SupplierEvaluation({
|
||||
</Panel>
|
||||
)}
|
||||
{!reportOnly && (
|
||||
<Panel title="Histórico de alterações e decisões">
|
||||
<Panel
|
||||
id="evaluation-history"
|
||||
title="Histórico de alterações e decisões"
|
||||
>
|
||||
<p className="mb-3 text-sm">
|
||||
{history.total} registos preservados. Cada alteração
|
||||
conserva a sua fotografia; versões aprovadas não são
|
||||
|
||||
@@ -208,6 +208,7 @@ export default function Suppliers({
|
||||
</div>
|
||||
)}
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="mb-5 flex gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user