bugfixing

This commit is contained in:
MuslemRahimi 2025-02-26 16:36:41 +01:00
parent 73ee265f77
commit 7b70c45aaf

View File

@ -163,16 +163,14 @@ export const groupEarnings = (earnings) => {
return Object?.entries( return Object?.entries(
earnings earnings
?.reduce((acc, item) => { ?.reduce((acc, item) => {
const date = new Date(item?.date); const dateKey = new Intl.DateTimeFormat('en-US', {
const berlinDate = new Intl.DateTimeFormat('en-US', {
day: '2-digit', day: '2-digit',
month: 'short', month: 'short',
year: 'numeric', year: 'numeric',
timeZone: 'Europe/Berlin' }).format(new Date(item?.date));
}).format(date);
if (!acc[berlinDate]) acc[berlinDate] = []; if (!acc[dateKey]) acc[dateKey] = [];
acc[berlinDate]?.push(item); acc[dateKey]?.push(item);
return acc; return acc;
}, {}) }, {})
) )
@ -182,13 +180,9 @@ export const groupEarnings = (earnings) => {
date, date,
// Sort earnings within the date by time // Sort earnings within the date by time
earnings?.sort((a, b) => { earnings?.sort((a, b) => {
const berlinTimeA = new Date( const timeA = new Date(`1970-01-01T${a?.time}`);
new Date(`${item.date}T${a?.time}`).toLocaleString('en-US', { timeZone: 'Europe/Berlin' }) const timeB = new Date(`1970-01-01T${b?.time}`);
); return timeB - timeA;
const berlinTimeB = new Date(
new Date(`${item.date}T${b?.time}`).toLocaleString('en-US', { timeZone: 'Europe/Berlin' })
);
return berlinTimeB - berlinTimeA;
}) })
]); ]);
}; };