3
3
import './SearchBar.scss' ;
4
4
5
5
import { useTranslations } from 'next-intl' ;
6
- import { useState , useRef , ChangeEvent , FormEvent } from 'react' ;
6
+ import { useContext , useState , useRef , ChangeEvent , FormEvent } from 'react' ;
7
7
import { FormControl , TextField } from '@mui/material' ;
8
8
import SearchIcon from '@mui/icons-material/Search' ;
9
9
import { fetchSellers } from '@/services/sellerApi' ;
10
10
11
11
import logger from '../../../../logger.config.mjs' ;
12
+ import { AppContext } from '../../../../context/AppContextProvider' ;
12
13
13
14
interface searchBarProps {
14
15
onSearch ?: ( query : string , results : any [ ] ) => void ;
@@ -21,6 +22,8 @@ const SearchBar: React.FC<searchBarProps> = ({ onSearch, page }) => {
21
22
const [ searchBarValue , setSearchBarValue ] = useState ( '' ) ;
22
23
const [ loading , setLoading ] = useState ( false ) ;
23
24
25
+ const { isSigningInUser } = useContext ( AppContext ) ;
26
+
24
27
const inputRef = useRef < HTMLInputElement > ( null ) ;
25
28
26
29
const getPlaceholderText = ( page : 'map_center' | 'default' ) : string => {
@@ -70,17 +73,20 @@ const SearchBar: React.FC<searchBarProps> = ({ onSearch, page }) => {
70
73
type = "text"
71
74
variant = "outlined"
72
75
color = "success"
73
- className = " bg-white hover:bg-gray-100 w-full rounded"
74
- label = { placeholder }
76
+ className = { `w-full rounded ${ isSigningInUser ? ' bg-gray-200' : 'bg- white hover:bg-gray-100' } ` }
77
+ label = { ` ${ isSigningInUser ? '' : placeholder } ` }
75
78
value = { searchBarValue }
76
79
onChange = { handleSearchBarChange }
77
80
ref = { inputRef }
81
+ disabled = { isSigningInUser }
78
82
/>
79
83
</ FormControl >
80
84
< button
81
85
aria-label = "search"
82
86
type = "submit"
83
- className = "bg-primary rounded h-full w-15 p-[15.5px] flex items-center justify-center hover:bg-gray-600"
87
+ className = { `rounded h-full w-15 p-[15.5px] flex items-center justify-center
88
+ ${ isSigningInUser ? 'bg-tertiary' : 'bg-primary hover:bg-gray-500' } ` }
89
+ disabled = { isSigningInUser }
84
90
>
85
91
< SearchIcon className = "text-[#ffc153]" />
86
92
</ button >
0 commit comments