feat(dashboard): refina experiencia dos widgets

This commit is contained in:
Felipe Coutinho
2026-05-31 15:18:43 -03:00
parent 402f0072af
commit 35abe1b0bf
39 changed files with 887 additions and 592 deletions

View File

@@ -34,7 +34,6 @@ import {
import { safeToNumber as toNumber } from "@/shared/utils/number";
const PAYMENT_METHOD_BOLETO = "Boleto";
const PAYMENT_METHOD_CARD = "Cartão de Crédito";
const TRANSACTION_TYPE_EXPENSE = "Despesa";
const TRANSACTION_TYPE_INCOME = "Receita";
const CONDITION_RECURRING = "Recorrente";
@@ -79,7 +78,6 @@ type DashboardCurrentPeriodOverview = {
installmentExpensesData: InstallmentExpensesData;
topEstablishmentsData: TopEstablishmentsData;
topExpensesAll: TopExpensesData;
topExpensesCardOnly: TopExpensesData;
purchasesByCategoryData: PurchasesByCategoryData;
};
@@ -99,7 +97,6 @@ const emptyOverview = (): DashboardCurrentPeriodOverview => ({
installmentExpensesData: { expenses: [] },
topEstablishmentsData: { establishments: [] },
topExpensesAll: { expenses: [] },
topExpensesCardOnly: { expenses: [] },
purchasesByCategoryData: {
categories: [],
transactionsByCategory: {},
@@ -190,6 +187,7 @@ const buildBillsSnapshot = (
: null,
isSettled: Boolean(row.isSettled),
accountId: row.accountId ?? null,
transactionType: row.transactionType,
}))
.sort((a, b) => {
if (a.isSettled !== b.isSettled) {
@@ -432,14 +430,12 @@ const mapTopExpense = (row: CurrentPeriodTransactionRow): TopExpense => ({
const buildTopExpensesData = (
rows: CurrentPeriodTransactionRow[],
cardOnly: boolean,
): TopExpensesData => ({
expenses: rows
.filter(
(row) =>
row.transactionType === TRANSACTION_TYPE_EXPENSE &&
shouldIncludeWithoutAutoGenerated(row.note) &&
(!cardOnly || row.paymentMethod === PAYMENT_METHOD_CARD),
shouldIncludeWithoutAutoGenerated(row.note),
)
.sort((a, b) => toNumber(a.amount) - toNumber(b.amount))
.slice(0, 10)
@@ -617,8 +613,7 @@ export async function fetchDashboardCurrentPeriodOverview(
recurringExpensesData: buildRecurringExpensesData(rows),
installmentExpensesData: buildInstallmentExpensesData(rows),
topEstablishmentsData: buildTopEstablishmentsData(rows),
topExpensesAll: buildTopExpensesData(rows, false),
topExpensesCardOnly: buildTopExpensesData(rows, true),
topExpensesAll: buildTopExpensesData(rows),
purchasesByCategoryData: buildPurchasesByCategoryData(rows),
};
}