-
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.
- Loading branch information
1 parent
a6b5a91
commit f11a4f6
Showing
8 changed files
with
338 additions
and
297 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
30 changes: 15 additions & 15 deletions
30
src/components/GoogleSignOutButton/GoogleSignOutButton.tsx
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 |
---|---|---|
@@ -1,39 +1,39 @@ | ||
import { TouchableOpacity, Text } from 'react-native'; | ||
import { Text, TouchableOpacity } from 'react-native'; | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
import { useAuth } from '@/context/AuthContext'; | ||
import { NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
import { CommonActions } from '@react-navigation/native'; | ||
import { NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
import { useAuth } from '@/context/AuthContext'; | ||
import { ContactStackParamList } from '@/types/navigation'; | ||
import { styles } from './styles'; | ||
|
||
type GoogleSignOutButtonProps = NativeStackScreenProps<ContactStackParamList, 'Contact'>; | ||
type GoogleSignOutButtonProps = NativeStackScreenProps< | ||
ContactStackParamList, | ||
'Contact' | ||
>; | ||
|
||
export default function GoogleSignOutButton({ navigation }: GoogleSignOutButtonProps) { | ||
const { setAuthenticated } = useAuth(); | ||
export default function GoogleSignOutButton({ | ||
navigation, | ||
}: GoogleSignOutButtonProps) { | ||
const { setAuthenticated } = useAuth(); | ||
|
||
const handleSignOut = async () => { | ||
try { | ||
await AsyncStorage.setItem('authenticated', 'false'); | ||
await setAuthenticated(false); | ||
await setAuthenticated(false); | ||
navigation.dispatch( | ||
CommonActions.reset({ | ||
index: 0, | ||
routes: [{ name: 'LoginStack' }], | ||
}) | ||
}), | ||
); | ||
} catch (error) { | ||
console.error('Error signing out:', error); | ||
} | ||
}; | ||
|
||
return ( | ||
<TouchableOpacity | ||
style={styles.button} | ||
onPress={handleSignOut} | ||
> | ||
<Text style={styles.buttonText}> | ||
Sign out | ||
</Text> | ||
<TouchableOpacity style={styles.button} onPress={handleSignOut}> | ||
<Text style={styles.buttonText}>Sign out</Text> | ||
</TouchableOpacity> | ||
); | ||
} |
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
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