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