diff options
Diffstat (limited to 'components/Menu.jsx')
-rw-r--r-- | components/Menu.jsx | 100 |
1 files changed, 44 insertions, 56 deletions
diff --git a/components/Menu.jsx b/components/Menu.jsx index fb82f34..519fe94 100644 --- a/components/Menu.jsx +++ b/components/Menu.jsx @@ -1,61 +1,49 @@ -import { StyleSheet, Text, View, Alert } from 'react-native'; -import AsyncStorage from '@react-native-async-storage/async-storage'; -import { confirmLogout } from '../helpers' +import { StyleSheet, Text, View } from 'react-native'; +import { handleLogout } from '../helpers' -const Menu = ({ session, setSession, setEdit, showError, saveNote }) => { - const logout = async () => { - try { - await AsyncStorage.clear(); - setSession(null) - } catch(e) { - showError('Error while logging out') +const Menu = ({ session, setSession, setEdit, showError, saveNote }) => ( + <View style={styles.menu}> + { + saveNote + ? ( + <> + <Text + style={styles.menuText} + onPress={() => setEdit(null)} + > + Back + </Text> + <Text + style={styles.menuText} + onPress={saveNote} + > + Save + </Text> + </> + ) : ( + <> + <Text + style={styles.menuText} + onPress={() => setEdit({})} + > + New Note + </Text> + <Text + style={styles.menuText} + > + Sort + </Text> + <Text + style={styles.menuText} + onPress={() => handleLogout({ session, setSession, showError })} + > + {session.email} + </Text> + </> + ) } - } - - return ( - <View style={styles.menu}> - { - saveNote - ? ( - <> - <Text - style={styles.menuText} - onPress={() => setEdit(null)} - > - Back - </Text> - <Text - style={styles.menuText} - onPress={saveNote} - > - Save - </Text> - </> - ) : ( - <> - <Text - style={styles.menuText} - onPress={() => setEdit({})} - > - New Note - </Text> - <Text - style={styles.menuText} - > - Sort - </Text> - <Text - style={styles.menuText} - onPress={() => confirmLogout({ logout, email: session.email })} - > - {session.email} - </Text> - </> - ) - } - </View> - ) -} + </View> +) const styles = StyleSheet.create({ menu: { |