mirror of
https://github.com/urosran/cally.git
synced 2025-07-19 03:25:10 +00:00
profile deletion added
This commit is contained in:
2
app.json
2
app.json
@ -16,7 +16,7 @@
|
||||
"supportsTablet": true,
|
||||
"bundleIdentifier": "com.cally.app",
|
||||
"googleServicesFile": "./ios/GoogleService-Info.plist",
|
||||
"buildNumber": "63",
|
||||
"buildNumber": "64",
|
||||
"usesAppleSignIn": true
|
||||
},
|
||||
"android": {
|
||||
|
@ -2,6 +2,7 @@ import React, { useState } from "react";
|
||||
import { Dialog, Button, Text, View } from "react-native-ui-lib";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { Feather } from "@expo/vector-icons";
|
||||
import {useDeleteUser} from "@/hooks/firebase/useDeleteUser";
|
||||
|
||||
interface ConfirmationDialogProps {
|
||||
visible: boolean;
|
||||
@ -17,6 +18,7 @@ const DeleteProfileDialogs: React.FC<ConfirmationDialogProps> = ({
|
||||
onConfirm,
|
||||
}) => {
|
||||
const [confirmationDialog, setConfirmationDialog] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog
|
||||
|
@ -20,6 +20,7 @@ import { useUpdateUserData } from "@/hooks/firebase/useUpdateUserData";
|
||||
import { useChangeProfilePicture } from "@/hooks/firebase/useChangeProfilePicture";
|
||||
import { colorMap } from "@/constants/colorMap";
|
||||
import DeleteProfileDialogs from "../user_components/DeleteProfileDialogs";
|
||||
import {useDeleteUser} from "@/hooks/firebase/useDeleteUser";
|
||||
|
||||
const MyProfile = () => {
|
||||
const { user, profileData } = useAuthContext();
|
||||
@ -45,6 +46,7 @@ const MyProfile = () => {
|
||||
|
||||
const { mutateAsync: updateUserData } = useUpdateUserData();
|
||||
const { mutateAsync: changeProfilePicture } = useChangeProfilePicture();
|
||||
const { mutateAsync: deleteAsync } = useDeleteUser()
|
||||
const isFirstRender = useRef(true);
|
||||
|
||||
const handleUpdateUserData = async () => {
|
||||
@ -229,7 +231,7 @@ const MyProfile = () => {
|
||||
}}
|
||||
visible={showDeleteDialog}
|
||||
onDismiss={handleHideDeleteDialog}
|
||||
onConfirm={() => {console.log('delete account here')}}
|
||||
onConfirm={() => deleteAsync({})}
|
||||
/>
|
||||
</ScrollView>
|
||||
);
|
||||
|
32
hooks/firebase/useDeleteUser.ts
Normal file
32
hooks/firebase/useDeleteUser.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import {useMutation} from "react-query";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import auth, {FirebaseAuthTypes} from "@react-native-firebase/auth";
|
||||
|
||||
export const useDeleteUser = () => {
|
||||
const {user: currentUser} = useAuthContext();
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["deleteUser"],
|
||||
mutationFn: async ({customUser}: { customUser?: FirebaseAuthTypes.User }) => {
|
||||
const user = currentUser ?? customUser;
|
||||
|
||||
if (user) {
|
||||
try {
|
||||
await firestore()
|
||||
.collection("Profiles")
|
||||
.doc(user.uid)
|
||||
.delete();
|
||||
|
||||
await auth().currentUser?.delete();
|
||||
|
||||
await auth().signOut();
|
||||
|
||||
console.log("User deleted and signed out successfully");
|
||||
} catch (e) {
|
||||
console.error("Error deleting user:", e);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
@ -47,7 +47,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>63</string>
|
||||
<string>64</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
@ -138,6 +138,7 @@
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>SplashScreen</string>
|
||||
|
Reference in New Issue
Block a user