@@ -74,6 +74,22 @@ const SearchBar = ({
74
74
}
75
75
} , [ router . isReady , router . query . searchTerms ] ) ; // useEffect is called every time the query changes
76
76
77
+ const searchBarHints = [
78
+ 'ex. GOVT 2306, Sara Johnson' ,
79
+ 'ex. CS 1200, CS 2337' ,
80
+ 'ex. MATH 2418' ,
81
+ 'ex. John Cole, Jason Smith' ,
82
+ ] ;
83
+ const [ searchBarHintIndex , setSearchBarHintIndex ] = useState < number > ( 1 ) ;
84
+
85
+ useEffect ( ( ) => {
86
+ const interval = setInterval ( ( ) => {
87
+ setSearchBarHintIndex ( Math . floor ( Math . random ( ) * 4 ) ) ;
88
+ } , 7000 ) ;
89
+
90
+ return ( ) => clearInterval ( interval ) ; // Cleanup when component unmounts
91
+ } , [ ] ) ; // run on mount
92
+
77
93
// updateValue -> onSelect_internal -> updateQueries - clicking enter on an autocomplete suggestion in topMenu Searchbar
78
94
// updateValue -> onSelect_internal -> onSelect (custom function) - clicking enter on an autocomplete suggestion in home page SearchBar
79
95
// params.inputProps.onKeyDown -> handleKeyDown -> onSelect_internal -> updateQueries/onSelect - clicking enter in the SearchBar
@@ -263,7 +279,7 @@ const SearchBar = ({
263
279
{ ...params }
264
280
variant = "outlined"
265
281
className = { input_className }
266
- placeholder = "ex. GOVT 2306 Sara Johnson"
282
+ placeholder = { searchBarHints [ searchBarHintIndex ] }
267
283
//eslint-disable-next-line jsx-a11y/no-autofocus
268
284
autoFocus = { autoFocus }
269
285
/>
0 commit comments