- Fixed issue with uploading images for other users

This commit is contained in:
Dejan
2024-12-17 21:52:55 +01:00
parent 0b56b169a5
commit 956628bcb6
2 changed files with 13 additions and 6 deletions

View File

@ -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) => {
</TouchableOpacity>
<TouchableOpacity onPress={pickImage}>
<Text style={styles.photoSet} color="#50be0c" onPress={pickImage}>
<Text style={styles.photoSet} color="#50be0c">
{profileData?.pfp ? "Change" : "Add"} Photo
</Text>
</TouchableOpacity>

View File

@ -43,6 +43,11 @@ export const useChangeProfilePicture = (customUserId?: string) => {
.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"]});
}
},
});