commit16
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import {
|
||||
publicRecordOfflineHtml,
|
||||
downloadOfflineHtml,
|
||||
offlineValue as display,
|
||||
} from './public-record-offline.ts';
|
||||
|
||||
type PublicOpportunity = {
|
||||
title: string;
|
||||
slug: string;
|
||||
reference: string;
|
||||
summary?: string | null;
|
||||
description?: string | null;
|
||||
sector?: { name: string } | null;
|
||||
province?: string | null;
|
||||
district?: string | null;
|
||||
maturity_label?: string | null;
|
||||
estimated_investment_amount?: string | null;
|
||||
estimated_investment_currency?: string | null;
|
||||
financing_modality?: string | null;
|
||||
expected_impact?: string | null;
|
||||
last_validated_at?: string | null;
|
||||
};
|
||||
|
||||
export function publicOpportunityOfflineHtml(
|
||||
record: PublicOpportunity,
|
||||
origin: string,
|
||||
savedAt: Date,
|
||||
): string {
|
||||
return publicRecordOfflineHtml(
|
||||
{
|
||||
title: record.title,
|
||||
kind: 'Ficha pública de oportunidade',
|
||||
sourcePath: `/oportunidades/${encodeURIComponent(record.slug)}`,
|
||||
rows: [
|
||||
['Referência', display(record.reference)],
|
||||
['Sector', display(record.sector?.name)],
|
||||
['Preparação', display(record.maturity_label)],
|
||||
[
|
||||
'Contexto territorial indicado na ficha',
|
||||
[record.district, record.province]
|
||||
.filter(Boolean)
|
||||
.join(', ') || 'Não indicado',
|
||||
],
|
||||
[
|
||||
'Investimento estimado',
|
||||
display(record.estimated_investment_amount) +
|
||||
(record.estimated_investment_currency
|
||||
? ` ${record.estimated_investment_currency}`
|
||||
: ''),
|
||||
],
|
||||
[
|
||||
'Modalidade de financiamento',
|
||||
display(record.financing_modality),
|
||||
],
|
||||
[
|
||||
'Última validação indicada',
|
||||
display(record.last_validated_at),
|
||||
],
|
||||
],
|
||||
sections: [
|
||||
{ title: 'Resumo', text: display(record.summary) },
|
||||
{ title: 'Descrição', text: display(record.description) },
|
||||
{
|
||||
title: 'Impacto esperado',
|
||||
text: display(record.expected_impact),
|
||||
},
|
||||
],
|
||||
notice: 'O contexto territorial não confirma a implantação. A execução depende das condições e autorizações aplicáveis ao projecto. Esta cópia não inclui mapas, anexos ou dados do dossier privado.',
|
||||
},
|
||||
origin,
|
||||
savedAt,
|
||||
);
|
||||
}
|
||||
|
||||
export function downloadPublicOpportunityOffline(
|
||||
record: PublicOpportunity,
|
||||
): void {
|
||||
downloadOfflineHtml(
|
||||
publicOpportunityOfflineHtml(
|
||||
record,
|
||||
window.location.origin,
|
||||
new Date(),
|
||||
),
|
||||
'oportunidade',
|
||||
record.slug || 'ficha',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user