mirror of
https://github.com/urosran/cally.git
synced 2025-07-14 17:25:46 +00:00
Adding and displaying family members
This commit is contained in:
@ -5,13 +5,16 @@ import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
|
||||
|
||||
export const useCreateSubUser = () => {
|
||||
const queryClient = useQueryClient()
|
||||
const { profileType } = useAuthContext()
|
||||
const {profileType, profileData} = useAuthContext()
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["createSubUser"],
|
||||
mutationFn: async ({email, ...userProfile}: { email: string } & UserProfile) => {
|
||||
if(profileType === ProfileType.PARENT) {
|
||||
return await functions().httpsCallable("createSubUser")({email, ...userProfile})
|
||||
if (profileType === ProfileType.PARENT) {
|
||||
return await functions().httpsCallable("createSubUser")({
|
||||
email,
|
||||
userProfile: {...userProfile, familyId: profileData?.familyId}
|
||||
})
|
||||
} else {
|
||||
throw Error("Can't create sub-users as a non-parent.")
|
||||
}
|
||||
|
Reference in New Issue
Block a user