Added creating family devices, refetch calendar on notification received

This commit is contained in:
Milan Paunovic
2024-10-13 10:21:38 +02:00
parent 9123aab566
commit 1e506dd246
6 changed files with 479 additions and 391 deletions

View File

@ -2,6 +2,7 @@ import {useMutation, useQueryClient} from "react-query";
import {UserProfile} from "@/hooks/firebase/types/profileTypes";
import functions from '@react-native-firebase/functions';
import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
import {HttpsCallableResult} from "@firebase/functions";
export const useCreateSubUser = () => {
const queryClient = useQueryClient()
@ -9,13 +10,13 @@ export const useCreateSubUser = () => {
return useMutation({
mutationKey: ["createSubUser"],
mutationFn: async ({email, ...userProfile}: { email: string } & UserProfile) => {
mutationFn: async ({email, ...userProfile}: { email?: string } & UserProfile) => {
if (profileType === ProfileType.PARENT) {
return await functions().httpsCallable("createSubUser")({
...userProfile,
email,
familyId: profileData?.familyId
})
}) as HttpsCallableResult<{ userId: string }>
} else {
throw Error("Can't create sub-users as a non-parent.")
}