diff --git a/App.js b/App.js index be38b6c4..97bcd46a 100644 --- a/App.js +++ b/App.js @@ -14,6 +14,7 @@ import { import * as Sentry from '@sentry/react-native'; import { ActionSheetProvider, connectActionSheet } from '@expo/react-native-action-sheet'; +import { LogBox } from 'react-native'; import Navigation from './src/navigation/Navigation'; import UserProvider from './src/states/UserContextProvider'; import GeolocationProvider from './src/states/GeolocationContextProvider'; @@ -23,7 +24,6 @@ import OverlayContextProvider from './src/states/OverlayContextProvider'; import SocketContextProvider from './src/states/SocketContextProvider'; import ConversationsContextProvider from './src/states/ConversationsContextProvider'; - Sentry.init({ dsn: 'https://19407e7c32a2487689649a399a55c564@o1315355.ingest.sentry.io/6567185', // eslint-disable-next-line no-undef @@ -34,6 +34,8 @@ Sentry.init({ tracesSampleRate: 1.0, }); +LogBox.ignoreLogs(['rgb']); + const NavigationApp = () => ( @@ -74,5 +76,3 @@ export default function App() { ); } - - diff --git a/src/navigation/Navigation.js b/src/navigation/Navigation.js index ce5f64b2..31ab2564 100644 --- a/src/navigation/Navigation.js +++ b/src/navigation/Navigation.js @@ -16,6 +16,7 @@ import ProfileEditScreen from '../screens/ProfileEditScreen'; import BlockedUsersScreen from '../screens/BlockedUsersScreen'; import UserDropiesScreen from '../screens/UserDropiesScreen'; import Onboarding from '../screens/Onboarding'; +import AccountScreen from '../screens/AccountScreen'; const MainStack = createStackNavigator(); @@ -45,6 +46,7 @@ export default function Navigation() { + ); } diff --git a/src/screens/AccountScreen.js b/src/screens/AccountScreen.js new file mode 100644 index 00000000..71603855 --- /dev/null +++ b/src/screens/AccountScreen.js @@ -0,0 +1,121 @@ +import { AntDesign } from '@expo/vector-icons'; +import React from 'react'; +import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; +import { responsiveWidth } from 'react-native-responsive-dimensions'; +import GoBackHeader from '../components/other/GoBackHeader'; +import useOverlay from '../hooks/useOverlay'; +import API from '../services/API'; +import Styles, { Colors, Fonts } from '../styles/Styles'; + +const AccountScreen = ({ navigation }) => { + const { sendAlert } = useOverlay(); + + + const handleDeleteAccount = async () => { + const confirmed = await sendAlert({ + title: 'Are you sure?', + description: 'Your account and all your data will be deleted!', + denyText: 'Cancel', + validateText: 'Delete', + }); + + if (!confirmed) + return; + + try { + const response = await API.deleteAccount(); + console.log(response.data); + await API.logout(); + navigation.reset({ + index: 0, + routes: [ + { + name: 'Splash', + params: { cancelAutoLogin: true }, + } + ], + }); + } catch (error) { + sendAlert({ + title: 'Oh no...', + description: 'We couldn\'t delete your account..\nCheck your internet connection!', + }); + console.error('Error while deleting user', error?.response?.data || error); + } + }; + + return ( + + + + + Subscription + + + + + + Restore purchase + + + + + + Reset password + + + + + + + + Delete my account + + + ); +}; + +export default AccountScreen; + +const styles = StyleSheet.create({ + container: { + flex: 1, + alignItems: 'center', + backgroundColor: Colors.white, + ...Styles.safeAreaView, + }, + content: { + width: responsiveWidth(100), + alignItems: 'center', + marginTop: 20, + height: '80%', + }, + navigateContainer: { + alignItems: 'center', + flexDirection: 'row', + justifyContent: 'space-between', + backgroundColor: Colors.lighterGrey, + width: '90%', + borderRadius: 20, + paddingVertical: 10, + paddingHorizontal: 15, + ...Styles.softShadows, + shadowOpacity: 0.2, + height: 50, + marginBottom: 10, + }, + navigateArrow: { + ...Styles.center, + backgroundColor: Colors.darkGrey, + height: '95%', + width: 50, + borderRadius: 12, + }, + spacer: { + width: '90%', + height: 2, + borderRadius: 1, + backgroundColor: Colors.lighterGrey, + marginVertical: 20, + }, +}); diff --git a/src/screens/SettingScreen.js b/src/screens/SettingScreen.js index 7a3afeb4..86a8d1d1 100644 --- a/src/screens/SettingScreen.js +++ b/src/screens/SettingScreen.js @@ -35,11 +35,12 @@ const SettingsScreen = ({ navigation }) => { const notificatinsSettingsRef = useRef(null); useEffect(() => { - fetchNotificationsSettings(); - return () => { + const unsubscribe = navigation.addListener('unfocus', () => { + fetchNotificationsSettings(); if (notificatinsSettingsRef.current != null) postNotificationsSettings(notificatinsSettingsRef.current); - }; + }); + return unsubscribe; }, []); useEffect(() => { @@ -57,7 +58,10 @@ const SettingsScreen = ({ navigation }) => { description: 'We were unable to retrieve your notification settings', validateText: 'Ok', }); - console.error('Error while fetch notifications settings', error.response?.data || error); + console.error( + 'Error while fetch notifications settings', + error.response?.data || error + ); navigation.goBack(); } }; @@ -72,7 +76,10 @@ const SettingsScreen = ({ navigation }) => { description: 'We were unable to update your notification settings', validateText: 'Ok', }); - console.error('Error while update notifications settings', error.response?.data || error); + console.error( + 'Error while update notifications settings', + error.response?.data || error + ); } }; @@ -96,12 +103,15 @@ const SettingsScreen = ({ navigation }) => { - Background location - Get alerted when you walk onto a drop with the app closed. - Highly recommended + + Get alerted when you walk onto a drop with the app closed. + + + Highly recommended + { setNotificationsSettings((old) => ({ ...old, dailyDropyReminder: value }))} + onValueChange={(value) => setNotificationsSettings((old) => ({ + ...old, + dailyDropyReminder: value, + })) + } /> setNotificationsSettings((old) => ({ ...old, dropyCollected: value }))} + onValueChange={(value) => setNotificationsSettings((old) => ({ ...old, dropyCollected: value })) + } /> setNotificationsSettings((old) => ({ ...old, newFeature: value }))} + onValueChange={(value) => setNotificationsSettings((old) => ({ ...old, newFeature: value })) + } /> - Others + {/* Others - + */} - navigation.navigate('UserDropies')}> + navigation.navigate('UserDropies')}> My drops - navigation.navigate('BlockedUsers')}> - Blocked users + navigation.navigate('BlockedUsers')}> + + Blocked users + + + + + + navigation.navigate('Account')}> + My account @@ -153,20 +183,34 @@ const SettingsScreen = ({ navigation }) => { - Linking.openURL('https://dropy-app.com/help')}> + Linking.openURL('https://dropy-app.com/help')}> Help - Linking.openURL('https://dropy-app.com/about')}> + Linking.openURL('https://dropy-app.com/about')}> About - Linking.openURL('https://dropy-app.com/privacy-policy.html')}> - Privacy Policy + Linking.openURL('https://dropy-app.com/privacy-policy.html') + }> + + Privacy Policy + - Linking.openURL('https://dropy-app.com/terms-conditions.html')}> - Terms & Conditions + Linking.openURL('https://dropy-app.com/terms-conditions.html') + }> + + Terms & Conditions + @@ -174,26 +218,24 @@ const SettingsScreen = ({ navigation }) => { + onPress={logout}> Logout - {/* eslint-disable-next-line no-undef */} - (user.isDeveloper || __DEV__) && setDeveloperMode((old) => !old)} activeOpacity={1}> + (user.isDeveloper || __DEV__) && setDeveloperMode((old) => !old) + } + activeOpacity={1}> - - {AppInfo.version} - + {AppInfo.version} - - {AppInfo.versionFlag} - + {AppInfo.versionFlag} @@ -217,7 +259,6 @@ const SettingsScreen = ({ navigation }) => { export default SettingsScreen; - const styles = StyleSheet.create({ container: { flex: 1, diff --git a/src/services/API.js b/src/services/API.js index 09ac9da7..3ed81f41 100644 --- a/src/services/API.js +++ b/src/services/API.js @@ -190,6 +190,11 @@ const getUserProfile = async () => { return response; }; +const deleteAccount = async () => { + const response = await axios.delete('/user/delete'); + return response; +}; + const logout = async () => { await init(); const removedItem = await Storage.removeItem('@auth_tokens'); @@ -234,6 +239,7 @@ const API = { getNotificationsSettings, postNotificationsSettings, init, + deleteAccount, }; export default API;