Commit ebac59c4 authored by Florent Chehab's avatar Florent Chehab

Search => filter for coherence

parent 9e91cba3
Pipeline #26891 passed with stages
in 2 minutes and 28 seconds
export const SAVE_MAIN_MAP_POSITION = 'SAVE_MAIN_MAP_POSITION';
export const SAVE_SELECTED_UNIVERSITIES = 'SAVE_SELECTED_UNIVERSITIES';
export const SAVE_SEARCH_CONFIG = 'SAVE_SEARCH_CONFIG';
export const SAVE_FILTER_CONFIG = 'SAVE_FILTER_CONFIG';
import {
SAVE_SELECTED_UNIVERSITIES,
SAVE_FILTER_CONFIG
} from "./action-types";
export function saveSelectedUniversities(new_selection) {
return {
type: SAVE_SELECTED_UNIVERSITIES,
new_selection
};
}
export function saveFilterConfig(config) {
return {
type: SAVE_FILTER_CONFIG,
config
};
}
import {
SAVE_SELECTED_UNIVERSITIES,
SAVE_SEARCH_CONFIG
SAVE_FILTER_CONFIG
} from "./action-types";
......@@ -12,9 +12,9 @@ export function saveSelectedUniversities(new_selection) {
};
}
export function saveSearchConfig(config) {
export function saveFilterConfig(config) {
return {
type: SAVE_SEARCH_CONFIG,
type: SAVE_FILTER_CONFIG,
config
};
}
......@@ -33,7 +33,7 @@ import {
import PageMap from './pages/PageMap';
import PageHome from './pages/PageHome';
import PageSearch from './pages/PageSearch';
import PageFilter from './pages/PageFilter';
const drawerWidth = 240;
......@@ -159,7 +159,7 @@ class App extends MyComponent {
<Route path="/app/" exact={true} component={PageHome} />
<Route path="/app/map" component={PageMap} />
<Route path="/app/search" component={PageSearch} />
<Route path="/app/filter" component={PageFilter} />
</main>
</div>
......
......@@ -82,9 +82,9 @@ class DownshiftMultiple extends React.Component {
const { options } = this.props;
const { selectedItems } = this.state;
let possible = _.difference(options, selectedItems);
const search = fuzzysort.go(value, possible, { limit: 5, key: 'label' });
if (search.length > 0){
return _.map(search, (item) => item.obj)
const filter = fuzzysort.go(value, possible, { limit: 5, key: 'label' });
if (filter.length > 0){
return _.map(filter, (item) => item.obj)
} else {
return possible.slice(0,4)
}
......
......@@ -4,7 +4,7 @@ import DownshiftMultiple from './DownshiftMultiple';
import MyComponent from '../MyComponent'
import { connect } from "react-redux";
import _ from 'underscore';
import { saveSelectedUniversities, saveSearchConfig } from '../../actions/search';
import { saveSelectedUniversities, saveFilterConfig } from '../../actions/filter';
import {
universitiesFetchData,
......@@ -13,7 +13,7 @@ import {
countriesFetchData
} from '../../generated/actions';
class Search extends MyComponent {
class Filter extends MyComponent {
joinCampus(campus) {
const { universities, countries, cities } = this.getAllFetchedData();
......@@ -91,7 +91,7 @@ const mapStateToProps = (state) => {
mainCampuses: state.mainCampuses,
cities: state.cities,
countries: state.countries,
contriesFilterConfig: state.app.search.contriesFilter
contriesFilterConfig: state.app.filter.contriesFilter
};
};
......@@ -104,9 +104,9 @@ const mapDispatchToProps = (dispatch) => {
countries: () => dispatch(countriesFetchData())
},
saveSelection: (selectedUniversities) => dispatch(saveSelectedUniversities(selectedUniversities)),
saveConfig: (config) => dispatch(saveSearchConfig(config))
saveConfig: (config) => dispatch(saveFilterConfig(config))
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Search);
export default connect(mapStateToProps, mapDispatchToProps)(Filter);
......@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography';
import Search from '../search/Search';
import Filter from '../filter/Filter';
import Paper from '@material-ui/core/Paper';
const styles = theme => ({
......@@ -20,14 +20,14 @@ class PageMap extends React.Component {
<Grid container spacing={24}>
<Grid item xs={11}>
<Typography variant="display1" gutterBottom>
Recherche
Filtrer
</Typography>
</Grid>
{/* <Grid item xs={1}>
<UnivMapReloadButton />
</Grid> */}
</Grid>
<Search />
<Filter />
</Paper>
);
}
......
......@@ -9,6 +9,7 @@ import PeopleIcon from '@material-ui/icons/People';
import BarChartIcon from '@material-ui/icons/BarChart';
import HomeIcon from '@material-ui/icons/Home';
import SearchIcon from '@material-ui/icons/Search';
import FilterIcon from '@material-ui/icons/FilterList';
import AssignmentIcon from '@material-ui/icons/Assignment';
import { NavLink } from 'react-router-dom'
......@@ -24,6 +25,15 @@ export const mainListItems = (
</ListItem>
</NavLink>
<NavLink to={'/app/search/'}>
<ListItem button>
<ListItemIcon>
<SearchIcon />
</ListItemIcon>
<ListItemText primary="Rechercher" />
</ListItem>
</NavLink>
<NavLink to={'/app/map/'}>
<ListItem button>
<ListItemIcon>
......@@ -33,16 +43,15 @@ export const mainListItems = (
</ListItem>
</NavLink>
<NavLink to={'/app/search/'}>
<NavLink to={'/app/filter/'}>
<ListItem button>
<ListItemIcon>
<SearchIcon />
<FilterIcon />
</ListItemIcon>
<ListItemText primary="Recherche" />
<ListItemText primary="Filtrer" />
</ListItem>
</NavLink>
<ListItem button>
<ListItemIcon>
<LocationCityIcon />
......
import { SAVE_SELECTED_UNIVERSITIES, SAVE_SEARCH_CONFIG } from '../actions/action-types'
import { SAVE_SELECTED_UNIVERSITIES, SAVE_FILTER_CONFIG } from '../actions/action-types'
export function saveSelectedUniversities(state = [], action) {
switch (action.type) {
......@@ -12,9 +12,9 @@ export function saveSelectedUniversities(state = [], action) {
}
}
export function saveSearchConfig(state = { contriesFilter: { selectedItems: [], inputValue: '' } }, action) {
export function saveFilterConfig(state = { contriesFilter: { selectedItems: [], inputValue: '' } }, action) {
switch (action.type) {
case SAVE_SEARCH_CONFIG:
case SAVE_FILTER_CONFIG:
return Object.assign(state, action.config)
default:
......
......@@ -11,13 +11,13 @@ import {
} from '../generated/combinedReducers';
import { saveMainMapPosition } from './map';
import { saveSelectedUniversities } from './search';
import { saveSearchConfig } from './search';
import { saveSelectedUniversities } from './filter';
import { saveFilterConfig } from './filter';
const appReducers = combineReducers({
mainMap: saveMainMapPosition,
selectedUniversities: saveSelectedUniversities,
search: saveSearchConfig,
filter: saveFilterConfig,
})
const rootReducer = combineReducers({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment