first commit
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-09-28 10:01:09 +02:00
commit 250ac35fd1
481 changed files with 92144 additions and 0 deletions
+135
View File
@@ -0,0 +1,135 @@
import { Management, Pagination } from './shared';
import type { Paginated } from './shared';
type Event = {
id: string;
entity_type: string;
action: string;
occurred_at: string;
actor: string | null;
before_data: { values: Record<string, unknown> };
after_data: {
record_id: number | string;
changed_fields: string[];
values: Record<string, unknown>;
};
};
const entities: Record<string, string> = {
investment_accounts: 'Perfil de investimento',
investment_company_declarations: 'Declaração de empresa',
investment_submissions: 'Manifestação de interesse',
investment_messages: 'Mensagem de acompanhamento',
investment_reference_options: 'Opção de formulário',
opportunity_context: 'Contexto da oportunidade',
sectors: 'Sector',
opportunities: 'Oportunidade',
interest_requests: 'Pedido',
investors: 'Investidor',
contacts: 'Contacto',
leads: 'Lead',
tasks: 'Tarefa',
projects: 'Projecto',
economic_clusters: 'Cluster',
cluster_projects: 'Associação projecto–cluster',
value_chains: 'Etapa da cadeia de valor',
value_chain_links: 'Ligação entre etapas',
investment_gaps: 'Lacuna de investimento',
};
const fields: Record<string, string> = {
version: 'Versão',
active: 'Activo',
name: 'Nome',
slug: 'Endereço',
description: 'Descrição',
short_description: 'Descrição curta',
status: 'Estado',
is_active: 'Activo',
is_featured: 'Destaque',
sort_order: 'Ordem',
sector_id: 'Sector',
maturity_level: 'Maturidade',
maturity_label: 'Descrição da maturidade',
estimated_investment_amount: 'Investimento',
estimated_investment_currency: 'Moeda',
reference: 'Referência',
title: 'Título',
summary: 'Resumo',
province: 'Província',
district: 'Distrito',
promoter_name: 'Promotor',
promoter_type: 'Tipo de promotor',
financing_modality: 'Financiamento',
expected_impact: 'Impacto',
published_at: 'Publicação',
reviewed_at: 'Data de revisão',
reviewed_by: 'Responsável pela revisão',
};
function display(value: unknown): string {
if (value === null || value === undefined) return '—';
if (typeof value === 'boolean') return value ? 'Sim' : 'Não';
if (typeof value === 'object') return JSON.stringify(value);
if (typeof value === 'string') return value;
if (typeof value === 'number') return value.toString();
return '—';
}
export default function History({ events }: { events: Paginated<Event> }) {
return (
<Management title="Histórico de alterações">
<p className="text-muted-foreground">
Alterações efectuadas na gestão do portal. Os textos e contactos
pessoais não são copiados para o histórico.
</p>
<div className="space-y-4">
{events.data.map((event) => (
<article
key={event.id}
className="space-y-2 rounded border p-4"
>
<h2 className="font-semibold break-words">
{entities[event.entity_type] ?? event.entity_type} #
{event.after_data.record_id} ·{' '}
{event.action === 'created'
? 'Criado'
: 'Actualizado'}
</h2>
<p>
{event.actor ?? 'Utilizador indisponível'} ·{' '}
{new Intl.DateTimeFormat('pt-MZ', {
dateStyle: 'medium',
timeStyle: 'short',
timeZone: 'Africa/Maputo',
}).format(new Date(event.occurred_at))}{' '}
(Maputo)
</p>
<p className="text-sm break-words">
Campos:{' '}
{event.after_data.changed_fields
.map((key) => fields[key] ?? key)
.join(', ')}
</p>
{Object.entries(event.after_data.values)
.filter(
([key, value]) =>
JSON.stringify(
event.before_data.values[key],
) !== JSON.stringify(value),
)
.map(([key, value]) => (
<p key={key} className="text-sm break-words">
{fields[key] ?? key}:{' '}
{display(
event.before_data.values[key] ?? '—',
)}{' '}
→ {display(value)}
</p>
))}
</article>
))}
</div>
{!events.data.length && (
<p>Ainda não existem alterações registadas.</p>
)}
<Pagination page={events} />
</Management>
);
}