commit21
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Head, Link, router } from '@inertiajs/react';
|
||||
import { PageTitle, Panel } from '@/components/procurement';
|
||||
import { Head, Link, router, useForm } from '@inertiajs/react';
|
||||
import { PageTitle, Panel, controlClass } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { roleLabels, statusLabels } from '@/types/procurement';
|
||||
|
||||
@@ -7,7 +7,9 @@ type Props = {
|
||||
ready: boolean;
|
||||
unread: number;
|
||||
view: string;
|
||||
search: string;
|
||||
notices: {
|
||||
current_page: number;
|
||||
total: number;
|
||||
data: {
|
||||
id: number;
|
||||
@@ -24,7 +26,14 @@ type Props = {
|
||||
next_page_url: string | null;
|
||||
};
|
||||
};
|
||||
export default function Notices({ ready, unread, view, notices }: Props) {
|
||||
export default function Notices({
|
||||
ready,
|
||||
unread,
|
||||
view,
|
||||
search,
|
||||
notices,
|
||||
}: Props) {
|
||||
const form = useForm({ view, search });
|
||||
return (
|
||||
<>
|
||||
<Head title="Avisos de aprovação" />
|
||||
@@ -61,6 +70,56 @@ export default function Notices({ ready, unread, view, notices }: Props) {
|
||||
}
|
||||
description="Intervenções concluídas deixam a fila pendente. Resultados registados mantêm-se visíveis ao requisitante com acesso actual. Não são criados avisos retroactivos para decisões antigas."
|
||||
>
|
||||
<details
|
||||
className="mb-4 rounded border p-3"
|
||||
open={Boolean(search)}
|
||||
>
|
||||
<summary className="cursor-pointer text-sm">
|
||||
Localizar por referência da requisição
|
||||
</summary>
|
||||
<form
|
||||
className="mt-3 flex flex-wrap items-end gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
view,
|
||||
}));
|
||||
form.get('/requisicoes/avisos', {
|
||||
preserveState: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<label className="text-sm">
|
||||
Referência
|
||||
<input
|
||||
className={controlClass}
|
||||
maxLength={100}
|
||||
value={form.data.search}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'search',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<Button disabled={form.processing}>Procurar</Button>
|
||||
<Link
|
||||
className="text-sm underline"
|
||||
href={`/requisicoes/avisos?view=${view}`}
|
||||
>
|
||||
Limpar pesquisa
|
||||
</Link>
|
||||
{form.errors.search && (
|
||||
<p role="alert">{form.errors.search}</p>
|
||||
)}
|
||||
</form>
|
||||
</details>
|
||||
<p className="mb-3 text-sm text-muted-foreground">
|
||||
{notices.total} aviso(s) nesta consulta · Página{' '}
|
||||
{notices.current_page}
|
||||
</p>
|
||||
{!ready ? (
|
||||
<p>Instalação dos avisos internos pendente.</p>
|
||||
) : notices.data.length === 0 ? (
|
||||
@@ -102,6 +161,11 @@ export default function Notices({ ready, unread, view, notices }: Props) {
|
||||
onClick={() =>
|
||||
router.post(
|
||||
`/requisicoes/avisos/${notice.id}/ler`,
|
||||
{
|
||||
view,
|
||||
search,
|
||||
page: notices.current_page,
|
||||
},
|
||||
)
|
||||
}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user