@@ -6,11 +6,10 @@ import Container from "@/components/ui/Container";
6
6
import { Form , FormControl , FormField , FormItem } from "@/components/ui/form" ;
7
7
import { MultiSelect } from "@/components/ui/multiselect" ;
8
8
import MoonLoader from "react-spinners/MoonLoader" ;
9
- import { useEffect } from "react" ;
10
9
import { useForm } from "react-hook-form" ;
11
10
import { Client as StompClient } from "@stomp/stompjs" ;
12
11
import SockJS from "sockjs-client" ;
13
- import { useRef , useState } from "react" ;
12
+ import { useRef , useState , useEffect } from "react" ;
14
13
import FindPeerHeader from "@/app/(auth)/components/match/FindPeerHeader" ;
15
14
import {
16
15
preferredLanguagesList ,
@@ -74,7 +73,7 @@ const SOCKET_URL =
74
73
75
74
const CURRENT_USER = getBaseUserData ( ) . username ; // Username is unique
76
75
77
- const TIMEOUT_TIMER = 3 ; // in seconds
76
+ const TIMEOUT_TIMER = 100 ; // in seconds
78
77
79
78
const FindPeer = ( ) => {
80
79
const stompClientRef = useRef < StompClient | null > ( null ) ;
@@ -189,9 +188,11 @@ const FindPeer = () => {
189
188
onDisconnect : ( ) => {
190
189
console . log ( "STOMP connection closed" ) ;
191
190
setIsConnected ( false ) ;
191
+ clearTimeout ( timeout ) ;
192
192
} ,
193
193
onStompError : ( error ) => {
194
194
console . error ( "STOMP error: " , error ) ;
195
+ clearTimeout ( timeout ) ;
195
196
reject ( new Error ( error . headers . message ) ) ;
196
197
} ,
197
198
} ) ;
@@ -248,6 +249,24 @@ const FindPeer = () => {
248
249
} ) ;
249
250
250
251
const onSubmit = ( data : FindMatchFormOutput ) => {
252
+ if ( ! data . questionDifficulties . length ) {
253
+ Swal . fire (
254
+ "Error" ,
255
+ "Please select at least one difficulty level" ,
256
+ "error"
257
+ ) ;
258
+ return ;
259
+ } else if ( ! data . preferredLanguages . length ) {
260
+ Swal . fire (
261
+ "Error" ,
262
+ "Please select at least one preferred programming language" ,
263
+ "error"
264
+ ) ;
265
+ return ;
266
+ } else if ( ! data . questionTopics . length ) {
267
+ Swal . fire ( "Error" , "Please select at least one topic" , "error" ) ;
268
+ return ;
269
+ }
251
270
sendMatchRequest ( data ) ;
252
271
} ;
253
272
0 commit comments