import { Link, router } from '@inertiajs/react'; import { Frame, card, button } from './shared'; import OpportunityAlertPreferences, { type AlertPreferences, type AlertOptions, } from '@/components/opportunity-alert-preferences'; export default function Notifications({ unread, notifications, alertPreferences = null, alertOptions = null, }: { alertPreferences?: AlertPreferences | null; alertOptions?: AlertOptions | null; unread: number; notifications: { data: { id: string; submission_id: string | null; opportunity_id?: number | null; tender_version_id?: string | null; funding_version_id?: string | null; kind: string; payload: { status?: string; reference?: string; title?: string; slug?: string; source?: string; source_url?: string; source_reference?: string; source_checked_on?: string; preference_version?: number; tender_id?: string; programme_id?: string; scope_explanation?: Record; window_states?: { title: string; state: string; end_on?: string | null; }[]; publication_version?: number; act?: string; published_at?: string | null; }; read_at: string | null; created_at: string; }[]; prev_page_url: string | null; next_page_url: string | null; }; }) { const states: Record = { received: 'Recebido', in_review: 'Em análise', contacted: 'Contactado', closed: 'Encerrado', }; const fundingStates: Record = { open: 'aberta segundo as datas documentadas', closed: 'encerrada', upcoming: 'abertura futura', unknown: 'por confirmar', }; return ( Área do investidor

{unread} notificações por ler

{alertPreferences && alertOptions && ( )} {notifications.data.map((n) => (

{n.kind === 'funding_match' ? 'Nova publicação de fundo ou apoio' : n.kind === 'tender_match' ? 'Novo acto de concurso compatível' : n.kind === 'opportunity_match' ? 'Nova oportunidade compatível' : n.kind === 'received' ? 'Manifestação recebida' : n.kind === 'status' ? 'Estado actualizado' : 'Nova mensagem na conversa'}

{n.payload.title ?? n.payload.reference ?? (n.payload.status ? (states[n.payload.status] ?? n.payload.status) : 'Consulte o pedido para ler a mensagem.')}

{(n.kind === 'funding_match' || n.kind === 'opportunity_match' || n.kind === 'tender_match') && (

Fonte: {n.payload.source}.{' '} {n.payload.published_at && !Number.isNaN( new Date(n.payload.published_at).getTime(), ) ? ( <> Publicação em{' '} .{' '} ) : ( 'Data de publicação não indicada. ' )} Correspondência com a versão{' '} {n.payload.preference_version} das suas preferências; não representa avaliação de rentabilidade ou elegibilidade.

)} {n.kind === 'tender_match' && (

{alertOptions?.tenderActs?.[n.payload.act ?? ''] ?? n.payload.act ?? 'Acto publicado'}{' '} · versão {n.payload.publication_version}. Referência: {n.payload.reference ?? 'Não indicada'}. Consulte o concurso para verificar o estado e as condições actuais. Este aviso não apresenta uma proposta.

)} {n.kind === 'funding_match' && (
{n.payload.source_url && (

{n.payload.source_reference ?? 'Consultar fonte documentada'} {n.payload.source_checked_on ? ` — consultada em ${n.payload.source_checked_on}` : ''}

)}

Versão {n.payload.publication_version}. Consulte a ficha para conferir as condições actuais. Este aviso não confirma uma candidatura aberta nem concessão de financiamento.

{Object.entries( n.payload.scope_explanation ?? {}, ).map(([key, text]) => (

{text}

))}
    {(n.payload.window_states ?? []).map( (window, index) => (
  • {window.title}:{' '} {fundingStates[window.state] ?? window.state} {window.end_on ? `; data-limite ${window.end_on}` : ''}{' '} (estado na data do aviso).
  • ), )}
)}

Recebida em{' '} {new Date(n.created_at).toLocaleString('pt-MZ')}

{n.kind === 'funding_match' ? 'Consultar fundo ou apoio' : n.kind === 'tender_match' ? 'Consultar concurso' : n.kind === 'opportunity_match' ? 'Consultar oportunidade' : 'Abrir manifestação'} {!n.read_at && ( )}
))} {!notifications.data.length && (

Não existem notificações disponíveis nesta consulta.

)} ); }