diff --git a/app/(root)/(tabs)/rides.tsx b/app/(root)/(tabs)/rides.tsx index af2a22b..4347d40 100644 --- a/app/(root)/(tabs)/rides.tsx +++ b/app/(root)/(tabs)/rides.tsx @@ -1,10 +1,51 @@ -import { Text } from "react-native"; +import { useUser } from "@clerk/clerk-expo"; +import { ActivityIndicator, FlatList, Image, Text, View } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; +import { RideCard } from "@/components/ride-card"; +import { images } from "@/constants"; +import { useFetch } from "@/lib/fetch"; +import type { Ride } from "@/types/type"; + const Rides = () => { + const { user } = useUser(); + const { data: recentRides, loading } = useFetch( + `/(api)/ride/${user?.id}`, + ); + return ( - Rides + } + className="px-5" + keyboardShouldPersistTaps="handled" + contentContainerStyle={{ + paddingBottom: 100, + }} + ListEmptyComponent={() => ( + + {!loading ? ( + <> + No recent rides found + No recent rides found. + + ) : ( + + )} + + )} + ListHeaderComponent={() => ( + <> + All rides + + )} + /> ); }; diff --git a/app/_layout.tsx b/app/_layout.tsx index 9cedad9..337a8e9 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -4,6 +4,7 @@ import { Stack } from "expo-router"; import * as SplashScreen from "expo-splash-screen"; import { StatusBar } from "expo-status-bar"; import { useEffect } from "react"; +import { LogBox } from "react-native"; import "react-native-reanimated"; import { tokenCache } from "@/lib/auth"; @@ -11,6 +12,8 @@ import { tokenCache } from "@/lib/auth"; // Prevent the splash screen from auto-hiding before asset loading is complete. SplashScreen.preventAutoHideAsync(); +LogBox.ignoreAllLogs(); + const RootLayout = () => { const [loaded] = useFonts({ "Jakarta-Bold": require("../assets/fonts/PlusJakartaSans-Bold.ttf"), diff --git a/components/oauth.tsx b/components/oauth.tsx index a6bc887..5bd2df2 100644 --- a/components/oauth.tsx +++ b/components/oauth.tsx @@ -1,6 +1,6 @@ import { useOAuth } from "@clerk/clerk-expo"; import { useCallback } from "react"; -import { Alert, Image, Text, View } from "react-native"; +import { Image, Text, View } from "react-native"; import { icons } from "@/constants"; @@ -19,14 +19,9 @@ export const OAuth = ({ title }: OAuthProps) => { try { const result = await googleOAuth(startOAuthFlow); - if (result?.code === "session_exists") { + if (result?.code === "session_exists" || result?.code === "success") { router.replace("/(root)/(tabs)/home"); } - - Alert.alert( - result?.success ? "Success" : "Error", - result?.message || "You are Logged In!", - ); } catch (err) { console.error("OAuth error", err); } diff --git a/lib/auth.ts b/lib/auth.ts index 8f45769..ad6f49b 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -17,15 +17,13 @@ export const tokenCache = { async getToken(key: string) { try { const item = await SecureStore.getItemAsync(key); - if (item) { - console.log(`${key} was used 🔐 \n`); - } else { - console.log("No values stored under key: " + key); - } + return item; } catch (error) { console.error("GET_TOKEN_CACHE: ", error); + await SecureStore.deleteItemAsync(key); + return null; } },