ソースを参照

Filter Logic Alteration

Savio Fernando 1 年間 前
コミット
d7920bda36
1 ファイル変更6 行追加5 行削除
  1. 6 5
      src/screens/Search/SearchPage.js

+ 6 - 5
src/screens/Search/SearchPage.js

@@ -159,6 +159,7 @@ const SearchPage = props => {
     getMenus()
       .then(res => {
         let filtersPayload = res.data.body.results
+        //Reduce Submenus into a object
         setFiltersData(prev => ({ ...prev, "Category": filtersPayload.map(item => item.heading.submenu.reduce((current, value) => ({ ...current, [value]: false }), {})) }))
         setFiltersData(prev => ({ ...prev, "Source": filtersPayload.map(item => item.heading.submenu.reduce((current, value) => ({ ...current, [value]: false }), {})) }))
         setFiltersData(prev => ({ ...prev, "Hash Tags": filtersPayload.map(item => item.heading.submenu.reduce((current, value) => ({ ...current, [value]: false }), {})) }))
@@ -239,17 +240,17 @@ const SearchPage = props => {
               {
                 // filtersData[currentFilter] 
                 Object.keys(filtersData).length <= 0 ? <LoadingScreen/> 
-                : Object.keys(filtersData[currentFilter]).map(item => 
-                  { console.log(item)
+                : Object.entries(filtersData[currentFilter]).map(item => 
+                  { 
                     return (<List.Item
                   style={styles.listItem}
                   titleStyle={styles.listItemText}
-                  title={item}
+                  title={item[0]}
 
                   right={props => <Checkbox  
-                      status={filtersData[currentFilter][item] === true ? 'checked' : 'unchecked'}
+                      status={filtersData[currentFilter][item[0]] === true ? 'checked' : 'unchecked'}
                       onPress={() => 
-                        setFiltersData({...filtersData,[currentFilter]: {...filtersData[currentFilter],[item]: !filtersData[currentFilter][item]}})}
+                        setFiltersData({...filtersData,[currentFilter]: {...filtersData[currentFilter],[item[0]]: !filtersData[currentFilter][item[0]]}})}
                         // setSelectedTopics({...filtersData,[item.heading.name]: !selectedTopics[item.heading.name]})}
                       color={colors().secondaryColor}
                   />}