- 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

@ -51,6 +51,18 @@ export const useUpdateTodo = () => {
const newDoc = firestore().collection('Todos').doc();
let originalTodo = {...todoData, id: newDoc.id, familyId: profileData?.familyId, creatorId: currentUser?.uid}
batch.set(newDoc, originalTodo);
} else if (todoData.repeatType === REPEAT_TYPE.DAILY) {
console.log("DAILY");
// for the next 52 weeks
for (let i = 0; i < 52; i++) {
let date = todoData?.date;
const nextWeek = addWeeks(date, i);
let docRef = firestore().collection("Todos").doc();
let newTodo = { ...todoData, id: docRef.id, date: nextWeek, connectedTodoId: firstTodo?.connectedTodoId };
newTodo = resolveTodoAlternatingAssignees(todoData, newTodo, i);
batch.set(docRef, newTodo);
}
} else if (todoData.repeatType === REPEAT_TYPE.EVERY_WEEK) {
console.log("EVERY WEEK");