mirror of
https://github.com/urosran/cally.git
synced 2025-07-16 01:56:16 +00:00
fix groceries, todo, calendar
This commit is contained in:
@ -1,16 +1,40 @@
|
||||
import {useMutation} from "react-query";
|
||||
import { useMutation } from "react-query";
|
||||
import auth from "@react-native-firebase/auth";
|
||||
import {useUpdateUserData} from "@/hooks/firebase/useUpdateUserData";
|
||||
import {ProfileType} from "@/contexts/AuthContext";
|
||||
import { ProfileType } from "@/contexts/AuthContext";
|
||||
import { useSetUserData } from "./useSetUserData";
|
||||
|
||||
export const useSignUp = () => {
|
||||
const {mutateAsync: updateUserData} = useUpdateUserData()
|
||||
const { mutateAsync: setUserData } = useSetUserData();
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["signUp"],
|
||||
mutationFn: async ({email, password, firstName, lastName}: { email: string, password: string, firstName: string, lastName: string }) => {
|
||||
const res = await auth().createUserWithEmailAndPassword(email, password);
|
||||
await updateUserData({newUserData: {userType: ProfileType.PARENT, firstName: firstName, lastName: lastName}, customUser: res.user});
|
||||
}
|
||||
});
|
||||
}
|
||||
return useMutation({
|
||||
mutationKey: ["signUp"],
|
||||
mutationFn: async ({
|
||||
email,
|
||||
password,
|
||||
firstName,
|
||||
lastName,
|
||||
}: {
|
||||
email: string;
|
||||
password: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}) => {
|
||||
await auth()
|
||||
.createUserWithEmailAndPassword(email, password)
|
||||
.then(async (res) => {
|
||||
try {
|
||||
await setUserData({
|
||||
newUserData: {
|
||||
userType: ProfileType.PARENT,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
},
|
||||
customUser: res.user,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user