forked from adrianhajdin/uber
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOAuth.tsx
More file actions
49 lines (41 loc) · 1.38 KB
/
OAuth.tsx
File metadata and controls
49 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { useOAuth } from "@clerk/clerk-expo";
import { router } from "expo-router";
import { Alert, Image, Text, View } from "react-native";
import CustomButton from "@/components/CustomButton";
import { icons } from "@/constants";
import { googleOAuth } from "@/lib/auth";
const OAuth = () => {
const { startOAuthFlow } = useOAuth({ strategy: "oauth_google" });
const handleGoogleSignIn = async () => {
const result = await googleOAuth(startOAuthFlow);
if (result.code === "session_exists") {
Alert.alert("Success", "Session exists. Redirecting to home screen.");
router.replace("/(root)/(tabs)/home");
}
Alert.alert(result.success ? "Success" : "Error", result.message);
};
return (
<View>
<View className="flex flex-row justify-center items-center mt-4 gap-x-3">
<View className="flex-1 h-[1px] bg-general-100" />
<Text className="text-lg">Or</Text>
<View className="flex-1 h-[1px] bg-general-100" />
</View>
<CustomButton
title="Log In with Google"
className="mt-5 w-full shadow-none"
IconLeft={() => (
<Image
source={icons.google}
resizeMode="contain"
className="w-5 h-5 mx-2"
/>
)}
bgVariant="outline"
textVariant="primary"
onPress={handleGoogleSignIn}
/>
</View>
);
};
export default OAuth;