feat(editorial): preserve public editions and add QA review workflow
This commit is contained in:
@@ -0,0 +1,202 @@
|
||||
import { Link, router } from '@inertiajs/react';
|
||||
import { Field, Management, button, control } from './shared';
|
||||
|
||||
export const states: Record<string, string> = {
|
||||
draft: 'Rascunho',
|
||||
submitted: 'Submetido',
|
||||
in_review: 'Em revisão',
|
||||
approved: 'Aprovado',
|
||||
published: 'Publicado',
|
||||
returned: 'Devolvido',
|
||||
rejected: 'Rejeitado',
|
||||
archived: 'Arquivado',
|
||||
};
|
||||
type Item = {
|
||||
id: number;
|
||||
title: string;
|
||||
revision_no: number;
|
||||
state: string;
|
||||
responsible: string | null;
|
||||
published: boolean;
|
||||
legal_required: boolean;
|
||||
};
|
||||
const eventTitles: Record<string, string> = {
|
||||
submit: 'Submissão',
|
||||
start_review: 'Início da revisão',
|
||||
return: 'Devolução',
|
||||
reject: 'Rejeição',
|
||||
legal_validate: 'Validação jurídica',
|
||||
approve: 'Aprovação',
|
||||
publish: 'Publicação',
|
||||
archive: 'Arquivo',
|
||||
};
|
||||
export default function EditorialWorkflow({
|
||||
items,
|
||||
notices,
|
||||
filters = {},
|
||||
resourceAccess,
|
||||
opportunitiesUrl,
|
||||
opportunityPending,
|
||||
}: {
|
||||
resourceAccess: boolean;
|
||||
opportunitiesUrl: string | null;
|
||||
opportunityPending: number;
|
||||
filters?: { state?: string; kind?: string };
|
||||
items: { data: Item[]; current_page: number; last_page: number };
|
||||
notices: {
|
||||
id: number;
|
||||
action: string;
|
||||
read_at: string | null;
|
||||
href: string;
|
||||
reference: string;
|
||||
}[];
|
||||
}) {
|
||||
const pageUrl = (page: number) =>
|
||||
`/management/editorial?${new URLSearchParams({ ...filters, page: String(page) })}`;
|
||||
return (
|
||||
<Management title="Circuito editorial">
|
||||
<p>
|
||||
Artigos, legislação e documentos: edições privadas e versão
|
||||
pública separadas. As oportunidades mantêm o seu circuito
|
||||
próprio.
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<Link className="underline" href="/dashboard">
|
||||
Painel geral
|
||||
</Link>
|
||||
{resourceAccess && (
|
||||
<Link
|
||||
className="underline"
|
||||
href="/management/portal-services"
|
||||
>
|
||||
Biblioteca e editores
|
||||
</Link>
|
||||
)}
|
||||
{opportunitiesUrl && (
|
||||
<Link className="underline" href={opportunitiesUrl}>
|
||||
Oportunidades
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
{opportunitiesUrl && (
|
||||
<section
|
||||
aria-label="Circuito de oportunidades"
|
||||
className="my-4 rounded border p-4"
|
||||
>
|
||||
<h2 className="font-semibold">Oportunidades</h2>
|
||||
<p>
|
||||
{opportunityPending} conteúdos pendentes no seu âmbito
|
||||
de acesso.
|
||||
</p>
|
||||
<Link className="underline" href={opportunitiesUrl}>
|
||||
Continuar na fila de oportunidades existente
|
||||
</Link>
|
||||
</section>
|
||||
)}
|
||||
{resourceAccess && (
|
||||
<>
|
||||
<form
|
||||
action="/management/editorial"
|
||||
className="my-4 flex flex-wrap items-end gap-3"
|
||||
>
|
||||
<Field label="Conteúdo">
|
||||
<select
|
||||
className={control}
|
||||
name="kind"
|
||||
defaultValue={filters.kind ?? ''}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
<option value="article">Artigos</option>
|
||||
<option value="legislation">Legislação</option>
|
||||
<option value="document">Documentos</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Estado da edição">
|
||||
<select
|
||||
className={control}
|
||||
name="state"
|
||||
defaultValue={filters.state ?? ''}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{Object.entries(states).map(
|
||||
([state, label]) => (
|
||||
<option key={state} value={state}>
|
||||
{label}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</Field>
|
||||
<button className={button}>Filtrar fila</button>
|
||||
</form>
|
||||
<section aria-label="Fila editorial" className="space-y-3">
|
||||
{items.data.map((item) => (
|
||||
<article
|
||||
key={item.id}
|
||||
className="rounded border p-4"
|
||||
>
|
||||
<Link
|
||||
className="font-semibold underline"
|
||||
href={`/management/editorial/resources/${item.id}`}
|
||||
>
|
||||
{item.title}
|
||||
</Link>
|
||||
<p>
|
||||
Edição {item.revision_no} ·{' '}
|
||||
{states[item.state] ?? item.state} ·
|
||||
Responsável:{' '}
|
||||
{item.responsible ?? 'Por atribuir'}
|
||||
</p>
|
||||
<p>
|
||||
{item.published
|
||||
? 'Versão pública disponível'
|
||||
: 'Sem versão pública'}
|
||||
{item.legal_required &&
|
||||
' · Exige validação jurídica'}
|
||||
</p>
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
<nav aria-label="Paginação" className="flex gap-4">
|
||||
{items.current_page > 1 && (
|
||||
<Link href={pageUrl(items.current_page - 1)}>
|
||||
Anterior
|
||||
</Link>
|
||||
)}
|
||||
<span>
|
||||
Página {items.current_page} de {items.last_page}
|
||||
</span>
|
||||
{items.current_page < items.last_page && (
|
||||
<Link href={pageUrl(items.current_page + 1)}>
|
||||
Seguinte
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
</>
|
||||
)}
|
||||
<section aria-label="Notificações editoriais">
|
||||
<h2 className="font-semibold">Notificações</h2>
|
||||
{notices.map((n) => (
|
||||
<p key={n.id}>
|
||||
<Link className="underline" href={n.href}>
|
||||
{eventTitles[n.action] ?? 'Alteração editorial'} ·{' '}
|
||||
{n.reference}
|
||||
</Link>
|
||||
{!n.read_at && (
|
||||
<button
|
||||
className="ml-3 underline"
|
||||
onClick={() =>
|
||||
router.post(
|
||||
`/management/editorial/notices/${n.id}/read`,
|
||||
)
|
||||
}
|
||||
>
|
||||
Marcar como lida
|
||||
</button>
|
||||
)}
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
</Management>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user