- Added Daily repeat type for the todos and implemented creating and updating this kinds of todos

This commit is contained in:
Dejan
2024-11-10 18:00:17 +01:00
parent 7da8005fb1
commit 5b80a3ba80
4 changed files with 32 additions and 6 deletions

View File

@ -40,7 +40,19 @@ export const useCreateTodo = () => {
const batch = firestore().batch();
if (todoData.repeatType === REPEAT_TYPE.EVERY_WEEK) {
if (todoData.repeatType === REPEAT_TYPE.DAILY) {
// for the next 52 weeks
for (let i = 1; i < 52; i++) {
let date = originalTodo.date;
const nextWeek = addWeeks(date, i);
let docRef = firestore().collection("Todos").doc();
let newTodo = { ...originalTodo, id: docRef.id, date: nextWeek, connectedTodoId: newDoc.id };
newTodo = resolveTodoAlternatingAssignees(todoData, newTodo, i);
batch.set(docRef, newTodo);
}
} else if (todoData.repeatType === REPEAT_TYPE.EVERY_WEEK) {
let date = originalTodo.date;
let repeatDays = originalTodo.repeatDays;