@@ -17,16 +17,23 @@ const style = {
17
17
transform : "translate(-50%, -50%)" ,
18
18
width : "50%" ,
19
19
display : "flex-wrap" ,
20
- maxHeight : "60%" ,
20
+ // Remove or adjust the maxHeight value
21
+ //maxHeight: "60%",
21
22
justifyContent : "center" ,
22
23
textAlign : "center" ,
23
24
bgcolor : "background.paper" ,
24
25
border : "2px solid #000" ,
25
26
boxShadow : 24 ,
26
- overflow : "auto" ,
27
27
p : 4 ,
28
28
} ;
29
29
30
+ const snackbarStyle = {
31
+ position : "absolute" as "absolute" ,
32
+ top : 3 ,
33
+ left : "50%" ,
34
+ transform : "translate(-50%, 0)"
35
+ } ;
36
+
30
37
31
38
32
39
const titleStyle = {
@@ -57,6 +64,7 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
57
64
const { user } = useAuth ( ) ;
58
65
const userEmail = user ?. email ;
59
66
const [ openSnackbar , setOpenSnackbar ] = React . useState ( false ) ;
67
+ const [ snackbarMessage , setSnackbarMessage ] = React . useState ( "" ) ;
60
68
61
69
const handleConnect = async ( ) => {
62
70
const preferences = {
@@ -73,6 +81,7 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
73
81
} ) ;
74
82
75
83
if ( filteredQuestions . length === 0 ) {
84
+ setSnackbarMessage ( "No questions match the selected difficulty and category." ) ;
76
85
setOpenSnackbar ( true ) ;
77
86
return ;
78
87
}
@@ -138,6 +147,20 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
138
147
} ;
139
148
} , [ difficulty , category , userEmail , navigate ] ) ;
140
149
150
+ React . useEffect ( ( ) => {
151
+ socket . on ( "noMatchFound" , ( ) => {
152
+ console . log ( "Match Not Found" ) ;
153
+ setIsMatching ( false ) ;
154
+ setSnackbarMessage ( "No eligible match found within the given timeframe." ) ;
155
+ setOpenSnackbar ( true ) ;
156
+
157
+ } ) ;
158
+
159
+ return ( ) => {
160
+ socket . off ( "noMatchFound" ) ;
161
+ } ;
162
+ } ) ;
163
+
141
164
return (
142
165
< Box sx = { style } >
143
166
< h2 style = { titleStyle } >
@@ -188,6 +211,7 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
188
211
) }
189
212
190
213
< Snackbar
214
+ style = { snackbarStyle }
191
215
open = { openSnackbar }
192
216
autoHideDuration = { 6000 }
193
217
onClose = { ( ) => setOpenSnackbar ( false ) }
@@ -198,7 +222,7 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
198
222
severity = "warning"
199
223
sx = { { width : "100%" } }
200
224
>
201
- No questions match the selected difficulty and category.
225
+ { snackbarMessage }
202
226
</ Alert >
203
227
</ Snackbar >
204
228
</ Box >
0 commit comments