diff --git a/lib/data-utils.ts b/lib/data-utils.ts index dd2c096..53e0210 100644 --- a/lib/data-utils.ts +++ b/lib/data-utils.ts @@ -266,7 +266,7 @@ export async function getAllBudgets(userId: string) { const budgets = await db.query( sql`SELECT * FROM "budgetzen_budgets" WHERE "user_id" = $1 - ORDER BY "month" DESC`, + ORDER BY "month" DESC, "id" DESC`, [ userId, ], @@ -280,7 +280,7 @@ export async function getBudgetsByMonth(userId: string, month: string) { sql`SELECT * FROM "budgetzen_budgets" WHERE "user_id" = $1 AND "month" = $2 - ORDER BY "month" DESC`, + ORDER BY "month" DESC, "id" DESC`, [ userId, month, @@ -351,7 +351,7 @@ export async function getAllExpenses(userId: string) { const expenses = await db.query( sql`SELECT * FROM "budgetzen_expenses" WHERE "user_id" = $1 - ORDER BY "date" DESC`, + ORDER BY "date" DESC, "id" DESC`, [ userId, ], @@ -366,7 +366,7 @@ export async function getExpensesByMonth(userId: string, month: string) { WHERE "user_id" = $1 AND "date" >= '${month}-01' AND "date" <= '${month}-31' - ORDER BY "date" DESC`, + ORDER BY "date" DESC, "id" DESC`, [ userId, ], diff --git a/public/ts/index.ts b/public/ts/index.ts index 4383493..8b3c289 100644 --- a/public/ts/index.ts +++ b/public/ts/index.ts @@ -21,7 +21,7 @@ import { } from './utils.ts'; document.addEventListener('app-loaded', async () => { - const user = await checkForValidSession(); + await checkForValidSession(); const loginForm = document.getElementById('login-form') as HTMLFormElement; const emailInput = document.getElementById('email') as HTMLInputElement; @@ -175,6 +175,8 @@ document.addEventListener('app-loaded', async () => { } async function showData(isComingFromEmptyState = false) { + const user = await checkForValidSession(); + currency = user?.extra.currency || '$'; monthNavigationLabel.textContent = showFormattedDate(currentMonth, {