File tree Expand file tree Collapse file tree 4 files changed +20
-10
lines changed
Expand file tree Collapse file tree 4 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { User, Code } from 'lucide-react';
66import { Button } from '@/components/ui/button' ;
77import { useAuthStore } from '@/state/useAuthStore' ;
88import { consumeMessageFromQueue , sendMessageToQueue } from '@/lib/rabbitmq' ;
9- import { Match } from '@/types/types' ;
9+ import { UserMatchingResponse } from '@/types/types' ;
1010
1111export default function LoadingPage ( ) {
1212 const [ elapsedTime , setElapsedTime ] = useState ( 0 ) ;
@@ -17,9 +17,9 @@ export default function LoadingPage() {
1717
1818 // Function to consume messages from the RabbitMQ queue
1919 const handleStartListening = ( ) => {
20- const onMessageReceived = ( message : Match ) => {
20+ const onMessageReceived = ( message : UserMatchingResponse ) => {
2121 if ( message . status == "matched" ) {
22- console . log ( 'Match found, your partner is' , message . match ) ;
22+ console . log ( 'Match found, your partner is' , message . match . name ) ;
2323 setMatchStatus ( 'matched' ) ;
2424 } else {
2525 console . log ( 'Match failed' ) ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import { TopicsPopover } from '@/app/(main)/components/filter/TopicsPopover';
1515import { sendMessageToQueue } from '@/lib/rabbitmq' ;
1616import { axiosAuthClient } from '@/network/axiosClient' ;
1717import { DIFFICULTY_OPTIONS } from '@/lib/constants' ;
18+ import { UserMatchingRequest } from '@/types/types' ;
1819
1920export function PreMatch ( ) {
2021 const [ open , setOpen ] = useState ( false ) ;
@@ -25,7 +26,7 @@ export function PreMatch() {
2526 const handleConfirm = async ( ) => {
2627 try {
2728 const profileDetails = await getProfileDetails ( ) ;
28- const message = {
29+ const message : UserMatchingRequest = {
2930 _id : profileDetails . id ,
3031 name : profileDetails . username ,
3132 topic : selectedTopics [ 0 ] || '' , // TODO: change to list, but current backend only accepts 1
Original file line number Diff line number Diff line change 11/* eslint-disable @typescript-eslint/no-explicit-any */
2+ import { UserMatchingRequest , UserMatchingResponse } from '@/types/types' ;
23import { Client , IFrame , IMessage } from '@stomp/stompjs' ;
34
45let isConnected = false ;
56
6- const sendMessageToQueue = async ( message : Record < string , any > ) => {
7+ const sendMessageToQueue = async ( message : UserMatchingRequest ) => {
78 const uri = process . env . NEXT_PUBLIC_RABBITMQ_URL ;
89 const user = process . env . NEXT_PUBLIC_RABBITMQ_USER ;
910 const pass = process . env . NEXT_PUBLIC_RABBITMQ_PW ;
@@ -52,7 +53,7 @@ const sendMessageToQueue = async (message: Record<string, any>) => {
5253
5354const consumeMessageFromQueue = async (
5455 queue : string ,
55- onMessage : ( message : any ) => void ,
56+ onMessage : ( message : UserMatchingResponse ) => void ,
5657) => {
5758 const uri = process . env . NEXT_PUBLIC_RABBITMQ_URL ;
5859 const user = process . env . NEXT_PUBLIC_RABBITMQ_USER ;
Original file line number Diff line number Diff line change @@ -48,10 +48,17 @@ interface User {
4848 username : string ;
4949}
5050
51- interface Match {
52- status : string ;
53- match : string ;
51+ interface UserMatchingRequest {
52+ _id : string ;
53+ name ?: string ;
54+ difficulty ?: string ;
55+ topic ?: string ;
56+ type : string ;
57+ }
5458
59+ interface UserMatchingResponse {
60+ status : string ;
61+ match : UserMatchingRequest ;
5562}
5663
5764export type {
@@ -61,5 +68,6 @@ export type {
6168 FilterBadgeProps ,
6269 FilterSelectProps ,
6370 User ,
64- Match ,
71+ UserMatchingResponse ,
72+ UserMatchingRequest ,
6573} ;
You can’t perform that action at this time.
0 commit comments