import { Head, Link, useForm } from '@inertiajs/react'; import { FormErrors, PageTitle, Panel, controlClass, } from '@/components/procurement'; import { Button } from '@/components/ui/button'; type Group = { key: string; title: string; records: { total: number; current_page: number; last_page: number; prev_page_url: string | null; next_page_url: string | null; data: { id: number; title: string; detail: string; href: string }[]; }; }; const statuses: Record = { draft: 'Rascunho', pending: 'Pendente', approved: 'Aprovada', rejected: 'Rejeitada', cancelled: 'Cancelada', issued: 'Emitida', active: 'Activo', inactive: 'Inactivo', }; export default function ProcurementSearch({ term, groups, }: { term: string; groups: Group[]; }) { const form = useForm({ q: term }); return ( <>
{ e.preventDefault(); form.get('/compras/pesquisa', { preserveState: true, }); }} >
{term.trim().length < 2 && (

Introduza pelo menos dois caracteres para pesquisar.

)} {groups.map((group) => ( {group.records.data.length === 0 ? (

Nenhum resultado no seu âmbito de acesso.

) : (
    {group.records.data.map((record) => (
  • {record.title} {statuses[record.detail] ?? record.detail}
  • ))}
)}
))}
); }