瀏覽代碼

statistic navigation to user

Viktoriia 1 年之前
父節點
當前提交
644dcf1d92

+ 11 - 3
src/screens/InAppScreens/TravellersScreen/Components/StatisticRouter.tsx

@@ -21,15 +21,18 @@ import { getFontSize } from '../../../../utils';
 import { API_HOST } from '../../../../constants';
 
 import { ItemStyles } from './styles';
+import { TouchableOpacity } from 'react-native-gesture-handler';
+import { NAVIGATION_PAGES } from 'src/types';
 
 type Props = {
   blockIndex: number;
   item: ListType;
   ranking: any;
   idx: number;
+  navigation: any;
 };
 
-export const RenderItem: FC<Props> = ({ item, blockIndex, ranking, idx }) => {
+export const RenderItem: FC<Props> = ({ item, blockIndex, ranking, idx, navigation }) => {
   if (isType1(item) || isType4(item) || isType5(item)) {
     return (
       <>
@@ -138,14 +141,19 @@ export const RenderItem: FC<Props> = ({ item, blockIndex, ranking, idx }) => {
     );
   } else {
     return (
-      <>
+      <TouchableOpacity
+        onPress={() =>
+          item.user &&
+          navigation.navigate(NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId: item.user })
+        }
+      >
         <StatisticItem
           name={item.nation ? item.nation : `${item.first_name} ${item.last_name}`}
           flag={item.flag}
           cnt={item.score ? item.score : item.cnt}
           index={blockIndex}
         />
-      </>
+      </TouchableOpacity>
     );
   }
 };

+ 3 - 1
src/screens/InAppScreens/TravellersScreen/StatisticsListScreen/index.tsx

@@ -1,6 +1,6 @@
 import React, { useCallback, useEffect, useState } from 'react';
 import { FlatList, Text } from 'react-native';
-import { useFocusEffect } from '@react-navigation/native';
+import { useFocusEffect, useNavigation } from '@react-navigation/native';
 
 import { RenderItem } from '../Components/StatisticRouter';
 
@@ -14,6 +14,7 @@ const StatisticsListScreen = ({ route }: { route: any }) => {
   const title = route.params.title;
   const url1 = route.params.url1;
   const url2 = route.params.url2;
+  const navigation = useNavigation();
 
   const [isLoading, setIsLoading] = useState(true);
   const [statistic, setStatistic] = useState<StatisticType | null>(null);
@@ -89,6 +90,7 @@ const StatisticsListScreen = ({ route }: { route: any }) => {
                 blockIndex={blockIndex}
                 idx={index}
                 ranking={statistic?.ranking}
+                navigation={navigation}
               />
             );
           }}