100 lines
3.9 KiB
TypeScript
100 lines
3.9 KiB
TypeScript
import { Head, Link } from '@inertiajs/react';
|
|
import { offerStates } from '@/lib/offer-editorial';
|
|
import OfferNavigation from '@/components/offer-navigation';
|
|
|
|
export default function OfferPreparations({
|
|
records,
|
|
canCreate,
|
|
filters = {},
|
|
}: {
|
|
records: {
|
|
data: {
|
|
id: number;
|
|
title: string | null;
|
|
reference: string;
|
|
state: string;
|
|
availability?: string;
|
|
}[];
|
|
prev_page_url: string | null;
|
|
next_page_url: string | null;
|
|
};
|
|
canCreate: boolean;
|
|
filters?: {
|
|
state?: string;
|
|
operational?: boolean;
|
|
pending_reports?: boolean;
|
|
};
|
|
}) {
|
|
return (
|
|
<main className="mx-auto w-full max-w-5xl space-y-6 p-4 md:p-8">
|
|
<Head title="As minhas ofertas" />
|
|
<header className="flex flex-wrap items-center justify-between gap-4">
|
|
<div>
|
|
<h1 className="text-2xl font-semibold">
|
|
{filters.operational || filters.pending_reports
|
|
? 'Ofertas — acompanhamento'
|
|
: 'As minhas ofertas'}
|
|
</h1>
|
|
<p className="text-muted-foreground mt-2">
|
|
Prepare e guarde as suas ofertas num espaço privado.
|
|
</p>
|
|
</div>
|
|
{canCreate && (
|
|
<Link
|
|
className="bg-primary text-primary-foreground rounded-md px-4 py-2"
|
|
href="/minhas-oportunidades/ofertas/criar"
|
|
>
|
|
Preparar oferta
|
|
</Link>
|
|
)}
|
|
</header>
|
|
<OfferNavigation canCreate={canCreate} filters={filters} />
|
|
{!records.data.length && (
|
|
<p>Ainda não existem ofertas neste âmbito.</p>
|
|
)}
|
|
<ul className="space-y-3">
|
|
{records.data.map((record) => (
|
|
<li key={record.id} className="rounded-lg border p-4">
|
|
<Link
|
|
className="font-medium underline"
|
|
href={`/minhas-oportunidades/ofertas/${record.id}`}
|
|
>
|
|
{record.title || 'Oferta por completar'}
|
|
</Link>
|
|
<p className="text-muted-foreground mt-1 text-sm">
|
|
{record.reference} ·{' '}
|
|
{offerStates[record.state] ?? record.state}
|
|
{record.availability && (
|
|
<>
|
|
{' '}
|
|
·{' '}
|
|
{
|
|
(
|
|
{
|
|
available: 'Disponível',
|
|
withdrawn: 'Retirada',
|
|
expired: 'Expirada',
|
|
revalidation:
|
|
'Aguarda nova validação',
|
|
unavailable: 'Indisponível',
|
|
} as Record<string, string>
|
|
)[record.availability]
|
|
}
|
|
</>
|
|
)}
|
|
</p>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
<nav aria-label="Páginas das ofertas" className="flex gap-4">
|
|
{records.prev_page_url && (
|
|
<Link href={records.prev_page_url}>Anterior</Link>
|
|
)}
|
|
{records.next_page_url && (
|
|
<Link href={records.next_page_url}>Seguinte</Link>
|
|
)}
|
|
</nav>
|
|
</main>
|
|
);
|
|
}
|