сегодняшний день учитывается в графиках

This commit is contained in:
Nastya 2025-07-28 16:36:16 +03:00
parent 083ff081e8
commit 2882bb7e74

@ -131,11 +131,21 @@ export const General: FC<GeneralProps> = ({ data, day }) => {
const generalResponse = Object.entries(data).reduce( const generalResponse = Object.entries(data).reduce(
(total, [fatherKey, values]) => { (total, [fatherKey, values]) => {
const value = Object.keys(values).reduce((totalValue, key) => { const value = Object.keys(values).reduce((totalValue, key) => {
if (Number(key) - currentDate < 0) { const keyTimestamp = Number(key);
return { ...totalValue, [key]: values[key] }; const todayStart = moment().startOf('day').unix();
} const todayEnd = moment().endOf('day').unix();
return totalValue; // Включаем данные за сегодня и прошлые дни, исключаем будущие дни
if (keyTimestamp >= todayStart && keyTimestamp <= todayEnd) {
// Сегодняшний день - включаем
return { ...totalValue, [key]: values[key] };
} else if (keyTimestamp < todayStart) {
// Прошлые дни - включаем
return { ...totalValue, [key]: values[key] };
} else {
// Будущие дни - исключаем
return totalValue;
}
}, {}); }, {});
return { ...total, [fatherKey]: value }; return { ...total, [fatherKey]: value };