Shopping List backend implementation

- Added creatorId to the grocery item in db and showed the name of the user that requested to add the new grocery
This commit is contained in:
Dejan
2024-10-11 18:02:13 +02:00
parent 86231daba4
commit cd62837198
5 changed files with 24 additions and 5 deletions

View File

@ -4,7 +4,7 @@ import { useAuthContext } from "@/contexts/AuthContext";
import {IGrocery} from "@/hooks/firebase/types/groceryData";
export const useCreateGrocery = () => {
const { profileData } = useAuthContext();
const { user: currentUser, profileData } = useAuthContext();
const queryClients = useQueryClient();
return useMutation({
@ -14,7 +14,7 @@ export const useCreateGrocery = () => {
const newDoc = firestore().collection('Groceries').doc();
await firestore()
.collection("Groceries")
.add({...groceryData, id: newDoc.id, familyId: profileData?.familyId})
.add({...groceryData, id: newDoc.id, familyId: profileData?.familyId, creatorId: currentUser?.uid})
} catch (e) {
console.error(e)
}