File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 1
- import { ChangeEvent } from 'react' ;
2
1
import ListItem from '@mui/material/ListItem' ;
3
- import TextField from '@mui/material/TextField' ;
4
2
import FormControl from '@mui/material/FormControl' ;
3
+ import Select , { SelectChangeEvent } from '@mui/material/Select' ;
4
+ import MenuItem from '@mui/material/MenuItem' ;
5
5
import { useDispatch , useStore } from '../../store' ;
6
6
7
7
const BaseUrlControls = ( ) => {
8
8
const store = useStore ( ) ;
9
9
const dispatch = useDispatch ( ) ;
10
- const handleChange = ( e : ChangeEvent < HTMLInputElement > ) => {
10
+
11
+ const handleChange = ( e : SelectChangeEvent < string > ) => {
11
12
dispatch ( { type : 'baseUrl' , payload : e . target . value } ) ;
12
13
}
14
+
13
15
return (
14
16
< ListItem >
15
17
< FormControl fullWidth >
16
- < TextField
18
+ < Select
17
19
value = { store . baseUrl }
18
20
fullWidth
19
- label = "base URL"
20
- placeholder = 'https://www.okx.com'
21
+ label = "Base URL"
21
22
onChange = { handleChange }
22
- />
23
+ >
24
+ < MenuItem value = "https://www.okx.com" > https://www.okx.com</ MenuItem >
25
+ < MenuItem value = "https://beta.okex.org" > https://beta.okex.org</ MenuItem >
26
+ < MenuItem value = "http://127.0.0.1:3000" > http://127.0.0.1:3000</ MenuItem >
27
+ </ Select >
23
28
</ FormControl >
24
29
</ ListItem >
25
30
) ;
26
31
} ;
27
32
28
- export default BaseUrlControls ;
33
+ export default BaseUrlControls ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const initialState = {
15
15
}
16
16
type Action = {
17
17
type : string ;
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
19
payload : any ;
19
20
}
20
21
const reducer = ( state : typeof initialState , action : Action ) => {
@@ -74,13 +75,18 @@ const reducer = (state: typeof initialState, action: Action) => {
74
75
}
75
76
}
76
77
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
79
export const StoreContext = createContext < { store : typeof initialState , dispatch : Dispatch < any > } | null > ( null ) ;
78
80
79
81
export const useStore = ( ) => {
82
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
83
+ // @ts -expect-error
80
84
return useContext ( StoreContext ) . store ;
81
85
} ;
82
86
83
87
export const useDispatch = ( ) => {
88
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
89
+ // @ts -expect-error
84
90
return useContext ( StoreContext ) . dispatch ;
85
91
}
86
92
You can’t perform that action at this time.
0 commit comments