fix(transactions): usa data da última transação ao adicionar nova linha no MassAddDialog

Quando o usuário adiciona uma nova linha de transação no dialog de múltiplos lançamentos,
a data agora é pré-preenchida com o valor da transação anterior em vez da data atual.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
lucas
2026-05-23 11:27:43 -03:00
parent fea9cf81d8
commit d383d2db91

View File

@@ -123,10 +123,11 @@ interface TransactionRow {
function createEmptyTransactionRow( function createEmptyTransactionRow(
defaultPayerId?: string | null, defaultPayerId?: string | null,
lastPurchaseDate?: string,
): TransactionRow { ): TransactionRow {
return { return {
id: createClientSafeId(), id: createClientSafeId(),
purchaseDate: getTodayDateString(), purchaseDate: lastPurchaseDate ?? getTodayDateString(),
name: "", name: "",
amount: "", amount: "",
categoryId: undefined, categoryId: undefined,
@@ -180,9 +181,10 @@ export function MassAddDialog({
}, [categoryOptions, transactionType]); }, [categoryOptions, transactionType]);
const addTransaction = () => { const addTransaction = () => {
const lastTransaction = transactions[transactions.length - 1];
setTransactions([ setTransactions([
...transactions, ...transactions,
createEmptyTransactionRow(defaultPayerId), createEmptyTransactionRow(defaultPayerId, lastTransaction?.purchaseDate),
]); ]);
}; };