mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-12 18:43:50 +00:00
refactor(#54): Improve month string formatting for consistent sorting
This commit is contained in:
@@ -19,7 +19,7 @@ export async function load({ locals: { safeGetSession } }) {
|
|||||||
|
|
||||||
const monthlyAggregates = transactions.reduce((acc, transaction) => {
|
const monthlyAggregates = transactions.reduce((acc, transaction) => {
|
||||||
const date = new Date(transaction.created_at);
|
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 };
|
if (!acc[month]) acc[month] = { credits_added: 0, credits_deducted: 0 };
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
const groupedTransactions = transactions.reduce((acc, transaction) => {
|
const groupedTransactions = transactions.reduce((acc, transaction) => {
|
||||||
const date = new Date(transaction.created_at);
|
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] = [];
|
if (!acc[month]) acc[month] = [];
|
||||||
acc[month].push(transaction);
|
acc[month].push(transaction);
|
||||||
return acc;
|
return acc;
|
||||||
|
|||||||
Reference in New Issue
Block a user