mirror of
https://github.com/urosran/cally.git
synced 2025-07-14 09:17:19 +00:00
- Fixed incorrect saving of the points per day
This commit is contained in:
@ -139,7 +139,8 @@ export const useUpdateTodo = () => {
|
|||||||
Saturday: 0,
|
Saturday: 0,
|
||||||
Sunday: 0,
|
Sunday: 0,
|
||||||
};
|
};
|
||||||
const currentDay = getCurrentDay();
|
|
||||||
|
const currentDay = getCurrentDay(todoUpdate.date);
|
||||||
const updatedPointsPerDay = todoData.done
|
const updatedPointsPerDay = todoData.done
|
||||||
? pointsPerDay[currentDay] + todoUpdate.points
|
? pointsPerDay[currentDay] + todoUpdate.points
|
||||||
: pointsPerDay[currentDay] - todoUpdate.points;
|
: pointsPerDay[currentDay] - todoUpdate.points;
|
||||||
@ -158,7 +159,7 @@ export const useUpdateTodo = () => {
|
|||||||
userData = {
|
userData = {
|
||||||
...userData,
|
...userData,
|
||||||
weeklyPoints: weeklyPoints >= 0 ? weeklyPoints : 0,
|
weeklyPoints: weeklyPoints >= 0 ? weeklyPoints : 0,
|
||||||
weeklyDayPoints: updatedPointsPerDay,
|
weeklyDayPoints: pointsPerDay,
|
||||||
allTimePoints: allTimePoints >= 0 ? allTimePoints : 0,
|
allTimePoints: allTimePoints >= 0 ? allTimePoints : 0,
|
||||||
weeklyCompletedTodos: weeklyCompletedTodos >= 0 ? weeklyCompletedTodos : 0
|
weeklyCompletedTodos: weeklyCompletedTodos >= 0 ? weeklyCompletedTodos : 0
|
||||||
}
|
}
|
||||||
@ -184,8 +185,8 @@ export const useUpdateTodo = () => {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCurrentDay = () => {
|
const getCurrentDay = (date) => {
|
||||||
|
let selectedDate = new Date(date.seconds * 1000);
|
||||||
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
||||||
const now = new Date();
|
return days[selectedDate.getDay()];
|
||||||
return days[now.getDay()];
|
|
||||||
};
|
};
|
Reference in New Issue
Block a user