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}
                   />}