22import Container from '@material-ui/core/Container' ;
33import Grid from '@material-ui/core/Grid' ;
44import Typography from '@material-ui/core/Typography' ;
5+ import _isNil from 'ramda/src/isNil' ;
56import React , { useState } from 'react' ;
67import { useDispatch , useSelector } from 'react-redux' ;
78import { useHistory } from 'react-router-dom' ;
@@ -11,69 +12,6 @@ import { State } from '../../redux/rootReducer';
1112import Course from '../../types/items/Course' ;
1213import User from '../../types/items/User' ;
1314import useStyles from './styles' ;
14-
15- const initialResults = [
16- { label : 'Afghanistan' } ,
17- { label : 'Aland Islands' } ,
18- { label : 'Albania' } ,
19- { label : 'Algeria' } ,
20- { label : 'American Samoa' } ,
21- { label : 'Andorra' } ,
22- { label : 'Angola' } ,
23- { label : 'Anguilla' } ,
24- { label : 'Antarctica' } ,
25- { label : 'Antigua and Barbuda' } ,
26- { label : 'Argentina' } ,
27- { label : 'Armenia' } ,
28- { label : 'Aruba' } ,
29- { label : 'Australia' } ,
30- { label : 'Austria' } ,
31- { label : 'Azerbaijan' } ,
32- { label : 'Bahamas' } ,
33- { label : 'Bahrain' } ,
34- { label : 'Bangladesh' } ,
35- { label : 'Barbados' } ,
36- { label : 'Belarus' } ,
37- { label : 'Belgium' } ,
38- { label : 'Belize' } ,
39- { label : 'Benin' } ,
40- { label : 'Bermuda' } ,
41- { label : 'Bhutan' } ,
42- { label : 'Bolivia, Plurinational State of' } ,
43- { label : 'Bonaire, Sint Eustatius and Saba' } ,
44- { label : 'Bosnia and Herzegovina' } ,
45- { label : 'Botswana' } ,
46- { label : 'Bouvet Island' } ,
47- { label : 'Brazil' } ,
48- { label : 'British Indian Ocean Territory' } ,
49- { label : 'Brunei Darussalam' } ,
50- ] ;
51-
52- function getSuggestions (
53- value : string | null ,
54- { showEmpty } : { showEmpty : boolean } = { showEmpty : false }
55- ) {
56- const inputValue = String ( value )
57- . trim ( )
58- . toLowerCase ( ) ;
59- const inputLength = inputValue . length ;
60- let count = 0 ;
61-
62- return inputLength === 0 && ! showEmpty
63- ? [ ]
64- : initialResults . filter ( suggestion => {
65- const keep =
66- count < 5 &&
67- suggestion . label . slice ( 0 , inputLength ) . toLowerCase ( ) === inputValue ;
68-
69- if ( keep ) {
70- count += 1 ;
71- }
72-
73- return keep ;
74- } ) ;
75- }
76-
7715export interface GetFormattedResultsOptions {
7816 readonly courses : Course [ ] ;
7917 readonly users : User [ ] ;
@@ -114,7 +52,7 @@ const HeroContent = () => {
11452
11553 const handleChange = ( changes : any ) => {
11654 // TODO: abstract this operations
117- if ( changes . hasOwnProperty ( 'selectedItem' ) ) {
55+ if ( changes . hasOwnProperty ( 'selectedItem' ) && ! _isNil ( changes . selectedItem ) ) {
11856 setValue ( changes . selectedItem ) ;
11957
12058 const item : any = results . filter (
0 commit comments