Jelajahi Sumber

feat: disabling filtering

Oleksandr Honcharov 1 tahun lalu
induk
melakukan
4f546c6fb3

+ 1 - 37
src/database/statisticsService/index.ts

@@ -17,43 +17,7 @@ function loadData<T>(key: string): T | null {
 }
 
 function structureList(listData: Sublist[]) {
-  const structuredData: StructuredData = {};
-  const baseCategoryName = 'NOMADS STATISTICS';
-  const list = [];
-
-  listData.forEach((category) => {
-    const categoryName = category.name.split('<br/>')[0];
-
-    if (categoryName === baseCategoryName) {
-      if (!structuredData[baseCategoryName]) {
-        structuredData[baseCategoryName] = {
-          name: baseCategoryName,
-          sublists: []
-        };
-      }
-
-      const descriptor = category.name.split('<br/>')[1].replace(/<[^>]*>?/gm, '');
-
-      const sublist: Sublist | null =
-        structuredData[baseCategoryName].sublists?.find((el) => el.name === descriptor) || null;
-
-      if (!sublist) {
-        structuredData[baseCategoryName].sublists?.push({
-          name: descriptor,
-          list: category.list.map((item) => ({
-            name: item.name,
-            url1: item.url1,
-            url2: item.url2 || null
-          }))
-        });
-      }
-    } else {
-      list.push(category);
-    }
-  });
-
-  structuredData[baseCategoryName] && list.push(structuredData[baseCategoryName]);
-  saveData('list', list);
+  saveData('list', listData);
 }
 
 export async function fetchAndSaveStatistics(token: string) {

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

@@ -178,7 +178,12 @@ const StatisticsListScreen = ({ route }) => {
     } else
       return (
         <>
-          <Item name={item.nation} flag={item.flag} cnt={item.score} index={index} />
+          <Item
+            name={item.nation ? item.nation : `${item.first_name} ${item.last_name}`}
+            flag={item.flag}
+            cnt={item.score ? item.score : item.cnt}
+            index={index}
+          />
         </>
       );
   };

+ 35 - 20
src/screens/InAppScreens/TravellersScreen/StatisticsScreen/index.tsx

@@ -39,33 +39,47 @@ const StatisticsScreen = () => {
           <Header label={'Statistics'} />
           <View style={{ gap: 20 }}>
             {routes.map((route, i) => {
+              let name = route.title;
+              let subname: string = '';
+
+              if (route.title.startsWith('NOMADS STATISTICS')) {
+                name = route.title.replace(/<[^>]*>/g, '!');
+
+                const split = name.split('!');
+
+                name = split[0];
+                subname = split[2];
+              }
+
               return (
                 <View>
                   <TouchableOpacity
-                    onPress={() => {
-                      if (route.title === 'NOMADS STATISTICS')
-                        navigation.navigate(NAVIGATION_PAGES.NOMADS_STATISTICS, {
-                          ...route
-                        });
-                      else setIndex(index === i ? null : i);
-                    }}
+                    onPress={() => setIndex(index === i ? null : i)}
                     style={{
                       display: 'flex',
                       flexDirection: 'row',
-                      justifyContent: 'space-between'
+                      justifyContent: 'space-between',
+                      alignItems: 'center'
                     }}
                   >
-                    <Text
-                      style={[
-                        {
-                          fontSize: getFontSize(16),
-                          color: 'rgba(237, 147, 52, 1)',
-                          fontWeight: '700'
-                        }
-                      ]}
-                    >
-                      {route.title}
-                    </Text>
+                    <View>
+                      <Text
+                        style={[
+                          {
+                            fontSize: getFontSize(16),
+                            color: 'rgba(237, 147, 52, 1)',
+                            fontWeight: '700'
+                          }
+                        ]}
+                      >
+                        {route.title && name}
+                      </Text>
+                      {subname && (
+                        <Text style={{ color: Colors.DARK_BLUE, fontWeight: '700' }}>
+                          {subname}
+                        </Text>
+                      )}
+                    </View>
                     <View style={index === i ? { transform: 'rotate(180deg)' } : {}}>
                       <ArrowIcon height={18} width={18} stroke={'#B7C6CB'} />
                     </View>
@@ -79,7 +93,8 @@ const StatisticsScreen = () => {
                               navigation.navigate(NAVIGATION_PAGES.STATISTICS_LIST_DATA, {
                                 title: item.name,
                                 type: route.title,
-                                url1: item.url1
+                                url1: item.url1,
+                                url2: item.url2
                               })
                             }
                           >