fix: complete executive narrative exports and deduplicate company questionnaire in QA

This commit is contained in:
2026-11-21 20:45:25 +02:00
parent f5dbd55dfb
commit c144425e77
26 changed files with 875 additions and 36 deletions
@@ -21,17 +21,30 @@ export function DossierReportPreview({
{section.paragraphs.map((p, j) => (
<p key={j}>{p}</p>
))}
<dl className="space-y-2">
{section.rows.map((r, j) => (
<div className="break-words" key={j}>
<dt className="font-medium">{r.field}</dt>
<dd>{r.value}</dd>
<dd className="text-sm">
{r.classification} · {r.origin}
</dd>
</div>
))}
</dl>
{section.id !== 'finance' &&
section.id !== 'financial-report' ? (
section.rows.map((row, j) => (
<p key={j} className="break-words">
<strong>{row.field}: </strong>
{row.value}
<small className="block">
{row.classification}. {row.origin}
</small>
</p>
))
) : (
<dl className="space-y-2">
{section.rows.map((r, j) => (
<div className="break-words" key={j}>
<dt className="font-medium">{r.field}</dt>
<dd>{r.value}</dd>
<dd className="text-sm">
{r.classification} · {r.origin}
</dd>
</div>
))}
</dl>
)}
{section.tables && (
<InvestmentReportTables tables={section.tables} />
)}
@@ -274,6 +274,13 @@ const fieldGuidance: Record<
clarify:
'Pode começar por descrever o que pretende produzir ou prestar.',
},
project_summary: {
why: 'Reúne os objectivos, a missão e as chaves para o sucesso que pretende comunicar aos parceiros.',
example:
'Exemplo apenas de organização do texto: Objectivos. Missão. Chaves para o sucesso.',
clarify:
'Descreva as suas escolhas em texto livre. Não precisa de adoptar a estrutura ou os valores do exemplo TEMPO.',
},
project_problem: {
why: 'Uma necessidade concreta ajuda a explicar a razão do projecto.',
example:
+37 -13
View File
@@ -450,8 +450,25 @@ export async function generateProjectDossierDocx(
children.push(
new Paragraph({ children: [new TextRun({ text: paragraph })] }),
);
const table = sectionTable(section);
if (table) children.push(table);
if (section.id === 'finance' || section.id === 'financial-report') {
const table = sectionTable(section);
if (table) children.push(table);
} else {
for (const row of section.rows)
children.push(
new Paragraph({
children: [
new TextRun({ text: `${row.field}: `, bold: true }),
new TextRun({ text: row.value }),
new TextRun({
text: `${row.classification}. ${row.origin}`,
break: 1,
size: 18,
}),
],
}),
);
}
for (const issue of financialIssuesForDisplay(section.tables ?? [])) {
children.push(
new Paragraph({ text: issue.message, keepNext: true }),
@@ -665,17 +682,24 @@ export async function createProjectDossierPrintHtml(
for (const slice of investmentReportTableSlices(entry))
content.push(htmlTable(slice.headers, slice.rows));
}
if (section.rows.length && section.id !== 'financial-report')
content.push(
htmlTable(
['Campo', 'Conteúdo', 'Classificação / origem'],
section.rows.map((row) => [
row.field,
row.value,
`${row.classification}. ${row.origin}`,
]),
),
);
if (section.rows.length && section.id !== 'financial-report') {
if (section.id === 'finance')
content.push(
htmlTable(
['Campo', 'Conteúdo', 'Classificação / origem'],
section.rows.map((row) => [
row.field,
row.value,
`${row.classification}. ${row.origin}`,
]),
),
);
else
for (const row of section.rows)
content.push(
`<p><strong>${escapeHtml(row.field)}:</strong> ${escapeHtml(row.value)}<br><small>${escapeHtml(row.classification)}. ${escapeHtml(row.origin)}</small></p>`,
);
}
if (section.id === 'annexes') {
const selected = attachments.filter((item) => item.include);
if (!selected.length)
@@ -8,6 +8,8 @@ import {
type CompanyAnswers,
} from '@/lib/company-comparison';
const comparisonIntroduction =
'Compare alternativas para discutir a constituição; não existe uma forma universalmente preferível.';
type Question = { label: string; options: Record<string, string> };
const questionThemes: Record<string, string> = {
purpose: 'Organização do pedido',
@@ -145,10 +147,7 @@ function Comparator(props: Props) {
</Link>
</p>
)}
<p>
Compare alternativas para discutir a constituição; não existe
uma forma universalmente preferível.
</p>
<p>{comparisonIntroduction}</p>
{saved && (
<p>
{historical
@@ -307,13 +306,14 @@ function Comparator(props: Props) {
<h2 className="text-lg font-semibold">
Alternativas e pontos a conferir
</h2>
<p>{result.route}</p>
{result.route.trim() !== comparisonIntroduction && (
<p>{result.route}</p>
)}
{result.pending.length > 0 && (
<p>
Por esclarecer:{' '}
{result.pending
.map((key) => result.questions[key]?.label ?? key)
.join(' · ')}
Há {result.pending.length} temas por esclarecer nas
respostas. Pode completar os campos acima para
aprofundar a comparação.
</p>
)}
<div className="grid gap-4 md:grid-cols-2">