mirror of
https://github.com/urosran/cally.git
synced 2025-07-15 17:47:08 +00:00
Fix
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
import { useMutation } from "react-query";
|
||||
import auth from "@react-native-firebase/auth";
|
||||
import { useUpdateUserData } from "@/hooks/firebase/useUpdateUserData";
|
||||
import { ProfileType } from "@/contexts/AuthContext";
|
||||
|
||||
export const useSignIn = () => {
|
||||
|
||||
|
@ -4,13 +4,13 @@ import {useUpdateUserData} from "@/hooks/firebase/useUpdateUserData";
|
||||
import {ProfileType} from "@/contexts/AuthContext";
|
||||
|
||||
export const useSignUp = () => {
|
||||
const { mutateAsync: updateUserData } = useUpdateUserData()
|
||||
const {mutateAsync: updateUserData} = useUpdateUserData()
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["signUp"],
|
||||
mutationFn: async ({email, password}: { email: string, password: string }) => {
|
||||
const res= await auth().createUserWithEmailAndPassword(email, password);
|
||||
await updateUserData({userType: ProfileType.PARENT, email, password, customUser: res.user});
|
||||
const res = await auth().createUserWithEmailAndPassword(email, password);
|
||||
await updateUserData({newUserData: {userType: ProfileType.PARENT}, customUser: res.user});
|
||||
}
|
||||
});
|
||||
}
|
@ -9,19 +9,23 @@ export const useUpdateUserData = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["updateUserData"],
|
||||
mutationFn: async (newProfileData: Partial<UserProfile & { customUser?: FirebaseAuthTypes.User }>) => {
|
||||
const user = currentUser ?? newProfileData.customUser
|
||||
mutationFn: async ({newUserData, customUser}: {newUserData: Partial<UserProfile>, customUser?: FirebaseAuthTypes.User }) => {
|
||||
const user = currentUser ?? customUser
|
||||
|
||||
if (user) {
|
||||
try {
|
||||
console.log("yall don't even");
|
||||
console.log(newUserData)
|
||||
await firestore()
|
||||
.collection("Profiles")
|
||||
.doc(user.uid)
|
||||
.set(newProfileData);
|
||||
.set(newUserData);
|
||||
|
||||
console.log("wtf")
|
||||
const profileData = await firestore().collection("Profiles").doc(user?.uid!).get()
|
||||
console.log("wtf222")
|
||||
|
||||
console.log(profileData)
|
||||
setProfileData(profileData.data() as UserProfile)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
Reference in New Issue
Block a user