Skip to content

Commit 3e32a6a

Browse files
authored
Merge pull request #26 from CS3219-AY2324S1/22-create-button-for-matching-service
add matching service button
2 parents 0a40199 + bf5d2ae commit 3e32a6a

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

src/components/Home.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect } from "react";
22
import { Box } from "@mui/material";
3+
import ButtonModal from "./MatchingService/MatchButton";
34

45
export default function Home() {
56
// Sample data for practice questions (you can replace this with actual data)
@@ -34,6 +35,7 @@ export default function Home() {
3435
</li>
3536
))}
3637
</ul>
38+
<ButtonModal />
3739
</div>
3840
</div>
3941
</Box>
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

0 commit comments

Comments
 (0)