@@ -6,14 +6,13 @@ import { isEditOrPreviewMode } from "../helpers/urlHelper";
66
77type CustomString = string | number | readonly string [ ] | undefined
88
9- function SearchButton ( ) : JSX . Element {
10- const ARTIST = "Artist"
9+ function SearchButton ( { filterValue} : any ) : JSX . Element {
1110 const singleKeyUrl = process . env . REACT_APP_CONTENT_GRAPH_GATEWAY_URL as string
11+ const ARTIST = "Artist"
1212 const [ searchParams ] = useSearchParams ( )
1313 const [ token , setToken ] = useState ( "" )
1414 const [ isShown , setIsShown ] = useState ( false )
1515 const [ searchValue , setSearchValue ] = useState < CustomString > ( searchParams . get ( "q" ) ?. toString ( ) ?? "" )
16- const [ filterValue ] = useState < CustomString > ( searchParams . get ( "f" ) ?. toString ( ) ?? ARTIST )
1716 const [ orderBy ] = useState ( "ASC" )
1817 let autocompleteData : ArtistAutocompleteQuery | undefined = undefined
1918
@@ -24,7 +23,7 @@ function SearchButton(): JSX.Element {
2423
2524 function search ( event : any , action : string ) {
2625 if ( ( action == "keypress" && event . charCode === 13 ) || action == "buttonclick" ) {
27- window . location . href = `${ window . location . origin } /search?q=${ searchValue } &f=${ filterValue } `
26+ window . location . href = `${ window . location . origin } /search?q=${ searchValue } &f=${ filterValue ?? ARTIST } `
2827 }
2928 }
3029
@@ -35,7 +34,7 @@ function SearchButton(): JSX.Element {
3534
3635 function onAutoClick ( event : any ) {
3736 setSearchValue ( event . target . textContent ) ;
38- window . location . href = `${ window . location . origin } /search?q=${ event . target . textContent } `
37+ window . location . href = `${ window . location . origin } /search?q=${ event . target . textContent } &f= ${ filterValue ?? ARTIST } `
3938 }
4039
4140 return (
@@ -59,16 +58,16 @@ function SearchButton(): JSX.Element {
5958 </ a >
6059 < div className = "autocomplete-block" style = { isShown ? { display : "inherit" } : { display : "none" } } >
6160 {
62- autocompleteData ?. ArtistDetailsPage ?. autocomplete ?. ArtistName ?. map ( ( name ) => {
61+ autocompleteData ?. ArtistDetailsPage ?. autocomplete ?. ArtistName ?. map ( ( name , idx ) => {
6362 return (
64- < div key = { name } onClick = { ( event ) => onAutoClick ( event ) } > { name } </ div >
63+ < div key = { idx } onClick = { ( event ) => onAutoClick ( event ) } > { name } </ div >
6564 )
6665 } )
6766 }
6867 {
69- autocompleteData ?. ArtistDetailsPage ?. autocomplete ?. StageName ?. map ( ( name ) => {
68+ autocompleteData ?. ArtistDetailsPage ?. autocomplete ?. StageName ?. map ( ( name , idx ) => {
7069 return (
71- < div key = { name } onClick = { ( event ) => onAutoClick ( event ) } > { name } </ div >
70+ < div key = { idx } onClick = { ( event ) => onAutoClick ( event ) } > { name } </ div >
7271 )
7372 } )
7473 }
0 commit comments