import { Link, useForm } from '@inertiajs/react'; import { Management, Pagination, button, control, states } from './shared'; import type { Paginated } from './shared'; type Record = { id: number; name?: string; title?: string; reference?: string; slug: string; is_active?: boolean; status?: string; geography_scope?: string; primary_territory?: { name: string; location_type: string; source_system?: string; source_code?: string | null; } | null; }; export default function Catalog({ resource, records, filters, sectors, geographyReviewCount = 0, }: { resource: 'sectors' | 'opportunities'; records: Paginated; filters: { q?: string; status?: string; sector_id?: number | string; geography_scope?: string; }; sectors: { id: number; name: string }[]; geographyReviewCount?: number; }) { const form = useForm({ q: filters.q ?? '', status: filters.status ?? '', sector_id: String(filters.sector_id ?? ''), geography_scope: filters.geography_scope ?? '', }); return ( Criar {resource === 'sectors' ? 'sector' : 'oportunidade'} {resource === 'opportunities' && (

{geographyReviewCount} oportunidade(s) aguardam confirmação do âmbito geográfico. A lista não altera localizações; confirme apenas com fontes existentes.

)}
{ event.preventDefault(); form.get(`/management/${resource}`, { preserveState: false, }); }} > form.setData('q', event.target.value)} maxLength={150} /> {resource === 'opportunities' && ( <> )} Limpar filtros {Object.values(form.errors).map((error) => (

{error}

))}
{records.data.map((record) => (

{record.name ?? record.title}

{record.reference ?? record.slug} ·{' '} {resource === 'sectors' ? record.is_active ? 'Activo' : 'Inactivo' : states[record.status ?? 'draft']}

{resource === 'opportunities' && record.geography_scope === 'unspecified' && (

Pendente de confirmação; território já registado:{' '} {record.primary_territory?.name ?? 'nenhum'} . Fonte do território:{' '} {record.primary_territory ?.source_system ?? 'não indicada'} {record.primary_territory?.source_code ? `, código ${record.primary_territory.source_code}` : ''} . A classificação não é alterada automaticamente.

)}
Editar
))}
{!records.data.length &&

Nenhum registo encontrado.

}
); }