diff --git a/app/mobile/src/session/settings/Settings.jsx b/app/mobile/src/session/settings/Settings.jsx index a1426dd2..bb529cc9 100644 --- a/app/mobile/src/session/settings/Settings.jsx +++ b/app/mobile/src/session/settings/Settings.jsx @@ -1,13 +1,15 @@ import { useState } from 'react'; import { Linking, ActivityIndicator, KeyboardAvoidingView, Modal, ScrollView, View, Switch, Text, TextInput, TouchableOpacity, Alert } from 'react-native'; import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; +import { useNavigate } from 'react-router-dom'; import { styles } from './Settings.styled'; import { useSettings } from './useSettings.hook'; import MatIcons from 'react-native-vector-icons/MaterialCommunityIcons'; import Colors from 'constants/Colors'; export function Settings() { - + + const navigate = useNavigate(); const [ busy, setBusy ] = useState(false); const { state, actions } = useSettings(); @@ -77,6 +79,24 @@ export function Settings() { } } + const deleteAccount = async () => { + if (!busy) { + try { + setBusy(true); + await actions.deleteAccount(); + navigate('/'); + } + catch (err) { + console.log(err); + Alert.alert( + 'Failed to Delete Account', + 'Please try again.', + ); + } + setBusy(false); + } + } + return ( @@ -561,20 +581,22 @@ export function Settings() { - - { state.sealDelete === state.strings.deleteKey && ( - sealAction(actions.removeKey, 'Remove')}> - { state.strings.delete } - - )} - { state.sealDelete !== state.strings.deleteKey && ( - - { state.strings.delete } - - )} + + { state.confirm === state.strings.deleteKey && ( + + { state.strings.delete } + + )} + { state.confirm !== state.strings.deleteKey && ( + + { state.strings.delete } + + )} + diff --git a/app/mobile/src/session/settings/Settings.styled.js b/app/mobile/src/session/settings/Settings.styled.js index 79f40e64..a0c27792 100644 --- a/app/mobile/src/session/settings/Settings.styled.js +++ b/app/mobile/src/session/settings/Settings.styled.js @@ -217,8 +217,8 @@ export const styles = StyleSheet.create({ fontFamily: 'Roboto', }, dangerButton: { - marginTop: 32, - marginBottom: 16, + marginTop: 8, + marginBottom: 8, paddingTop: 8, paddingBottom: 8, paddingLeft: 32, diff --git a/app/mobile/src/session/settings/useSettings.hook.js b/app/mobile/src/session/settings/useSettings.hook.js index 0e878dac..77ffb693 100644 --- a/app/mobile/src/session/settings/useSettings.hook.js +++ b/app/mobile/src/session/settings/useSettings.hook.js @@ -103,6 +103,9 @@ export function useSettings() { changeLogin: async () => { await account.actions.setLogin(state.username, state.password); }, + deleteAccount: async () => { + await app.actions.remove(); + }, setUsername: (username) => { clearTimeout(debounce.current); checking.current = username; @@ -130,7 +133,7 @@ export function useSettings() { await app.actions.logout(); }, showDelete: () => { - updateState({ delete: true }); + updateState({ delete: true, confirm: null }); }, hideDelete: () => { updateState({ delete: false });