@@ -4,7 +4,6 @@ import { jsx } from "@emotion/core";
44import { useSetClubs } from "../actions/action-hooks" ;
55import { useClubs } from "../selectors/selectors" ;
66import { getClubs } from "../services/club" ;
7- import ClubCard from "../components/club-card" ;
87import Club from "../components/club" ;
98import { getDistance } from "geolib" ;
109import { Select } from "../components/ui" ;
@@ -13,7 +12,7 @@ function Home() {
1312 const clubs = useClubs ( ) ;
1413 const setClubs = useSetClubs ( ) ;
1514 const [ position , setPosition ] = React . useState ( [ 0 , 0 ] ) ;
16- const [ selectedLocation , setSelectedLocation ] = React . useState ( ) ;
15+ const [ selectedLocation , setSelectedLocation ] = React . useState ( "" ) ;
1716 const [ sortType , setSortType ] = React . useState ( "location" ) ;
1817
1918 React . useEffect ( ( ) => {
@@ -42,12 +41,10 @@ function Home() {
4241 } , [ setPosition ] ) ;
4342
4443 function handleChangeLocation ( e ) {
45- console . log ( e . target . value ) ;
4644 setSelectedLocation ( e . target . value ) ;
4745 }
4846
4947 function handleChangeSortType ( e ) {
50- console . log ( e . target . value ) ;
5148 setSortType ( e . target . value ) ;
5249 }
5350
@@ -67,6 +64,14 @@ function Home() {
6764 }
6865 }
6966
67+ function filterBy ( club ) {
68+ if ( selectedLocation !== "" ) {
69+ return selectedLocation === club . district ;
70+ } else {
71+ return true ;
72+ }
73+ }
74+
7075 const styleSelectsContainer = {
7176 display : "flex" ,
7277 justifyContent : "space-between" ,
@@ -115,9 +120,9 @@ function Home() {
115120 distance = setDistance ( club , position ) ;
116121 }
117122 club . distance = distance ;
118- console . log ( club ) ;
119123 return club ;
120124 } )
125+ . filter ( filterBy )
121126 . sort ( sortBy )
122127 . map ( club => {
123128 return < Club key = { club . id } club = { club } /> ;
0 commit comments