This commit is contained in:
Milan Paunovic
2024-08-23 18:04:30 +02:00
parent 0a862e7a8c
commit 5863ed7f4d
2 changed files with 7 additions and 4 deletions

View File

@ -9,8 +9,8 @@ export const useSignUp = () => {
return useMutation({ return useMutation({
mutationKey: ["signUp"], mutationKey: ["signUp"],
mutationFn: async ({email, password}: { email: string, password: string }) => { mutationFn: async ({email, password}: { email: string, password: string }) => {
await auth().createUserWithEmailAndPassword(email, password); const res= await auth().createUserWithEmailAndPassword(email, password);
await updateUserData({userType: ProfileType.PARENT, email, password}); await updateUserData({userType: ProfileType.PARENT, email, password, customUser: res.user});
} }
}); });
} }

View File

@ -2,13 +2,16 @@ import {useAuthContext} from "@/contexts/AuthContext";
import {useMutation} from "react-query"; import {useMutation} from "react-query";
import firestore from "@react-native-firebase/firestore"; import firestore from "@react-native-firebase/firestore";
import {UserProfile} from "@/hooks/firebase/types/profileTypes"; import {UserProfile} from "@/hooks/firebase/types/profileTypes";
import {FirebaseAuthTypes} from "@react-native-firebase/auth";
export const useUpdateUserData = () => { export const useUpdateUserData = () => {
const {user, setProfileData} = useAuthContext() const {user: currentUser, setProfileData} = useAuthContext()
return useMutation({ return useMutation({
mutationKey: ["updateUserData"], mutationKey: ["updateUserData"],
mutationFn: async (newProfileData: Partial<UserProfile>) => { mutationFn: async (newProfileData: Partial<UserProfile & { customUser?: FirebaseAuthTypes.User }>) => {
const user = currentUser ?? newProfileData.customUser
if (user) { if (user) {
try { try {
console.log("yall don't even"); console.log("yall don't even");