@@ -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
const titleStyle = {
31
38
fontSize : "2rem" , // Increase the title size
32
39
} ;
@@ -53,6 +60,7 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
53
60
const { user } = useAuth ( ) ;
54
61
const userEmail = user ?. email ;
55
62
const [ openSnackbar , setOpenSnackbar ] = React . useState ( false ) ;
63
+ const [ snackbarMessage , setSnackbarMessage ] = React . useState ( "" ) ;
56
64
57
65
const handleConnect = async ( ) => {
58
66
const preferences = {
@@ -69,6 +77,9 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
69
77
} ) ;
70
78
71
79
if ( filteredQuestions . length === 0 ) {
80
+ setSnackbarMessage (
81
+ "No questions match the selected difficulty and category."
82
+ ) ;
72
83
setOpenSnackbar ( true ) ;
73
84
return ;
74
85
}
@@ -121,8 +132,11 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
121
132
const matchedUser = matchedUserPreferences . matchedUserPreferences ;
122
133
setIsMatching ( false ) ;
123
134
const qId = await getQuestions ( seed ) ;
124
- const hashedEmailOne = sha256 ( userEmail || "" ) ;
125
- const hashedEmailTwo = sha256 ( matchedUser . userEmail ) ;
135
+ const emails = [ userEmail , matchedUser . userEmail ] . sort ( ) ;
136
+
137
+ // Hash the sorted emails
138
+ const hashedEmailOne = sha256 ( emails [ 0 ] ) ;
139
+ const hashedEmailTwo = sha256 ( emails [ 1 ] ) ;
126
140
navigate ( `/collab/question/${ qId } /${ hashedEmailOne } /${ hashedEmailTwo } ` ) ;
127
141
} ) ;
128
142
@@ -132,6 +146,19 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
132
146
// eslint-disable-next-line react-hooks/exhaustive-deps
133
147
} , [ difficulty , category , userEmail , navigate ] ) ;
134
148
149
+ React . useEffect ( ( ) => {
150
+ socket . on ( "noMatchFound" , ( ) => {
151
+ console . log ( "Match Not Found" ) ;
152
+ setIsMatching ( false ) ;
153
+ setSnackbarMessage ( "No eligible match found within the given timeframe." ) ;
154
+ setOpenSnackbar ( true ) ;
155
+ } ) ;
156
+
157
+ return ( ) => {
158
+ socket . off ( "noMatchFound" ) ;
159
+ } ;
160
+ } ) ;
161
+
135
162
return (
136
163
< Box sx = { style } >
137
164
< h2 style = { titleStyle } >
@@ -186,6 +213,7 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
186
213
) }
187
214
188
215
< Snackbar
216
+ style = { snackbarStyle }
189
217
open = { openSnackbar }
190
218
autoHideDuration = { 6000 }
191
219
onClose = { ( ) => setOpenSnackbar ( false ) }
@@ -196,7 +224,7 @@ const MatchingForm = React.forwardRef(function MatchingForm() {
196
224
severity = "warning"
197
225
sx = { { width : "100%" } }
198
226
>
199
- No questions match the selected difficulty and category.
227
+ { snackbarMessage }
200
228
</ Alert >
201
229
</ Snackbar >
202
230
</ Box >
0 commit comments