Skip to content

Commit

Permalink
Get currency right on first load + consistently sort expenses and bud…
Browse files Browse the repository at this point in the history
…gets
  • Loading branch information
BrunoBernardino committed Mar 11, 2023
1 parent f523adf commit 4e5a8f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/data-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export async function getAllBudgets(userId: string) {
const budgets = await db.query<Budget>(
sql`SELECT * FROM "budgetzen_budgets"
WHERE "user_id" = $1
ORDER BY "month" DESC`,
ORDER BY "month" DESC, "id" DESC`,
[
userId,
],
Expand All @@ -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,
Expand Down Expand Up @@ -351,7 +351,7 @@ export async function getAllExpenses(userId: string) {
const expenses = await db.query<Expense>(
sql`SELECT * FROM "budgetzen_expenses"
WHERE "user_id" = $1
ORDER BY "date" DESC`,
ORDER BY "date" DESC, "id" DESC`,
[
userId,
],
Expand All @@ -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,
],
Expand Down
4 changes: 3 additions & 1 deletion public/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, {
Expand Down

0 comments on commit 4e5a8f6

Please sign in to comment.