Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions public/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { ToastManager } from "./managers/toast";
const toastManager = new ToastManager(document.getElementById('toast-container'));

// Global variables
let currentTransactionType = 'income'; // Default transaction type
let currentFilter = null; // null = show all, 'income' = only income, 'expense' = only expenses
let editingTransactionId = null;
let currentSortField = 'date';
let currentSortDirection = 'desc';

// Theme toggle functionality
function getBaseUrl() {
// First try to get it from the server-provided meta tag
Expand Down Expand Up @@ -314,16 +321,6 @@ async function handleFetchResponse(response) {
return response;
}

// Add currentFilter variable at the top with other shared variables
let currentFilter = null; // null = show all, 'income' = only income, 'expense' = only expenses

// Add at the top with other variables
let editingTransactionId = null;

// Add at the top with other shared variables
let currentSortField = 'date';
let currentSortDirection = 'desc';

// Update loadTransactions function
async function loadTransactions() {
try {
Expand Down Expand Up @@ -470,6 +467,9 @@ function editTransaction(id, transaction, isRecurringInstance) {
document.getElementById('description').value = transaction.description;
document.getElementById('transactionDate').value = transaction.date;

// Update the currentTransactionType to match the transaction being edited
currentTransactionType = transaction.type;

// Set transaction type
toggleBtns.forEach(btn => {
btn.classList.toggle('active', btn.dataset.type === transaction.type);
Expand Down Expand Up @@ -651,8 +651,6 @@ function initModalHandling() {
const toggleBtns = document.querySelectorAll('.toggle-btn');
const amountInput = document.getElementById('amount');

let currentTransactionType = 'income';

// Initialize category handling
initCategoryHandling();

Expand Down