@@ -8,7 +8,7 @@ import { ROUTES } from '@/lib/routes';
8
8
import { MATCHING_EVENT , WS_EVENT } from '@/lib/ws' ;
9
9
import { MATCHING_SOCKET } from '@/services/api-clients' ;
10
10
import { cancelMatch } from '@/services/match-service' ;
11
- import { getUserId } from '@/services/user-service ' ;
11
+ import { useUser } from '@/stores/auth-store ' ;
12
12
import { useMatchRequest } from '@/stores/match-request-store' ;
13
13
14
14
import { UI_STATUS } from './constants' ;
@@ -25,6 +25,7 @@ type IWaitingRoomUIState = {
25
25
} ;
26
26
27
27
export const WaitingRoom = ( { socketPort, setIsModalOpen } : IWaitingRoomProps ) => {
28
+ const { userId } = useUser ( ) ;
28
29
const navigate = useNavigate ( ) ;
29
30
const { values } = useMatchRequest ( ) ;
30
31
const [ { connected, canCancel, uiState } , setUIState ] = useState < IWaitingRoomUIState > ( {
@@ -33,7 +34,7 @@ export const WaitingRoom = ({ socketPort, setIsModalOpen }: IWaitingRoomProps) =
33
34
uiState : UI_STATUS . WAITING_STATUS ,
34
35
} ) ;
35
36
const { mutate : sendCancelRequest , isPending : isCancelling } = useMutation ( {
36
- mutationFn : cancelMatch ,
37
+ mutationFn : ( ) => cancelMatch ( userId ) ,
37
38
onSuccess : ( ) => {
38
39
// TODO: Add toaster notif or cancel success UI
39
40
setIsModalOpen ( false ) ;
@@ -100,7 +101,7 @@ export const WaitingRoom = ({ socketPort, setIsModalOpen }: IWaitingRoomProps) =
100
101
101
102
socket . emit ( WS_EVENT . START_QUEUING , {
102
103
roomId : socketPort ,
103
- userId : getUserId ( ) ,
104
+ userId,
104
105
topic : values ?. selectedTopics ,
105
106
difficulty : values ?. difficulty ,
106
107
} ) ;
0 commit comments