Skip to content

Commit dd4e933

Browse files
committed
add matching service button
1 parent 13cc09f commit dd4e933

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as React from 'react';
2+
import Button from '@mui/material/Button';
3+
import Modal from '@mui/material/Modal';
4+
import MatchingForm from './MatchingForm';
5+
6+
export default function ButtonModal() {
7+
const [open, setOpen] = React.useState(false);
8+
const handleOpen = () => setOpen(true);
9+
const handleClose = () => setOpen(false);
10+
11+
return (
12+
<>
13+
<Button variant="contained" onClick={handleOpen}>
14+
Find a Match
15+
</Button>
16+
<Modal
17+
open={open}
18+
onClose={handleClose}
19+
aria-labelledby="modal-modal-title"
20+
aria-describedby="modal-modal-description"
21+
>
22+
<MatchingForm />
23+
</Modal>
24+
</>
25+
);
26+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import * as React from 'react';
2+
import { Box } from "@mui/material";
3+
import Button from '@mui/material/Button';
4+
import InputLabel from '@mui/material/InputLabel';
5+
import MenuItem from '@mui/material/MenuItem';
6+
import FormControl from '@mui/material/FormControl';
7+
import Select, { SelectChangeEvent } from '@mui/material/Select';
8+
9+
10+
const style = {
11+
position: 'absolute' as 'absolute',
12+
top: '50%',
13+
left: '50%',
14+
transform: 'translate(-50%, -50%)',
15+
width: '50%',
16+
display: 'flex-wrap',
17+
maxHeight: '60%',
18+
justifyContent: "center",
19+
textAlign: "center",
20+
bgcolor: 'background.paper',
21+
border: '2px solid #000',
22+
boxShadow: 24,
23+
overflow: 'auto',
24+
p: 4,
25+
};
26+
27+
const MatchingForm = React.forwardRef(function MatchingForm() {
28+
const [difficulty, setDifficulty] = React.useState('');
29+
const [category, setCategory] = React.useState('');
30+
const handleDiffChange = (event: SelectChangeEvent) => {
31+
setDifficulty(event.target.value);
32+
};
33+
const handleCatChange = (event: SelectChangeEvent) => {
34+
setCategory(event.target.value);
35+
};
36+
const handleConnect = () => {
37+
console.log('connecting...')
38+
}
39+
return (
40+
<Box sx={style}>
41+
<h2><center>Please select a difficulty and question category.</center></h2>
42+
<h4><center>We will attempt to connect you with a user who chose the same options as you within 30 seconds.</center></h4>
43+
<FormControl sx={{ mt: 1, width: '100%' }}>
44+
<InputLabel id="demo-simple-select-helper-label">Difficulty</InputLabel>
45+
<Select
46+
labelId="demo-simple-select-helper-label"
47+
id="demo-simple-select-helper"
48+
value={difficulty}
49+
label="Difficulty"
50+
onChange={handleDiffChange}
51+
>
52+
<MenuItem value="">
53+
<em>None</em>
54+
</MenuItem>
55+
<MenuItem value={'Easy'}>Easy</MenuItem>
56+
<MenuItem value={'Medium'}>Medium</MenuItem>
57+
<MenuItem value={'Hard'}>Hard</MenuItem>
58+
</Select>
59+
{/* <FormHelperText>Difficulty of Question</FormHelperText> */}
60+
</FormControl>
61+
<FormControl sx={{ mt: 1, mb: 1, width: '100%' }}>
62+
<InputLabel id="demo-simple-select-helper-label">Category</InputLabel>
63+
<Select
64+
labelId="demo-simple-select-helper-label"
65+
id="demo-simple-select-helper"
66+
value={category}
67+
label="Category"
68+
onChange={handleCatChange}
69+
>
70+
<MenuItem value="">
71+
<em>None</em>
72+
</MenuItem>
73+
<MenuItem value={'Algo'}>Algo</MenuItem>
74+
<MenuItem value={'ML'}>ML</MenuItem>
75+
</Select>
76+
{/* <FormHelperText>Difficulty of Question</FormHelperText> */}
77+
</FormControl>
78+
<Button sx={{ mt: '5%' }} variant="contained" onClick={handleConnect}>
79+
Connect
80+
</Button>
81+
</Box>
82+
);
83+
});
84+
85+
export default MatchingForm

src/pages/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Home from "../components/Home";
44
import "./App.css";
55
import Titlebar from "../components/Questions/Titlebar";
66
import CenteredContainer from "../components/CenteredContainer";
7+
import ButtonModal from "../components/MatchingService/MatchButton";
78

89
export default function App() {
910
return (
@@ -13,6 +14,7 @@ export default function App() {
1314
<CenteredContainer>
1415
<Home />
1516
<Titlebar />
17+
<ButtonModal />
1618
</CenteredContainer>
1719
</Box>
1820
);

0 commit comments

Comments
 (0)