mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 02:51:46 +00:00
Arquivos de queries, helpers e controllers dispersos na raiz de dashboard/ foram movidos para subdiretórios temáticos (bills/, invoices/, notes/, notifications/, overview/, payments/, goals-progress/, categories/). ~25 widgets monolíticos obsoletos removidos em favor de nova arquitetura baseada em widget-registry com components/widgets/. Novos componentes: category-breakdown-chart/list, goals-progress-item, percentage-change-indicator. Imports atualizados em fetch-dashboard-data e transaction-filters limpos. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
type BillDialogState,
|
|
getCurrentBillDateString,
|
|
markBillAsSettled,
|
|
} from "@/features/dashboard/bills/bills-helpers";
|
|
import type { DashboardBill } from "@/features/dashboard/bills/bills-queries";
|
|
import {
|
|
type PaymentDialogController,
|
|
usePaymentDialogController,
|
|
} from "@/features/dashboard/payments/use-payment-dialog-controller";
|
|
import { toggleTransactionSettlementAction } from "@/features/transactions/actions";
|
|
|
|
const EMPTY_BILLS: DashboardBill[] = [];
|
|
|
|
type BillWidgetController = Omit<
|
|
PaymentDialogController<DashboardBill>,
|
|
"selectedItem"
|
|
> & {
|
|
selectedBill: DashboardBill | null;
|
|
modalState: BillDialogState;
|
|
};
|
|
|
|
export function useBillWidgetController(
|
|
bills?: DashboardBill[],
|
|
): BillWidgetController {
|
|
const safeBills = bills ?? EMPTY_BILLS;
|
|
const controller = usePaymentDialogController({
|
|
items: safeBills,
|
|
getItemId: (bill) => bill.id,
|
|
isItemConfirmed: (bill) => bill.isSettled,
|
|
executeConfirm: (bill) =>
|
|
toggleTransactionSettlementAction({
|
|
id: bill.id,
|
|
value: true,
|
|
}),
|
|
applyConfirmedState: (bill) =>
|
|
markBillAsSettled(bill, getCurrentBillDateString()),
|
|
});
|
|
|
|
return {
|
|
...controller,
|
|
selectedBill: controller.selectedItem,
|
|
};
|
|
}
|