Fix profile type

This commit is contained in:
Milan Paunovic
2024-08-21 20:30:07 +02:00
parent 6b42476ef0
commit 55a3091023
4 changed files with 24 additions and 19 deletions
+6 -5
View File
@@ -1,10 +1,12 @@
import {ProfileType} from "@/contexts/AuthContext";
export interface User {
uid: string;
email: string | null;
}
export interface UserProfile {
userType: "parent" | "child" | "caregiver";
userType: ProfileType;
name: string;
childrenIds?: string[];
birthday?: Date;
@@ -15,18 +17,17 @@ export interface User {
}
export interface ParentProfile extends UserProfile {
userType: "parent";
userType: ProfileType.PARENT;
childrenIds: string[];
}
export interface ChildProfile extends UserProfile {
userType: "child";
userType: ProfileType.CHILD;
birthday: Date;
parentId: string;
}
export interface CaregiverProfile extends UserProfile {
userType: "caregiver";
//assignedChildrenId: string[];
userType: ProfileType.CAREGIVER;
contact: string;
}
+2 -1
View File
@@ -1,6 +1,7 @@
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 useSignUp = () => {
const { mutateAsync: updateUserData } = useUpdateUserData()
@@ -9,7 +10,7 @@ export const useSignUp = () => {
mutationKey: ["signUp"],
mutationFn: async ({email, password}: { email: string, password: string }) => {
await auth().createUserWithEmailAndPassword(email, password)
await updateUserData({userType: "parent", email, password})
await updateUserData({userType: ProfileType.PARENT, email, password})
}
});
}