@@ -16,6 +16,10 @@ type Entry = {
|
||||
opportunity_category: string | null;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
can_edit?: boolean;
|
||||
working_status?: string;
|
||||
draft_title?: string;
|
||||
publication?: { scope: string; label: string; public_catalog: boolean };
|
||||
};
|
||||
export default function Opportunities({
|
||||
records,
|
||||
@@ -24,10 +28,13 @@ export default function Opportunities({
|
||||
categories,
|
||||
sectors,
|
||||
geographyReviewCount,
|
||||
basePath = '/management/opportunities',
|
||||
canCreate = true,
|
||||
}: {
|
||||
records: Paginated<Entry>;
|
||||
filters: {
|
||||
q?: string;
|
||||
queue?: string;
|
||||
status?: string;
|
||||
category?: string;
|
||||
deleted?: boolean;
|
||||
@@ -38,9 +45,12 @@ export default function Opportunities({
|
||||
categories: string[];
|
||||
sectors: { id: number; name: string }[];
|
||||
geographyReviewCount: number;
|
||||
basePath?: string;
|
||||
canCreate?: boolean;
|
||||
}) {
|
||||
const form = useForm({
|
||||
q: filters.q ?? '',
|
||||
queue: filters.queue ?? '',
|
||||
status: filters.status ?? '',
|
||||
category: filters.category ?? '',
|
||||
deleted: Boolean(filters.deleted),
|
||||
@@ -48,10 +58,18 @@ export default function Opportunities({
|
||||
geography_scope: filters.geography_scope ?? '',
|
||||
});
|
||||
return (
|
||||
<Management title="Gestão de Oportunidades">
|
||||
<Link className={button} href="/management/opportunities/create">
|
||||
Nova oportunidade
|
||||
</Link>
|
||||
<Management
|
||||
title={
|
||||
basePath === '/minhas-oportunidades'
|
||||
? 'Minhas oportunidades'
|
||||
: 'Gestão de Oportunidades'
|
||||
}
|
||||
>
|
||||
{canCreate && (
|
||||
<Link className={button} href={`${basePath}/create`}>
|
||||
Nova oportunidade
|
||||
</Link>
|
||||
)}
|
||||
<p>
|
||||
{geographyReviewCount} registos com âmbito por indicar;
|
||||
referências existentes permanecem aceites.
|
||||
@@ -72,7 +90,7 @@ export default function Opportunities({
|
||||
<Link
|
||||
className="rounded border p-3"
|
||||
key={s}
|
||||
href={`/management/opportunities?status=${s}`}
|
||||
href={`${basePath}?status=${s}`}
|
||||
>
|
||||
{states[s] ?? s}: {counts[s] ?? 0}
|
||||
</Link>
|
||||
@@ -82,9 +100,31 @@ export default function Opportunities({
|
||||
className="flex flex-wrap gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.get('/management/opportunities');
|
||||
form.get(basePath);
|
||||
}}
|
||||
>
|
||||
{basePath === '/minhas-oportunidades' && (
|
||||
<label>
|
||||
Fila
|
||||
<select
|
||||
className={control}
|
||||
value={form.data.queue}
|
||||
onChange={(e) =>
|
||||
form.setData('queue', e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todas as autorizadas</option>
|
||||
<option value="assigned">Atribuídas a mim</option>
|
||||
<option value="review">
|
||||
Validação e pareceres
|
||||
</option>
|
||||
<option value="publication">
|
||||
Preparação editorial
|
||||
</option>
|
||||
<option value="appeal">Recursos pendentes</option>
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<input
|
||||
aria-label="Pesquisa global"
|
||||
placeholder="Título ou referência"
|
||||
@@ -166,7 +206,7 @@ export default function Opportunities({
|
||||
{records.data.map((r) => (
|
||||
<article key={r.id} className="rounded border p-4">
|
||||
<h2 className="font-semibold">
|
||||
{r.title ?? 'Rascunho sem título'}
|
||||
{r.draft_title ?? r.title ?? 'Rascunho sem título'}
|
||||
</h2>
|
||||
<p>
|
||||
ID {r.id} · {r.reference} ·{' '}
|
||||
@@ -174,24 +214,25 @@ export default function Opportunities({
|
||||
·{' '}
|
||||
{r.deleted_at
|
||||
? 'Eliminado logicamente'
|
||||
: (states[r.status] ?? r.status)}
|
||||
: (r.working_status ?? r.status) === 'published'
|
||||
? 'Versão disponibilizada'
|
||||
: (states[r.working_status ?? r.status] ??
|
||||
r.working_status ??
|
||||
r.status)}
|
||||
</p>
|
||||
{r.publication && <p>{r.publication.label}</p>}
|
||||
<p>Atualizado: {r.updated_at}</p>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<Link
|
||||
href={`/management/opportunities/${r.id}/view`}
|
||||
>
|
||||
Ver
|
||||
</Link>
|
||||
<Link
|
||||
href={`/management/opportunities/${r.id}/edit`}
|
||||
>
|
||||
{r.deleted_at || r.status === 'archived'
|
||||
? 'Restaurar'
|
||||
: r.status === 'draft'
|
||||
? 'Continuar preenchimento'
|
||||
: 'Editar nova versão'}
|
||||
</Link>
|
||||
<Link href={`${basePath}/${r.id}/view`}>Ver</Link>
|
||||
{r.can_edit !== false && (
|
||||
<Link href={`${basePath}/${r.id}/edit`}>
|
||||
{r.deleted_at || r.status === 'archived'
|
||||
? 'Restaurar'
|
||||
: r.status === 'draft'
|
||||
? 'Continuar preenchimento'
|
||||
: 'Editar nova versão'}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user