- Implemented assigning todos

This commit is contained in:
Dejan
2024-10-20 20:45:09 +02:00
parent 206ffd5a88
commit 709b333ee1
6 changed files with 75 additions and 36 deletions

View File

@ -7,5 +7,6 @@ export interface IToDo {
rotate: boolean;
repeatType: string;
creatorId?: string,
familyId?: string
familyId?: string,
assignees?: string[]; // Optional list of assignees
}

View File

@ -15,10 +15,24 @@ export const useGetFamilyMembers = (excludeSelf?: boolean) => {
.get();
if (excludeSelf) {
return snapshot.docs.map((doc) => doc.data()).filter((doc) => doc.id !== user?.uid) as UserProfile[];
return snapshot.docs.map((doc) => {
let documentData = doc.data();
return {
...documentData,
uid: doc.id
}
}).filter((doc) => doc.id !== user?.uid) as UserProfile[];
}
return snapshot.docs.map((doc) => doc.data()) as UserProfile[];
return snapshot.docs.map((doc) => {
let documentData = doc.data();
return {
...documentData,
uid: doc.id
}
}) as UserProfile[];
}
})
}

View File

@ -1,6 +1,8 @@
import { useQuery } from "react-query";
import firestore from "@react-native-firebase/firestore";
import { useAuthContext } from "@/contexts/AuthContext";
import {UserProfile} from "@/hooks/firebase/types/profileTypes";
import {IToDo} from "@/hooks/firebase/types/todoData";
export const useGetTodos = () => {
const { user, profileData } = useAuthContext();
@ -17,16 +19,11 @@ export const useGetTodos = () => {
const data = doc.data();
return {
...data,
id: doc.id,
title: data.title,
done: data.done,
date: data.date ? new Date(data.date.seconds * 1000) : null,
points: data.points,
rotate: data.points,
repeatType: data.repeatType,
creatorId: data.creatorId
};
});
}) as IToDo[];
}
})
};