From d8aed4970c5cc60b42cfd1765ddb268b86b92955 Mon Sep 17 00:00:00 2001 From: Jose Selesan Date: Thu, 27 Aug 2026 11:37:43 -0300 Subject: [PATCH] feat(analysis): bold month names for DB-sourced data, regular for external --- .../modules/quotes/handlers/getMonthlyLast.ts | 7 ++++--- .../components/MonthlyVariationTable.tsx | 21 ++++++++++++++++--- apps/frontend/src/lib/api.ts | 1 + 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/apps/backend/src/modules/quotes/handlers/getMonthlyLast.ts b/apps/backend/src/modules/quotes/handlers/getMonthlyLast.ts index 2490bb7..be1f663 100644 --- a/apps/backend/src/modules/quotes/handlers/getMonthlyLast.ts +++ b/apps/backend/src/modules/quotes/handlers/getMonthlyLast.ts @@ -6,6 +6,7 @@ type MonthlyLastRow = { month: string; type: string; buy: number; + source: "db" | "external"; }; type ExternalQuote = { @@ -94,7 +95,7 @@ export async function getMonthlyLast(c: Context) { for (const type of TYPES) { const buy = dbMap.get(month)?.get(type); if (buy !== undefined) { - result.push({ month, type, buy }); + result.push({ month, type, buy, source: "db" }); } } } @@ -152,13 +153,13 @@ export async function getMonthlyLast(c: Context) { for (const type of TYPES) { const dbBuy = dbMap.get(month)?.get(type); if (dbBuy !== undefined) { - result.push({ month, type, buy: dbBuy }); + result.push({ month, type, buy: dbBuy, source: "db" }); continue; } const extBuy = externalData.get(type)?.get(month); if (extBuy !== undefined) { - result.push({ month, type, buy: extBuy }); + result.push({ month, type, buy: extBuy, source: "external" }); } } } diff --git a/apps/frontend/src/features/analysis/components/MonthlyVariationTable.tsx b/apps/frontend/src/features/analysis/components/MonthlyVariationTable.tsx index 0971c5e..b95fc3e 100644 --- a/apps/frontend/src/features/analysis/components/MonthlyVariationTable.tsx +++ b/apps/frontend/src/features/analysis/components/MonthlyVariationTable.tsx @@ -13,6 +13,7 @@ type CurrencyValues = { type MonthRow = { month: MonthKey; label: string; + fromDb: boolean; BELO: CurrencyValues; BLUE: CurrencyValues; BNA: CurrencyValues; @@ -117,7 +118,12 @@ export function MonthlyVariationTable() { const monthsMap = new Map< MonthKey, - { BELO: number | null; BLUE: number | null; BNA: number | null } + { + BELO: number | null; + BLUE: number | null; + BNA: number | null; + dbTypes: Set; + } >(); for (const entry of monthlyData) { @@ -125,10 +131,12 @@ export function MonthlyVariationTable() { BELO: null, BLUE: null, BNA: null, + dbTypes: new Set(), }; if (entry.type === "BELO") existing.BELO = entry.buy; if (entry.type === "BLUE") existing.BLUE = entry.buy; if (entry.type === "BNA") existing.BNA = entry.buy; + if (entry.source === "db") existing.dbTypes.add(entry.type); monthsMap.set(entry.month, existing); } @@ -175,6 +183,7 @@ export function MonthlyVariationTable() { return { month, label: formatMonth(month), + fromDb: (current?.dbTypes.size ?? 0) > 0, BELO: { variation: beloVar, prev: prevData?.BELO ?? null, @@ -223,7 +232,9 @@ export function MonthlyVariationTable() { className="rounded-lg border bg-card p-3 text-sm" >
- {row.label} + + {row.label} + {row.inflation !== null ? ( @@ -297,7 +308,11 @@ export function MonthlyVariationTable() { key={row.month} className="border-b last:border-0 hover:bg-muted/30" > - {row.label} + + {row.label} + {