|
1 |
| -import { type ChangeEventHandler } from "react"; |
2 |
| -import "./BranchSelector.scss"; |
| 1 | +import InputLabel from "@mui/material/InputLabel"; |
| 2 | +import MenuItem from "@mui/material/MenuItem"; |
| 3 | +import FormControl from "@mui/material/FormControl"; |
| 4 | +import type { SelectChangeEvent } from "@mui/material/Select"; |
| 5 | +import Select from "@mui/material/Select"; |
3 | 6 |
|
4 | 7 | import { useGlobalData } from "hooks";
|
5 | 8 | import { sendFetchAnalyzedDataCommand } from "services";
|
| 9 | +import "./BranchSelector.scss"; |
6 | 10 |
|
7 | 11 | const BranchSelector = () => {
|
8 | 12 | const { branchList, selectedBranch, setSelectedBranch, setLoading } = useGlobalData();
|
9 | 13 |
|
10 |
| - const handleChangeSelect: ChangeEventHandler<HTMLSelectElement> = (e) => { |
11 |
| - setSelectedBranch(e.target.value); |
| 14 | + const handleChangeSelect = (event: SelectChangeEvent) => { |
| 15 | + setSelectedBranch(event.target.value); |
12 | 16 | setLoading(true);
|
13 |
| - sendFetchAnalyzedDataCommand(e.target.value); |
| 17 | + sendFetchAnalyzedDataCommand(event.target.value); |
14 | 18 | };
|
15 | 19 |
|
16 | 20 | return (
|
17 |
| - <section className="branch-selector"> |
18 |
| - <span>Branches:</span> |
19 |
| - <select |
20 |
| - className="select-box" |
21 |
| - onChange={handleChangeSelect} |
22 |
| - value={selectedBranch} |
| 21 | + <div className="branch-selector"> |
| 22 | + <p>Branches: </p> |
| 23 | + <FormControl |
| 24 | + sx={{ m: 1, minWidth: 120 }} |
| 25 | + size="small" |
23 | 26 | >
|
24 |
| - {branchList?.map((option) => ( |
25 |
| - <option |
26 |
| - key={option} |
27 |
| - value={option} |
28 |
| - > |
29 |
| - {option} |
30 |
| - </option> |
31 |
| - ))} |
32 |
| - </select> |
33 |
| - </section> |
| 27 | + <InputLabel id="branch-select-small-label">Branches</InputLabel> |
| 28 | + <Select |
| 29 | + labelId="branch-select-small-label" |
| 30 | + id="branch-select-small" |
| 31 | + value={selectedBranch} |
| 32 | + label="Branches" |
| 33 | + onChange={handleChangeSelect} |
| 34 | + className="select-box" |
| 35 | + > |
| 36 | + <MenuItem value=""> |
| 37 | + <em>None</em> |
| 38 | + </MenuItem> |
| 39 | + {branchList?.map((option) => ( |
| 40 | + <MenuItem |
| 41 | + key={option} |
| 42 | + value={option} |
| 43 | + > |
| 44 | + {option} |
| 45 | + </MenuItem> |
| 46 | + ))} |
| 47 | + </Select> |
| 48 | + </FormControl> |
| 49 | + </div> |
34 | 50 | );
|
35 | 51 | };
|
36 | 52 |
|
|
0 commit comments