diff --git a/components/pages/settings/user_settings_views/UpdateUserDialog.tsx b/components/pages/settings/user_settings_views/UpdateUserDialog.tsx index 9a275c8..258d96c 100644 --- a/components/pages/settings/user_settings_views/UpdateUserDialog.tsx +++ b/components/pages/settings/user_settings_views/UpdateUserDialog.tsx @@ -50,7 +50,7 @@ const UpdateUserDialog = ({ open, handleClose, profileData }: Props) => { const { mutateAsync: updateUserData } = useUpdateUserData(); const { mutateAsync: updateSubUser } = useUpdateSubUser(); - const { mutateAsync: changeProfilePicture } = useChangeProfilePicture(); + const { mutateAsync: changeProfilePicture } = useChangeProfilePicture(profileData?.uid); const handleUpdateUserData = async () => { await updateSubUser({ @@ -150,7 +150,7 @@ const UpdateUserDialog = ({ open, handleClose, profileData }: Props) => { - + {profileData?.pfp ? "Change" : "Add"} Photo diff --git a/hooks/firebase/useChangeProfilePicture.ts b/hooks/firebase/useChangeProfilePicture.ts index cbd483b..c6d13c2 100644 --- a/hooks/firebase/useChangeProfilePicture.ts +++ b/hooks/firebase/useChangeProfilePicture.ts @@ -39,10 +39,15 @@ export const useChangeProfilePicture = (customUserId?: string) => { console.log("Download URL:", downloadURL); if(!customUserId) { - await firestore() - .collection("Profiles") - .doc(user?.uid) - .update({pfp: downloadURL}); + await firestore() + .collection("Profiles") + .doc(user?.uid) + .update({pfp: downloadURL}); + } else { + await firestore() + .collection("Profiles") + .doc(customUserId) + .update({pfp: downloadURL}); } } catch (e) { @@ -55,6 +60,8 @@ export const useChangeProfilePicture = (customUserId?: string) => { if (!customUserId) { queryClient.invalidateQueries({queryKey: ["Profiles"]}); refreshProfileData(); + } else { + queryClient.invalidateQueries({queryKey: ["Profiles"]}); } }, });