diff --git a/frontend/components/PopularUser.tsx b/frontend/components/PopularUser.tsx index 87550188..89f617bb 100644 --- a/frontend/components/PopularUser.tsx +++ b/frontend/components/PopularUser.tsx @@ -1,5 +1,4 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-expect-error import React from 'react'; import {Image, StyleSheet, Text, View, TouchableOpacity} from 'react-native'; import { Leader } from '../types/types'; diff --git a/frontend/components/ProfilePerformance.tsx b/frontend/components/ProfilePerformance.tsx index 9af473f9..6cb6cf96 100644 --- a/frontend/components/ProfilePerformance.tsx +++ b/frontend/components/ProfilePerformance.tsx @@ -1,5 +1,5 @@ -import { View, Text, Pressable } from 'react-native' -import React from 'react' +import { View, Text, Pressable } from 'react-native'; +import React from 'react'; import { useNavigation } from '@react-navigation/native'; import { ProfileNavigationProp } from '../types/navigationTypes'; import { useSession } from '@clerk/clerk-expo'; @@ -10,15 +10,16 @@ interface ProfilePerformanceProps { user: User; } -const ProfilePerformance = ( - { portfolioValue }: ProfilePerformanceProps, - { user }: ProfilePerformanceProps, -) => { +const ProfilePerformance = ({ + portfolioValue, + user, +}: ProfilePerformanceProps) => { const { session } = useSession(); const navigator = useNavigation(); const handleCopyTrades = () => { navigator.navigate('CopyTrades', { user: user }); }; + console.log(user); return ( @@ -28,15 +29,15 @@ const ProfilePerformance = ( className={`text-2xl ${portfolioValue >= 0 ? 'text-[#02AD98]' : 'text-[#FF2B51]'}`}> {portfolioValue} % - {session?.user.username === user?.username ? null : ( - - Copy Trades - - )} + {session?.user.username !== user?.username ? ( + + Copy Trades + + ) : null} YTD Performance ); }; -export default ProfilePerformance \ No newline at end of file +export default ProfilePerformance; diff --git a/frontend/pages/Copy/CopyTradesPage.tsx b/frontend/pages/Copy/CopyTradesPage.tsx index 6f707b40..aa67bbbb 100644 --- a/frontend/pages/Copy/CopyTradesPage.tsx +++ b/frontend/pages/Copy/CopyTradesPage.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import { View, Text, @@ -9,15 +9,15 @@ import { Alert, Image, } from 'react-native'; -import { useNavigation } from '@react-navigation/native'; +import { useNavigation, useRoute } from '@react-navigation/native'; import { useSession } from '@clerk/clerk-expo'; import { ProfileNavigationProp, AuthNavigationProp, } from '../../types/navigationTypes'; -import { User } from '../../types/types'; -import { getUserById } from '../../services/users'; -import { copyTrades } from '../../services/copy'; +import { CopyRouteParams } from '../../types/types'; +// import { User } from '../../types/types'; +// import { copyTrades } from '../../services/copy'; function CopyTradesPage() { const { session } = useSession(); @@ -28,20 +28,17 @@ function CopyTradesPage() { const [stopLossAmount, setStopLossAmount] = useState('500'); const [tradeAuthorizationRequired, setTradeAuthorizationRequired] = useState(false); - const [user, setUser] = useState(null); + const route = useRoute(); + const user = (route.params as CopyRouteParams)?.user; const handleSubmit = async () => { - if (!user) { - Alert.alert('Error', "User doesn't exist"); - return; - } if (!session?.user.id) { authNavigation.navigate('Login'); return; } try { - await copyTrades(session?.user.id as string, user.username); + // await copyTrades(session?.user.id as string, user.username); } catch (error) { Alert.alert('Error', 'Failed to copy trades'); return; @@ -51,24 +48,13 @@ function CopyTradesPage() { navigation.navigate('Profile'); }; - useEffect(() => { - const fetchUser = async () => { - try { - const user = await getUserById(''); - setUser(user); - } catch (error) { - console.error('Error fetching user:', error); - } - }; - - fetchUser(); - }, []); - return ( - @kevinkevindaliri + + @{user?.username || 'kevinkevindaliri'} + navigation.navigate('Profile')}> × diff --git a/frontend/pages/Profile.tsx b/frontend/pages/Profile.tsx index 5280c3ca..1da798cb 100644 --- a/frontend/pages/Profile.tsx +++ b/frontend/pages/Profile.tsx @@ -1,6 +1,6 @@ import { useNavigation, useRoute } from '@react-navigation/native'; import React, { useEffect, useState } from 'react'; -import { FlatList, Pressable, ScrollView, View } from 'react-native'; +import { FlatList, Pressable, ScrollView, Text, View } from 'react-native'; import { useSession } from '@clerk/clerk-expo'; import ProfileBanner from '../components/ProfileBanner'; import SubTabButton from '../components/SubTabButton'; @@ -64,49 +64,63 @@ const Profile = () => { }, []); return ( - - - + + + - - + + {!isFollowerProfile && ( - + )} { + onMomentumScrollEnd={event => { const offset = event.nativeEvent.contentOffset.x; const page = Math.round(offset / 375); console.log(`Page number: ${page}`); setPageNumber(page); - }} - > - {pageNumber === 0 && ( - - - - - )} - + }}> + {pageNumber === 0 && ( + + + + + )} + {pageNumber == 1 && ( item.id.toString()} + keyExtractor={item => item.id.toString()} renderItem={({ item }) => ( - )} /> + icon={item.icon} + /> + )} + /> )} - + {user.username} ); diff --git a/frontend/router/BottomNavBar.tsx b/frontend/router/BottomNavBar.tsx index b1e037e3..8da9f24c 100644 --- a/frontend/router/BottomNavBar.tsx +++ b/frontend/router/BottomNavBar.tsx @@ -73,13 +73,4 @@ const BottomNavBar = () => { ); }; - -// const ProfileStack = createStackNavigator(); -// const ProfileStackNavigator = () => ( -// -// -// -// -// ); - export default BottomNavBar; \ No newline at end of file diff --git a/frontend/types/types.d.ts b/frontend/types/types.d.ts index f65a9c10..eb04465b 100644 --- a/frontend/types/types.d.ts +++ b/frontend/types/types.d.ts @@ -72,6 +72,10 @@ export interface ProfileRouteParams { user: User; } +export interface CopyRouteParams { + user: User; +} + export interface FollowerRouteParams { users: User[], label: string