268 lines
10 KiB
TypeScript
268 lines
10 KiB
TypeScript
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> = {
|
|
submitted: 'Submissão',
|
|
pending_review: 'Submissão',
|
|
review_started: 'Início da revisão',
|
|
in_review: 'Início da revisão',
|
|
returned: 'Devolução',
|
|
rejected: 'Rejeição',
|
|
approved: 'Aprovação',
|
|
published: 'Publicação',
|
|
archived: 'Arquivo',
|
|
withdrawn: 'Retirada da publicação',
|
|
publication_withdrawn: 'Retirada da publicação',
|
|
suspended: 'Suspensão da publicação',
|
|
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,
|
|
clustersUrl,
|
|
portfolioUrl,
|
|
portfolioPending = 0,
|
|
demographyUrl,
|
|
demographyPending = 0,
|
|
territorialUrl,
|
|
nativePending = { clusters: 0, territories: 0 },
|
|
subjectsUrl,
|
|
subjectsPending = 0,
|
|
zonesUrl,
|
|
}: {
|
|
resourceAccess: boolean;
|
|
opportunitiesUrl: string | null;
|
|
opportunityPending: number;
|
|
clustersUrl?: string | null;
|
|
portfolioUrl?: string | null;
|
|
portfolioPending?: number;
|
|
demographyUrl?: string | null;
|
|
demographyPending?: number;
|
|
territorialUrl?: string | null;
|
|
nativePending?: { clusters: number; territories: number; zones?: number };
|
|
zonesUrl?: string | null;
|
|
subjectsUrl?: string | null;
|
|
subjectsPending?: 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">
|
|
{zonesUrl && (
|
|
<Link className="underline" href={zonesUrl}>
|
|
Zonas e indicadores: {nativePending.zones ?? 0}{' '}
|
|
pendentes
|
|
</Link>
|
|
)}
|
|
{subjectsUrl && (
|
|
<Link className="underline" href={subjectsUrl}>
|
|
Estruturas e relações: {subjectsPending} pendentes
|
|
</Link>
|
|
)}
|
|
{demographyUrl && (
|
|
<Link className="underline" href={demographyUrl}>
|
|
Demografia: {demographyPending} lotes pendentes
|
|
</Link>
|
|
)}
|
|
{territorialUrl && (
|
|
<Link className="underline" href={territorialUrl}>
|
|
Conteúdos territoriais: {nativePending.territories}{' '}
|
|
pendentes
|
|
</Link>
|
|
)}
|
|
{portfolioUrl && (
|
|
<Link className="underline" href={portfolioUrl}>
|
|
Carteira: {portfolioPending} fichas pendentes
|
|
</Link>
|
|
)}
|
|
{clustersUrl && (
|
|
<Link className="underline" href={clustersUrl}>
|
|
Competitividade dos clusters: {nativePending.clusters}{' '}
|
|
pendentes
|
|
</Link>
|
|
)}
|
|
<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>
|
|
);
|
|
}
|