import { Link, router } from '@inertiajs/react'; import { Field, Management, button, control } from './shared'; import { states } from '@/lib/editorial-states'; type Item = { id: number; title: string; revision_no: number; state: string; responsible: string | null; published: boolean; legal_required: boolean; }; const eventTitles: Record = { 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, offersUrl = null, offerOperationsUrl = null, opportunityPending, clustersUrl, portfolioUrl, portfolioPending = 0, demographyUrl, demographyPending = 0, territorialUrl, nativePending = { clusters: 0, territories: 0 }, subjectsUrl, subjectsPending = 0, zonesUrl, }: { resourceAccess: boolean; opportunitiesUrl: string | null; offersUrl?: string | null; offerOperationsUrl?: 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) })}`; const areas = [ { title: 'Conteúdos e oportunidades', entries: [ { label: 'Artigos', href: resourceAccess ? '/management/editorial?kind=article' : null, }, { label: 'Legislação', href: resourceAccess ? '/management/editorial?kind=legislation' : null, }, { label: 'Documentos', href: resourceAccess ? '/management/editorial?kind=document' : null, }, { label: 'Oportunidades', href: opportunitiesUrl, pending: opportunityPending, }, { label: 'Ofertas — revisão privada', href: offersUrl, }, { label: 'Ofertas — acompanhamento', href: offerOperationsUrl }, { label: 'Biblioteca e editores', href: resourceAccess ? '/management/portal-services' : null, }, ], }, { title: 'Investimentos e competitividade', entries: [ { label: 'Carteira', href: portfolioUrl, pending: portfolioPending, }, { label: 'Competitividade dos clusters', href: clustersUrl, pending: nativePending.clusters, }, { label: 'Estruturas e relações', href: subjectsUrl, pending: subjectsPending, }, ], }, { title: 'Território e dados', entries: [ { label: 'Conteúdos territoriais', href: territorialUrl, pending: nativePending.territories, }, { label: 'Zonas e indicadores', href: zonesUrl, pending: nativePending.zones ?? 0, }, { label: 'Demografia', href: demographyUrl, pending: demographyPending, }, ], }, ].filter((area) => area.entries.some((item) => item.href)); return (

Acompanhe a preparação, revisão e publicação numa única área de trabalho. Seleccione uma actividade para continuar nas tarefas da sua equipa.

{areas.map((area) => (

{area.title}

    {area.entries.map((item) => item.href ? (
  • {item.label} {'pending' in item && ( {item.pending} pendentes )}
  • ) : null, )}
))}
{resourceAccess && ( <>

Fila de conteúdos

{items.data.map((item) => (
{item.title}

Edição {item.revision_no} ·{' '} {states[item.state] ?? item.state} · Responsável:{' '} {item.responsible ?? 'Por atribuir'}

{item.published ? 'Versão pública disponível' : 'Sem versão pública'} {item.legal_required && ' · Exige validação jurídica'}

))}
)}

Notificações

{notices.length === 0 && (

Não há notificações neste âmbito.

)} {notices.map((n) => (

{eventTitles[n.action] ?? 'Alteração editorial'} ·{' '} {n.reference} {!n.read_at && ( )}

))}
); }