Files
waseel/components/oauth.tsx
T
Krikorios 62dc5e9d53 Rebrand to Waseel, swap Stripe for Areeba, add phone-ready auth and DB seed
- Rename app: Waseel (name, slug, scheme waseel://, com.waseel.app ids, splash)
- Payments: replace Stripe with Areeba hosted checkout (create/verify API routes,
  lib/areeba.ts, WebBrowser-based payment flow)
- Maps: migrate address autocomplete to Places API (New), drop legacy library
- Web support: map stub for web (native maps are iOS/Android only)
- Auth: keep email + Google OAuth; fix OAuth redirect for Expo Go
- Add scripts/seed-db.mjs (schema + Lebanese driver seed)
- Pin Expo SDK 51 compatible package versions
2026-08-22 15:53:41 +03:00

62 lines
1.6 KiB
TypeScript

import { useOAuth } from "@clerk/clerk-expo";
import { router } from "expo-router";
import { useCallback } from "react";
import { Image, Text, View, Alert } from "react-native";
import { icons } from "@/constants";
import { googleOAuth } from "@/lib/auth";
import { CustomButton } from "./custom-button";
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" || result?.code === "success") {
router.replace("/(root)/(tabs)/home");
}
} catch (err: any) {
console.error("OAuth error", err);
Alert.alert(
"Google sign-in failed",
err?.errors?.[0]?.longMessage || err?.message || "Please try again.",
);
}
}, [startOAuthFlow]);
return (
<View>
<View className="flex flex-row justify-center items-center mt-4 gap-x-3">
<View className="flex-1 h-px bg-general-100" />
<Text className="text-lg">Or</Text>
<View className="flex-1 h-px bg-general-100" />
</View>
<CustomButton
title={title}
className="mt-5 w-full shadow-none"
iconLeft={() => (
<Image
source={icons.google}
alt="Google logo"
resizeMode="contain"
className="h-5 w-5 mx-2"
/>
)}
bgVariant="outline"
textVariant="primary"
onPress={handleGoogleOAuth}
/>
</View>
);
};