mirror of
https://github.com/urosran/cally.git
synced 2025-11-27 00:44:54 +00:00
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:
@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user