Skip to content

Commit 2a2f36b

Browse files
authored
Merge pull request #36 from DumbWareio/dev
# Fix: Transaction Type Reference Error in Edit Mode
2 parents f219116 + 6a98aff commit 2a2f36b

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

public/script.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { ToastManager } from "./managers/toast";
22
const toastManager = new ToastManager(document.getElementById('toast-container'));
33

4+
// Global variables
5+
let currentTransactionType = 'income'; // Default transaction type
6+
let currentFilter = null; // null = show all, 'income' = only income, 'expense' = only expenses
7+
let editingTransactionId = null;
8+
let currentSortField = 'date';
9+
let currentSortDirection = 'desc';
10+
411
// Theme toggle functionality
512
function getBaseUrl() {
613
// First try to get it from the server-provided meta tag
@@ -314,16 +321,6 @@ async function handleFetchResponse(response) {
314321
return response;
315322
}
316323

317-
// Add currentFilter variable at the top with other shared variables
318-
let currentFilter = null; // null = show all, 'income' = only income, 'expense' = only expenses
319-
320-
// Add at the top with other variables
321-
let editingTransactionId = null;
322-
323-
// Add at the top with other shared variables
324-
let currentSortField = 'date';
325-
let currentSortDirection = 'desc';
326-
327324
// Update loadTransactions function
328325
async function loadTransactions() {
329326
try {
@@ -470,6 +467,9 @@ function editTransaction(id, transaction, isRecurringInstance) {
470467
document.getElementById('description').value = transaction.description;
471468
document.getElementById('transactionDate').value = transaction.date;
472469

470+
// Update the currentTransactionType to match the transaction being edited
471+
currentTransactionType = transaction.type;
472+
473473
// Set transaction type
474474
toggleBtns.forEach(btn => {
475475
btn.classList.toggle('active', btn.dataset.type === transaction.type);
@@ -651,8 +651,6 @@ function initModalHandling() {
651651
const toggleBtns = document.querySelectorAll('.toggle-btn');
652652
const amountInput = document.getElementById('amount');
653653

654-
let currentTransactionType = 'income';
655-
656654
// Initialize category handling
657655
initCategoryHandling();
658656

0 commit comments

Comments
 (0)