Skip to content

Commit

Permalink
more renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
christophertorres1 committed Dec 4, 2024
1 parent 51021e2 commit a4a2251
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 35 deletions.
12 changes: 3 additions & 9 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import { DefaultTheme, NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import AllTreesScreen from '@/screens/all_trees/AllTreesScreen';
import AvailableTreesScreen from '@/screens/available_trees/AvailableTreesScreen';
import LoginScreen from '@/screens/Login/Login';
import TreeSearchScreen from '@/screens/TreeSearch/TreeSearch';
import { LoginStackParamList } from '@/types/navigation';

const Stack = createNativeStackNavigator<LoginStackParamList>();
Expand All @@ -19,13 +18,8 @@ export default function App() {
options={{ headerShown: false }}
/>
<Stack.Screen
name="AvailableTrees"
component={AvailableTreesScreen}
options={{ headerShown: false }}
/>
<Stack.Screen
name="AllTrees"
component={AllTreesScreen}
name="TreeSearch"
component={TreeSearchScreen}
options={{ headerShown: false }}
/>
</Stack.Navigator>
Expand Down
34 changes: 17 additions & 17 deletions src/components/GoogleSignInButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ export default function GoogleSignInButton({ navigation, route }: LoginProps) {
console.log(userInfo);

useEffect(() => {
handleSignInWithGoogle();
}, [response]);

async function handleSignInWithGoogle() {
try {
const userJSON = await AsyncStorage.getItem('@user');
if (userJSON) {
setUserInfo(JSON.parse(userJSON));
} else if (
response?.type === 'success' &&
response.authentication?.accessToken
) {
getUserInfo(response.authentication.accessToken);
async function handleSignInWithGoogle() {
try {
const userJSON = await AsyncStorage.getItem('@user');
if (userJSON) {
setUserInfo(JSON.parse(userJSON));
} else if (
response?.type === 'success' &&
response.authentication?.accessToken
) {
getUserInfo(response.authentication.accessToken);
}
} catch (error) {
console.error('Error retrieving user data from AsyncStorage:', error);
}
} catch (error) {
console.error('Error retrieving user data from AsyncStorage:', error);
}
}

handleSignInWithGoogle();
}, [response]);

const getUserInfo = async (token: string) => {
if (!token) return;
Expand All @@ -65,7 +65,7 @@ export default function GoogleSignInButton({ navigation, route }: LoginProps) {
<TouchableOpacity
onPress={() => {
promptAsync();
navigation.navigate('AllTrees');
navigation.navigate('TreeSearch');
}}
>
<Text style={styles.adminLoginLinkText}>Login Here</Text>
Expand Down
9 changes: 6 additions & 3 deletions src/screens/TreeInfo/TreeInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import { NativeStackScreenProps } from '@react-navigation/native-stack';
import { RootStackParamList } from '@/types/navigation';
import styles from './styles';

type TreeInfoPageProps = NativeStackScreenProps<
type TreeInfoScreenProps = NativeStackScreenProps<
RootStackParamList,
'TreeInfoPage'
'TreeInfoScreen'
>;

export default function TreeInfo({ route, navigation }: TreeInfoPageProps) {
export default function TreeInfoScreen({
route,
navigation,
}: TreeInfoScreenProps) {
return (
<View style={styles.container}>
<Text>Tree Id:</Text>
Expand Down
6 changes: 3 additions & 3 deletions src/screens/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import GoogleSignInButton from '@/components/GoogleSignInButton';
import { LoginStackParamList } from '@/types/navigation';
import { styles } from './styles';

type LoginProps = NativeStackScreenProps<LoginStackParamList, 'Login'>;
type LoginScreenProps = NativeStackScreenProps<LoginStackParamList, 'Login'>;

export default function LoginScreen({ navigation, route }: LoginProps) {
export default function LoginScreen({ navigation, route }: LoginScreenProps) {
return (
<View style={styles.loginContainer}>
<Text style={styles.loginText}>I am a...</Text>
Expand All @@ -17,7 +17,7 @@ export default function LoginScreen({ navigation, route }: LoginProps) {

<TouchableOpacity
style={styles.button}
onPress={() => navigation.navigate('AvailableTrees')}
onPress={() => navigation.navigate('TreeSearch')}
>
<Text style={styles.buttonText}>Guest</Text>
</TouchableOpacity>
Expand Down
5 changes: 2 additions & 3 deletions src/types/navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export type LoginStackParamList = {
Login: undefined;
AvailableTrees: undefined;
AllTrees: undefined;
TreeSearch: undefined;
};

export type RootStackParamList = {
Home: undefined;
Scanner: undefined;
TreeInfoPage: { treeId: string };
TreeInfoScreen: { treeId: string };
};

0 comments on commit a4a2251

Please sign in to comment.