diff --git a/src/routes/(user)/credits/+page.server.ts b/src/routes/(user)/credits/+page.server.ts index 5cbc43e..f781a0d 100644 --- a/src/routes/(user)/credits/+page.server.ts +++ b/src/routes/(user)/credits/+page.server.ts @@ -19,7 +19,7 @@ export async function load({ locals: { safeGetSession } }) { const monthlyAggregates = transactions.reduce((acc, transaction) => { const date = new Date(transaction.created_at); - const month = `${date.getFullYear()}-${date.getMonth() + 1}`; + const month = date.toISOString().substring(0, 7); // Returns YYYY-MM format if (!acc[month]) acc[month] = { credits_added: 0, credits_deducted: 0 }; diff --git a/src/routes/(user)/credits/+page.svelte b/src/routes/(user)/credits/+page.svelte index 1d3b8fd..ffafa94 100644 --- a/src/routes/(user)/credits/+page.svelte +++ b/src/routes/(user)/credits/+page.svelte @@ -19,7 +19,7 @@ const groupedTransactions = transactions.reduce((acc, transaction) => { const date = new Date(transaction.created_at); - const month = `${date.getFullYear()}-${date.getMonth() + 1}`; + const month = date.toISOString().substring(0, 7); // Returns YYYY-MM format if (!acc[month]) acc[month] = []; acc[month].push(transaction); return acc;