feat(analysis): bold month names for DB-sourced data, regular for external

This commit is contained in:
Jose Selesan
2026-08-27 11:37:43 -03:00
parent 28f9dea7ba
commit d8aed4970c
3 changed files with 23 additions and 6 deletions

View File

@@ -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" });
}
}
}

View File

@@ -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<string>;
}
>();
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"
>
<div className="flex items-center justify-between mb-2">
<span className="font-medium">{row.label}</span>
<span className={row.fromDb ? "font-semibold" : "font-normal"}>
{row.label}
</span>
{row.inflation !== null ? (
<span className="text-xs text-muted-foreground tabular-nums inline-flex items-center gap-1">
<TrendingUp className="size-3" />
@@ -297,7 +308,11 @@ export function MonthlyVariationTable() {
key={row.month}
className="border-b last:border-0 hover:bg-muted/30"
>
<td className="px-3 py-2.5 font-medium">{row.label}</td>
<td
className={`px-3 py-2.5 ${row.fromDb ? "font-semibold" : "font-normal"}`}
>
{row.label}
</td>
<td className="px-3 py-2.5 text-right">
<VariationIndicator
variation={row.BELO.variation}

View File

@@ -113,6 +113,7 @@ export type MonthlyLast = {
month: string;
type: "BELO" | "BLUE" | "BNA";
buy: number;
source: "db" | "external";
};
export function getMonthlyLast(): Promise<MonthlyLast[]> {