This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Delete account works. TODO: Refactor duplicated code and handle modal notification popup * add code suggestion * fix popup notifications on logout
- Loading branch information
1 parent
20fca0d
commit 10eb3ea
Showing
5 changed files
with
206 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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://[email protected]/6567185', | ||
// eslint-disable-next-line no-undef | ||
|
@@ -34,6 +34,8 @@ Sentry.init({ | |
tracesSampleRate: 1.0, | ||
}); | ||
|
||
LogBox.ignoreLogs(['rgb']); | ||
|
||
const NavigationApp = () => ( | ||
<NavigationContainer> | ||
<OverlayContextProvider> | ||
|
@@ -74,5 +76,3 @@ export default function App() { | |
</ActionSheetProvider> | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<View style={styles.container}> | ||
<GoBackHeader text='Account' /> | ||
<View style={styles.content}> | ||
<TouchableOpacity style={{ ...styles.navigateContainer, marginTop: 10 }} disabled> | ||
<Text style={{ ...Fonts.bold(12, Colors.darkGrey) }}>Subscription</Text> | ||
<View style={styles.navigateArrow}> | ||
<AntDesign name='arrowright' size={24} color={Colors.white} /> | ||
</View> | ||
</TouchableOpacity> | ||
<TouchableOpacity style={styles.navigateContainer} disabled> | ||
<Text style={{ ...Fonts.bold(12, Colors.darkGrey) }}>Restore purchase</Text> | ||
<View style={styles.navigateArrow}> | ||
<AntDesign name='arrowright' size={24} color={Colors.white} /> | ||
</View> | ||
</TouchableOpacity> | ||
<TouchableOpacity style={styles.navigateContainer} disabled> | ||
<Text style={{ ...Fonts.bold(12, Colors.darkGrey) }}>Reset password</Text> | ||
<View style={styles.navigateArrow}> | ||
<AntDesign name='arrowright' size={24} color={Colors.white} /> | ||
</View> | ||
</TouchableOpacity> | ||
</View> | ||
<View style={styles.spacer} /> | ||
<TouchableOpacity onPress={handleDeleteAccount}> | ||
<Text style={{ ...Fonts.regular(12, Colors.lightGrey) }}> Delete my account </Text> | ||
</TouchableOpacity> | ||
</View> | ||
); | ||
}; | ||
|
||
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, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters