mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
adding extra confirmation on profile delete
This commit is contained in:
parent
97831daebe
commit
a5c39ea1e7
@ -66,18 +66,16 @@ export function Profile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const remove = async () => {
|
const remove = async () => {
|
||||||
|
try {
|
||||||
|
await actions.remove();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
"Deleting Account",
|
'Failed to Delete Account',
|
||||||
"Confirm?",
|
'Please try again.'
|
||||||
[
|
)
|
||||||
{ text: "Cancel",
|
}
|
||||||
onPress: () => {},
|
|
||||||
},
|
|
||||||
{ text: "Delete", onPress: () => {
|
|
||||||
actions.remove();
|
|
||||||
}}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
@ -187,7 +185,7 @@ export function Profile() {
|
|||||||
<Ionicons name="logout" size={14} color={Colors.white} />
|
<Ionicons name="logout" size={14} color={Colors.white} />
|
||||||
<Text style={styles.logoutText}>Logout</Text>
|
<Text style={styles.logoutText}>Logout</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity style={styles.delete} onPress={remove}>
|
<TouchableOpacity style={styles.delete} onPress={actions.showDelete}>
|
||||||
<Ionicons name="delete" size={14} color={Colors.white} />
|
<Ionicons name="delete" size={14} color={Colors.white} />
|
||||||
<Text style={styles.deleteText}>Delete</Text>
|
<Text style={styles.deleteText}>Delete</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@ -385,6 +383,39 @@ export function Profile() {
|
|||||||
</View>
|
</View>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
<Modal
|
||||||
|
animationType="fade"
|
||||||
|
transparent={true}
|
||||||
|
visible={state.showDelete}
|
||||||
|
supportedOrientations={['portrait', 'landscape']}
|
||||||
|
onRequestClose={actions.hideDelete}
|
||||||
|
>
|
||||||
|
<KeyboardAvoidingView behavior="height" style={styles.editWrapper}>
|
||||||
|
<View style={styles.editContainer}>
|
||||||
|
<Text style={styles.editHeader}>Deleting Your Account</Text>
|
||||||
|
<View style={styles.inputField}>
|
||||||
|
<TextInput style={styles.input} value={state.confirmDelete} onChangeText={actions.setConfirmDelete}
|
||||||
|
autoCapitalize="none" placeholder="Type 'delete' to Confirm" placeholderTextColor={Colors.grey} />
|
||||||
|
</View>
|
||||||
|
<View style={styles.editControls}>
|
||||||
|
<TouchableOpacity style={styles.cancel} onPress={actions.hideDelete}>
|
||||||
|
<Text>Cancel</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
{ state.confirmDelete === 'delete' && (
|
||||||
|
<TouchableOpacity style={styles.remove} onPress={remove}>
|
||||||
|
<Text style={styles.removeText}>Delete</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
{ state.confirmDelete !== 'delete' && (
|
||||||
|
<TouchableOpacity style={styles.unconfirmed}>
|
||||||
|
<Text style={styles.removeText}>Delete</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -136,21 +136,26 @@ export const styles = StyleSheet.create({
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
paddingLeft: 8,
|
paddingLeft: 8,
|
||||||
},
|
},
|
||||||
delete: {
|
unconfirmed: {
|
||||||
marginTop: 32,
|
backgroundColor: Colors.lightgrey,
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
backgroundColor: Colors.error,
|
padding: 8,
|
||||||
|
width: 72,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
paddingLeft: 8,
|
justifyContent: 'center',
|
||||||
paddingRight: 8,
|
|
||||||
paddingTop: 8,
|
|
||||||
paddingBottom: 8,
|
|
||||||
},
|
},
|
||||||
deleteText: {
|
remove: {
|
||||||
|
backgroundColor: Colors.error,
|
||||||
|
borderRadius: 4,
|
||||||
|
padding: 8,
|
||||||
|
width: 72,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
removeText: {
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
paddingLeft: 8,
|
|
||||||
},
|
},
|
||||||
switch: {
|
switch: {
|
||||||
false: Colors.grey,
|
false: Colors.grey,
|
||||||
@ -240,12 +245,36 @@ export const styles = StyleSheet.create({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
},
|
},
|
||||||
|
save: {
|
||||||
|
padding: 8,
|
||||||
|
borderRadius: 4,
|
||||||
|
backgroundColor: Colors.error,
|
||||||
|
width: 72,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
link: {
|
link: {
|
||||||
marginTop: 16,
|
marginTop: 16,
|
||||||
},
|
},
|
||||||
linkText: {
|
linkText: {
|
||||||
color: Colors.primary,
|
color: Colors.primary,
|
||||||
},
|
},
|
||||||
|
delete: {
|
||||||
|
backgroundColor: Colors.error,
|
||||||
|
marginTop: 16,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
paddingLeft: 8,
|
||||||
|
paddingRight: 8,
|
||||||
|
paddingTop: 8,
|
||||||
|
paddingBottom: 8,
|
||||||
|
borderRadius: 4,
|
||||||
|
},
|
||||||
|
deleteText: {
|
||||||
|
paddingLeft: 8,
|
||||||
|
color: Colors.white,
|
||||||
|
},
|
||||||
saveText: {
|
saveText: {
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
},
|
},
|
||||||
|
@ -28,11 +28,13 @@ export function useProfile() {
|
|||||||
available: true,
|
available: true,
|
||||||
showPassword: false,
|
showPassword: false,
|
||||||
showConfirm: false,
|
showConfirm: false,
|
||||||
|
showDelete: false,
|
||||||
blockedChannels: false,
|
blockedChannels: false,
|
||||||
blockedCards: false,
|
blockedCards: false,
|
||||||
blockedMessages: false,
|
blockedMessages: false,
|
||||||
tabbed: null,
|
tabbed: null,
|
||||||
disconnected: false,
|
disconnected: false,
|
||||||
|
confirmDelete: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const app = useContext(AppContext);
|
const app = useContext(AppContext);
|
||||||
@ -78,6 +80,7 @@ export function useProfile() {
|
|||||||
},
|
},
|
||||||
remove: async () => {
|
remove: async () => {
|
||||||
await app.actions.remove();
|
await app.actions.remove();
|
||||||
|
updateState({ showDelete: false });
|
||||||
navigate('/');
|
navigate('/');
|
||||||
},
|
},
|
||||||
setVisible: async (searchable) => {
|
setVisible: async (searchable) => {
|
||||||
@ -126,6 +129,9 @@ export function useProfile() {
|
|||||||
setEditDescription: (editDescription) => {
|
setEditDescription: (editDescription) => {
|
||||||
updateState({ editDescription });
|
updateState({ editDescription });
|
||||||
},
|
},
|
||||||
|
setConfirmDelete: (confirmDelete) => {
|
||||||
|
updateState({ confirmDelete });
|
||||||
|
},
|
||||||
showPassword: () => {
|
showPassword: () => {
|
||||||
updateState({ showPassword: true });
|
updateState({ showPassword: true });
|
||||||
},
|
},
|
||||||
@ -138,6 +144,12 @@ export function useProfile() {
|
|||||||
hideConfirm: () => {
|
hideConfirm: () => {
|
||||||
updateState({ showConfirm: false });
|
updateState({ showConfirm: false });
|
||||||
},
|
},
|
||||||
|
showDelete: () => {
|
||||||
|
updateState({ showDelete: true });
|
||||||
|
},
|
||||||
|
hideDelete: () => {
|
||||||
|
updateState({ showDelete: false });
|
||||||
|
},
|
||||||
setEditHandle: (editHandle) => {
|
setEditHandle: (editHandle) => {
|
||||||
updateState({ editHandle, checked: false });
|
updateState({ editHandle, checked: false });
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user