import { useOAuth } from "@clerk/clerk-expo"; import { useCallback } from "react"; import { Alert, Image, Text, View } from "react-native"; import { icons } from "@/constants"; import { CustomButton } from "./custom-button"; import { googleOAuth } from "@/lib/auth"; import { router } from "expo-router"; type OAuthProps = { title: string; }; export const OAuth = ({ title }: OAuthProps) => { const { startOAuthFlow } = useOAuth({ strategy: "oauth_google" }); const handleGoogleOAuth = useCallback(async () => { try { const result = await googleOAuth(startOAuthFlow); if (result?.code === "session_exists") { router.replace("/(root)/(tabs)/home"); } Alert.alert( result?.success ? "Success" : "Error", result?.message || "You are Logged In!", ); } catch (err) { console.error("OAuth error", err); } }, [startOAuthFlow]); return ( Or ( Google logo )} bgVariant="outline" textVariant="primary" onPress={handleGoogleOAuth} /> ); };