@@ -0,0 +1,139 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
Panel,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { supplierFields } from '@/types/supplier';
|
||||
import type { Supplier } from '@/types/supplier';
|
||||
|
||||
export default function EditSupplier({ supplier }: { supplier: Supplier }) {
|
||||
const form = useForm({
|
||||
name: supplier.name,
|
||||
nuit: supplier.nuit,
|
||||
contact: supplier.contact,
|
||||
email: supplier.email,
|
||||
phone: supplier.phone,
|
||||
address: supplier.address,
|
||||
category: supplier.category,
|
||||
beneficiaries: supplier.beneficiaries,
|
||||
document_references: supplier.document_references,
|
||||
diligence_notes: supplier.diligence_notes,
|
||||
next_review: supplier.next_review.slice(0, 10),
|
||||
blocked: supplier.blocked,
|
||||
version: supplier.version,
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<Head title={`Editar ${supplier.name}`} />
|
||||
<div className="mx-auto flex w-full max-w-4xl flex-col gap-7 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow="Fornecedores"
|
||||
title="Editar ficha do fornecedor"
|
||||
description={supplier.name}
|
||||
/>
|
||||
<Panel title="Dados e renovação da diligência">
|
||||
<p className="mb-5 rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-100">
|
||||
Alterações à ficha retiram a validação actual. Finanças
|
||||
terá de rever o fornecedor antes de este voltar a ser
|
||||
elegível para novas cotações.
|
||||
</p>
|
||||
<form
|
||||
className="space-y-5"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.put(`/fornecedores/${supplier.id}`);
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{Object.entries(supplierFields).map(
|
||||
([key, label]) => {
|
||||
const name =
|
||||
key as keyof typeof supplierFields;
|
||||
const multiline = [
|
||||
'beneficiaries',
|
||||
'document_references',
|
||||
'diligence_notes',
|
||||
'address',
|
||||
].includes(key);
|
||||
return (
|
||||
<div className="space-y-2" key={key}>
|
||||
<Label htmlFor={`supplier-${key}`}>
|
||||
{label}
|
||||
</Label>
|
||||
{multiline ? (
|
||||
<textarea
|
||||
id={`supplier-${key}`}
|
||||
required
|
||||
className={`${controlClass} h-24 py-2`}
|
||||
value={form.data[name]}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
name,
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<Input
|
||||
id={`supplier-${key}`}
|
||||
required
|
||||
type={
|
||||
key === 'email'
|
||||
? 'email'
|
||||
: key ===
|
||||
'next_review'
|
||||
? 'date'
|
||||
: 'text'
|
||||
}
|
||||
value={form.data[name]}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
name,
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</div>
|
||||
<label className="flex items-center gap-3 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.blocked}
|
||||
onChange={(e) =>
|
||||
form.setData('blocked', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Fornecedor consta da lista de impedidos
|
||||
</label>
|
||||
<div className="flex justify-end gap-3">
|
||||
<Button asChild variant="outline">
|
||||
<Link href={`/fornecedores/${supplier.id}`}>
|
||||
Cancelar
|
||||
</Link>
|
||||
</Button>
|
||||
<Button disabled={form.processing}>
|
||||
Guardar alterações
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Panel>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
EditSupplier.layout = {
|
||||
breadcrumbs: [
|
||||
{ title: 'Fornecedores', href: '/fornecedores' },
|
||||
{ title: 'Editar ficha', href: '#' },
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,348 @@
|
||||
import { Head, Link, router, useForm } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
Panel,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
type Supplier = {
|
||||
id: number;
|
||||
name: string;
|
||||
nuit: string;
|
||||
contact: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
address: string;
|
||||
category: string;
|
||||
beneficiaries: string;
|
||||
document_references: string;
|
||||
diligence_notes: string;
|
||||
status: string;
|
||||
blocked: boolean;
|
||||
next_review: string;
|
||||
review_comment: string | null;
|
||||
version: number;
|
||||
};
|
||||
const labels: Record<string, string> = {
|
||||
pending: 'Pendente de validação',
|
||||
active: 'Activo',
|
||||
suspended: 'Suspenso',
|
||||
};
|
||||
const fields = {
|
||||
name: 'Nome legal',
|
||||
nuit: 'NUIT (9 dígitos)',
|
||||
contact: 'Pessoa de contacto',
|
||||
email: 'Email',
|
||||
phone: 'Telefone',
|
||||
address: 'Morada',
|
||||
category: 'Categoria de fornecimento',
|
||||
beneficiaries: 'Beneficiários efectivos',
|
||||
document_references: 'Referências dos documentos verificados',
|
||||
diligence_notes: 'Resultado da diligência devida',
|
||||
next_review: 'Próxima revisão',
|
||||
};
|
||||
export default function Suppliers({
|
||||
suppliers,
|
||||
filters,
|
||||
canCreate,
|
||||
canReview,
|
||||
}: {
|
||||
suppliers: {
|
||||
data: Supplier[];
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
};
|
||||
filters: { search?: string };
|
||||
canCreate: boolean;
|
||||
canReview: boolean;
|
||||
}) {
|
||||
const form = useForm({
|
||||
name: '',
|
||||
nuit: '',
|
||||
contact: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
address: '',
|
||||
category: '',
|
||||
beneficiaries: '',
|
||||
document_references: '',
|
||||
diligence_notes: '',
|
||||
next_review: '',
|
||||
blocked: false,
|
||||
});
|
||||
const review = useForm({ status: 'active', comment: '', version: 0 });
|
||||
const [creating, setCreating] = useState(false);
|
||||
const [selected, setSelected] = useState<Supplier | null>(null);
|
||||
const [search, setSearch] = useState(filters.search ?? '');
|
||||
return (
|
||||
<>
|
||||
<Head title="Fornecedores" />
|
||||
<div className="mx-auto flex w-full max-w-7xl flex-col gap-7 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow="Consulta ao mercado"
|
||||
title="Fornecedores"
|
||||
description="Cadastro, diligência devida e validação independente por Finanças."
|
||||
action={
|
||||
canCreate ? (
|
||||
<Button onClick={() => setCreating(!creating)}>
|
||||
{creating
|
||||
? 'Fechar formulário'
|
||||
: 'Novo fornecedor'}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
{creating && (
|
||||
<Panel title="Registar fornecedor">
|
||||
<form
|
||||
className="space-y-5"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.post('/fornecedores', {
|
||||
onSuccess: () => {
|
||||
form.reset();
|
||||
setCreating(false);
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={form.errors} />
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{Object.entries(fields).map(([key, label]) => {
|
||||
const name = key as keyof typeof fields;
|
||||
return (
|
||||
<div className="space-y-2" key={key}>
|
||||
<Label htmlFor={key}>{label}</Label>
|
||||
<Input
|
||||
id={key}
|
||||
required
|
||||
type={
|
||||
key === 'email'
|
||||
? 'email'
|
||||
: key === 'next_review'
|
||||
? 'date'
|
||||
: 'text'
|
||||
}
|
||||
value={form.data[name]}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
name,
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<label className="flex items-center gap-3 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.blocked}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
'blocked',
|
||||
e.target.checked,
|
||||
)
|
||||
}
|
||||
/>
|
||||
Fornecedor consta da lista de impedidos
|
||||
</label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Registe as referências do alvará, situação
|
||||
fiscal e declaração de conflitos que verificou.
|
||||
Após o registo pode abrir a ficha para anexar os
|
||||
documentos privados. Os dados bancários serão
|
||||
tratados numa etapa posterior.
|
||||
</p>
|
||||
<Button disabled={form.processing}>
|
||||
Guardar para validação
|
||||
</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
)}
|
||||
<Panel title="Directório de fornecedores">
|
||||
<form
|
||||
className="mb-5 flex gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
router.get(
|
||||
'/fornecedores',
|
||||
{ search },
|
||||
{ preserveState: true },
|
||||
);
|
||||
}}
|
||||
>
|
||||
<Input
|
||||
aria-label="Pesquisar fornecedor"
|
||||
placeholder="Pesquisar nome ou NUIT"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
<Button variant="outline">Pesquisar</Button>
|
||||
</form>
|
||||
<div className="overflow-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead className="border-b text-muted-foreground">
|
||||
<tr>
|
||||
{[
|
||||
'Fornecedor',
|
||||
'NUIT',
|
||||
'Estado',
|
||||
'Próxima revisão',
|
||||
'',
|
||||
].map((h, i) => (
|
||||
<th className="pr-4 pb-3" key={i}>
|
||||
{h}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{suppliers.data.map((s) => (
|
||||
<tr className="border-b" key={s.id}>
|
||||
<td className="py-4 pr-4">
|
||||
<strong>{s.name}</strong>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{s.category}
|
||||
</p>
|
||||
</td>
|
||||
<td className="pr-4">{s.nuit}</td>
|
||||
<td className="pr-4">
|
||||
{labels[s.status]}
|
||||
{s.blocked && (
|
||||
<span className="block text-red-700">
|
||||
Impedido
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="pr-4">
|
||||
{s.next_review.slice(0, 10)}
|
||||
</td>
|
||||
<td>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setSelected(s);
|
||||
review.reset();
|
||||
review.clearErrors();
|
||||
review.setData(
|
||||
'version',
|
||||
s.version,
|
||||
);
|
||||
}}
|
||||
>
|
||||
Ver ficha
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{!suppliers.data.length && (
|
||||
<p className="py-8 text-center text-muted-foreground">
|
||||
Nenhum fornecedor encontrado.
|
||||
</p>
|
||||
)}
|
||||
<div className="mt-4 flex gap-4">
|
||||
{suppliers.prev_page_url && (
|
||||
<Link href={suppliers.prev_page_url}>Anterior</Link>
|
||||
)}
|
||||
{suppliers.next_page_url && (
|
||||
<Link href={suppliers.next_page_url}>Seguinte</Link>
|
||||
)}
|
||||
</div>
|
||||
</Panel>
|
||||
{selected && (
|
||||
<Panel
|
||||
title={selected.name}
|
||||
description={`NUIT ${selected.nuit}`}
|
||||
>
|
||||
<Button asChild variant="outline" className="mb-5">
|
||||
<Link href={`/fornecedores/${selected.id}`}>
|
||||
Abrir ficha, edição e documentos
|
||||
</Link>
|
||||
</Button>
|
||||
<dl className="grid gap-4 text-sm md:grid-cols-2">
|
||||
{Object.entries(fields).map(([key, label]) => (
|
||||
<div key={key}>
|
||||
<dt className="text-muted-foreground">
|
||||
{label}
|
||||
</dt>
|
||||
<dd className="mt-1 whitespace-pre-wrap">
|
||||
{selected[key as keyof typeof fields]}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
{selected.review_comment && (
|
||||
<p className="mt-5 text-sm">
|
||||
Última validação: {selected.review_comment}
|
||||
</p>
|
||||
)}
|
||||
{canReview && (
|
||||
<form
|
||||
className="mt-6 space-y-4 border-t pt-5"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
review.post(
|
||||
`/fornecedores/${selected.id}/validar`,
|
||||
{ onSuccess: () => setSelected(null) },
|
||||
);
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={review.errors} />
|
||||
<Label htmlFor="review-status">
|
||||
Resultado da validação
|
||||
</Label>
|
||||
<select
|
||||
id="review-status"
|
||||
className={controlClass}
|
||||
value={review.data.status}
|
||||
onChange={(e) =>
|
||||
review.setData('status', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="active">
|
||||
Activar fornecedor
|
||||
</option>
|
||||
<option value="suspended">
|
||||
Suspender fornecedor
|
||||
</option>
|
||||
</select>
|
||||
<Label htmlFor="review-comment">
|
||||
Fundamento da decisão
|
||||
</Label>
|
||||
<textarea
|
||||
id="review-comment"
|
||||
className={controlClass}
|
||||
required
|
||||
minLength={10}
|
||||
value={review.data.comment}
|
||||
onChange={(e) =>
|
||||
review.setData(
|
||||
'comment',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Button disabled={review.processing}>
|
||||
Registar decisão
|
||||
</Button>
|
||||
</form>
|
||||
)}
|
||||
</Panel>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Suppliers.layout = {
|
||||
breadcrumbs: [{ title: 'Fornecedores', href: '/fornecedores' }],
|
||||
};
|
||||
@@ -0,0 +1,318 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { Download, FileLock2, Pencil, Upload } from 'lucide-react';
|
||||
import { useRef } from 'react';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
Panel,
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { date } from '@/types/procurement';
|
||||
import {
|
||||
documentTypes,
|
||||
supplierFields,
|
||||
supplierStatuses,
|
||||
} from '@/types/supplier';
|
||||
import type { Supplier } from '@/types/supplier';
|
||||
|
||||
type Document = {
|
||||
id: number;
|
||||
original_name: string;
|
||||
document_type: string;
|
||||
size: number;
|
||||
created_at: string;
|
||||
sha256: string;
|
||||
};
|
||||
type Props = {
|
||||
supplier: Supplier;
|
||||
documents: Document[];
|
||||
canEdit: boolean;
|
||||
canDocuments: boolean;
|
||||
canReview: boolean;
|
||||
};
|
||||
|
||||
export default function SupplierShow({
|
||||
supplier,
|
||||
documents,
|
||||
canEdit,
|
||||
canDocuments,
|
||||
canReview,
|
||||
}: Props) {
|
||||
const upload = useForm<{ file: File | null; document_type: string }>({
|
||||
file: null,
|
||||
document_type: 'license',
|
||||
});
|
||||
const review = useForm({ status: 'active', comment: '' });
|
||||
const fileInput = useRef<HTMLInputElement>(null);
|
||||
return (
|
||||
<>
|
||||
<Head title={supplier.name} />
|
||||
<div className="mx-auto flex w-full max-w-5xl flex-col gap-7 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow="Ficha de fornecedor"
|
||||
title={supplier.name}
|
||||
description={`NUIT ${supplier.nuit} · ${supplierStatuses[supplier.status]}${supplier.blocked ? ' · Impedido' : ''}`}
|
||||
action={
|
||||
canEdit ? (
|
||||
<Button asChild>
|
||||
<Link
|
||||
href={`/fornecedores/${supplier.id}/editar`}
|
||||
>
|
||||
<Pencil className="size-4" />
|
||||
Editar ficha
|
||||
</Link>
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<Panel title="Dados do fornecedor">
|
||||
<dl className="grid gap-5 text-sm md:grid-cols-2">
|
||||
{Object.entries(supplierFields).map(([key, label]) => (
|
||||
<div key={key}>
|
||||
<dt className="text-muted-foreground">
|
||||
{label}
|
||||
</dt>
|
||||
<dd className="mt-1 whitespace-pre-wrap">
|
||||
{key === 'next_review'
|
||||
? date(supplier.next_review)
|
||||
: supplier[
|
||||
key as keyof typeof supplierFields
|
||||
]}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
{supplier.review_comment && (
|
||||
<p className="mt-5 border-t pt-4 text-sm">
|
||||
Última validação: {supplier.review_comment}
|
||||
</p>
|
||||
)}
|
||||
</Panel>
|
||||
{canDocuments ? (
|
||||
<Panel
|
||||
title="Documentos privados"
|
||||
description="Acesso restrito a Administração, Procurement e Finanças da empresa. As transferências ficam registadas em auditoria."
|
||||
>
|
||||
<div className="space-y-3">
|
||||
{documents.map((document) => (
|
||||
<div
|
||||
className="flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4"
|
||||
key={document.id}
|
||||
>
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<FileLock2 className="mt-1 size-5 shrink-0 text-teal-700" />
|
||||
<div className="min-w-0">
|
||||
<p className="text-sm font-medium break-all">
|
||||
{document.original_name}
|
||||
</p>
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
{
|
||||
documentTypes[
|
||||
document.document_type
|
||||
]
|
||||
}{' '}
|
||||
·{' '}
|
||||
{Math.ceil(
|
||||
document.size / 1024,
|
||||
)}{' '}
|
||||
KB · {date(document.created_at)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button asChild variant="outline" size="sm">
|
||||
<a
|
||||
href={`/fornecedores/${supplier.id}/documentos/${document.id}`}
|
||||
>
|
||||
<Download className="size-4" />
|
||||
Descarregar
|
||||
<span className="sr-only">
|
||||
{' '}
|
||||
{document.original_name}
|
||||
</span>
|
||||
</a>
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
{documents.length === 0 && (
|
||||
<p className="py-4 text-sm text-muted-foreground">
|
||||
Ainda não existem documentos anexados a esta
|
||||
ficha.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{canEdit && (
|
||||
<form
|
||||
className="mt-6 space-y-4 border-t pt-5"
|
||||
encType="multipart/form-data"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
upload.post(
|
||||
`/fornecedores/${supplier.id}/documentos`,
|
||||
{
|
||||
forceFormData: true,
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
upload.reset();
|
||||
if (fileInput.current)
|
||||
fileInput.current.value =
|
||||
'';
|
||||
},
|
||||
},
|
||||
);
|
||||
}}
|
||||
>
|
||||
<h3 className="text-sm font-semibold">
|
||||
Anexar documento
|
||||
</h3>
|
||||
<FormErrors errors={upload.errors} />
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="document-type">
|
||||
Tipo de documento
|
||||
</Label>
|
||||
<select
|
||||
id="document-type"
|
||||
className={controlClass}
|
||||
value={upload.data.document_type}
|
||||
onChange={(e) =>
|
||||
upload.setData(
|
||||
'document_type',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
{Object.entries(documentTypes).map(
|
||||
([value, label]) => (
|
||||
<option
|
||||
value={value}
|
||||
key={value}
|
||||
>
|
||||
{label}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="supplier-file">
|
||||
Ficheiro (PDF, JPEG ou PNG; até 2
|
||||
MB)
|
||||
</Label>
|
||||
<Input
|
||||
id="supplier-file"
|
||||
ref={fileInput}
|
||||
type="file"
|
||||
accept=".pdf,.jpg,.jpeg,.png"
|
||||
required
|
||||
onChange={(e) =>
|
||||
upload.setData(
|
||||
'file',
|
||||
e.target.files?.[0] ?? null,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
O envio de um documento devolve o fornecedor
|
||||
ao estado pendente de validação. Os
|
||||
documentos existentes permanecem no
|
||||
histórico.
|
||||
</p>
|
||||
{upload.progress && (
|
||||
<p className="text-xs" role="status">
|
||||
Envio: {upload.progress.percentage}%
|
||||
</p>
|
||||
)}
|
||||
<Button disabled={upload.processing}>
|
||||
<Upload className="size-4" />
|
||||
Enviar documento
|
||||
</Button>
|
||||
</form>
|
||||
)}
|
||||
</Panel>
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
O acesso aos documentos está reservado a Administração,
|
||||
Procurement e Finanças.
|
||||
</p>
|
||||
)}
|
||||
{canReview && (
|
||||
<Panel
|
||||
title="Validação independente por Finanças"
|
||||
description="Confira os dados e os documentos actuais antes de decidir."
|
||||
>
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
review.transform((data) => ({
|
||||
...data,
|
||||
version: supplier.version,
|
||||
}));
|
||||
review.post(
|
||||
`/fornecedores/${supplier.id}/validar`,
|
||||
{
|
||||
preserveScroll: true,
|
||||
onSuccess: () => review.reset(),
|
||||
},
|
||||
);
|
||||
}}
|
||||
>
|
||||
<FormErrors errors={review.errors} />
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="review-result">Resultado</Label>
|
||||
<select
|
||||
id="review-result"
|
||||
className={controlClass}
|
||||
value={review.data.status}
|
||||
onChange={(e) =>
|
||||
review.setData('status', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="active">
|
||||
Activar fornecedor
|
||||
</option>
|
||||
<option value="suspended">
|
||||
Suspender fornecedor
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="review-reason">
|
||||
Fundamento da decisão
|
||||
</Label>
|
||||
<textarea
|
||||
id="review-reason"
|
||||
className={`${controlClass} h-24 py-2`}
|
||||
required
|
||||
minLength={10}
|
||||
maxLength={2000}
|
||||
value={review.data.comment}
|
||||
onChange={(e) =>
|
||||
review.setData(
|
||||
'comment',
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<Button disabled={review.processing}>
|
||||
Registar decisão
|
||||
</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
SupplierShow.layout = {
|
||||
breadcrumbs: [
|
||||
{ title: 'Fornecedores', href: '/fornecedores' },
|
||||
{ title: 'Ficha e documentos', href: '#' },
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user