Procházet zdrojové kódy

Merge branch 'country-filter-fix' of Viktoriia/nomadmania-app into dev

Viktoriia před 1 rokem
rodič
revize
2be29b67ed

+ 13 - 6
src/screens/InAppScreens/MapScreen/UsersListScreen/index.tsx

@@ -173,11 +173,16 @@ const UsersListScreen: FC<Props> = ({ navigation, route }) => {
   };
 
   const convertData = (data: { [key: string]: { country: string; flag: string } }) => {
-    return Object.entries(data).map(([key, value]) => ({
-      two: key,
-      name: value.country,
-      flag: value.flag
-    }));
+    let formatedCountries = [{ two: 'all', name: 'ALL', flag: '' }];
+    formatedCountries.push(
+      ...Object.entries(data).map(([key, value]) => ({
+        two: key,
+        name: value.country,
+        flag: value.flag
+      }))
+    );
+
+    return formatedCountries;
   };
 
   const handleEndReached = useCallback(() => {
@@ -258,11 +263,13 @@ const UsersListScreen: FC<Props> = ({ navigation, route }) => {
           setFilter({
             age: filterAge?.value ? +filterAge?.value : undefined,
             ranking: filterRanking?.name,
-            country: filterCountry?.two
+            country:
+              filterCountry?.two && filterCountry?.two !== 'all' ? filterCountry?.two : undefined
           });
           setModalVisible(false);
         }}
         countriesData={masterCountries}
+        isCountryHidden={isFromHere}
       />
     </PageWrapper>
   );

+ 28 - 24
src/screens/InAppScreens/TravellersScreen/Components/FilterModal.tsx

@@ -26,7 +26,8 @@ export const FilterModal: FC<ModalProps> = ({
   isModalVisible,
   setModalVisible,
   countriesData,
-  applyFilter
+  applyFilter,
+  isCountryHidden
 }) => {
   const netInfo = useConnection();
   const [filterAge, setFilterAge] = useState<filterAgeType>(null);
@@ -35,8 +36,8 @@ export const FilterModal: FC<ModalProps> = ({
 
   return (
     <Modal isVisible={isModalVisible}>
-      <View style={{ height: 270, backgroundColor: 'white', borderRadius: 15 }}>
-        <View style={{ marginLeft: '5%', marginRight: '5%', marginTop: '5%' }}>
+      <View style={{ backgroundColor: 'white', borderRadius: 15 }}>
+        <View style={{ marginLeft: '5%', marginRight: '5%', marginTop: '5%', marginBottom: '10%' }}>
           <View style={{ alignSelf: 'flex-end' }}>
             <TouchableOpacity onPress={() => setModalVisible(!isModalVisible)}>
               <CloseIcon />
@@ -44,27 +45,30 @@ export const FilterModal: FC<ModalProps> = ({
           </View>
           <View style={{ display: 'flex', alignItems: 'center' }}>
             <Text style={{ color: Colors.DARK_BLUE, fontSize: 20, fontWeight: '700' }}>Filter</Text>
-            <Dropdown
-              style={[ModalStyles.dropdown, { width: '100%', marginTop: 20 }]}
-              placeholderStyle={ModalStyles.placeholderStyle}
-              selectedTextStyle={ModalStyles.selectedTextStyle}
-              containerStyle={ModalStyles.dropdownContent}
-              data={countriesData}
-              disable={!netInfo?.isInternetReachable}
-              labelField="name"
-              valueField="two"
-              value={filterCountry?.two}
-              placeholder="Country"
-              onChange={(item) => {
-                setFilterCountry(item);
-              }}
-              search={true}
-              searchPlaceholder="Search"
-              autoScroll={false}
-              inputSearchStyle={ModalStyles.search}
-              flatListProps={{ initialNumToRender: 50, maxToRenderPerBatch: 10 }}
-            />
-            <View style={ModalStyles.ageAndRankingWrapper}>
+            {!isCountryHidden && (
+              <Dropdown
+                style={[ModalStyles.dropdown, { width: '100%', marginTop: 20 }]}
+                placeholderStyle={ModalStyles.placeholderStyle}
+                selectedTextStyle={ModalStyles.selectedTextStyle}
+                containerStyle={ModalStyles.dropdownContent}
+                data={countriesData}
+                disable={!netInfo?.isInternetReachable}
+                labelField="name"
+                valueField="two"
+                value={filterCountry?.two}
+                placeholder="Country"
+                onChange={(item) => {
+                  setFilterCountry(item);
+                }}
+                search={true}
+                searchPlaceholder="Search"
+                autoScroll={false}
+                inputSearchStyle={ModalStyles.search}
+                flatListProps={{ initialNumToRender: 50, maxToRenderPerBatch: 10 }}
+              />
+            )}
+
+            <View style={[ModalStyles.ageAndRankingWrapper, isCountryHidden ? {marginTop: 20} : {}]}>
               <Dropdown
                 style={ModalStyles.dropdown}
                 placeholderStyle={ModalStyles.placeholderStyle}

+ 1 - 0
src/screens/InAppScreens/TravellersScreen/utils/types.ts

@@ -20,6 +20,7 @@ export type ModalProps = {
     filterCountry: filterCountryType
   ) => void;
   countriesData: { two: string; name: string }[];
+  isCountryHidden?: boolean;
 };
 
 export type FilterButtonProps = {