Skip to content

Commit d043bfe

Browse files
authored
Merge pull request #90 from CS3219-AY2425S1/improvement/amqp_over_ws
Fix cancel press bug
2 parents e8a1082 + cf257d7 commit d043bfe

File tree

1 file changed

+11
-7
lines changed
  • peerprep-fe/src/app/(main)/match

1 file changed

+11
-7
lines changed

peerprep-fe/src/app/(main)/match/page.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { User, Code } from 'lucide-react';
66
import { Button } from '@/components/ui/button';
77
import { useAuthStore } from '@/state/useAuthStore';
88
import { consumeMessageFromQueue, sendMessageToQueue } from '@/lib/rabbitmq';
9-
import { UserMatchingResponse } from '@/types/types';
9+
import { UserMatchingRequest, UserMatchingResponse } from '@/types/types';
1010

1111
export default function LoadingPage() {
1212
const [elapsedTime, setElapsedTime] = useState(0);
@@ -61,12 +61,16 @@ export default function LoadingPage() {
6161

6262
const handleCancel = () => {
6363
console.log('Matching cancelled');
64-
const message = {
65-
_id: user?.id,
66-
type: "cancel",
67-
};
68-
sendMessageToQueue(message);
69-
router.push('/');
64+
if (user?.id) {
65+
const message : UserMatchingRequest = {
66+
_id: user?.id,
67+
type: "cancel",
68+
};
69+
sendMessageToQueue(message);
70+
router.push('/');
71+
} else {
72+
console.warn("User ID is undefined. This is not supposed to happen.");
73+
}
7074
};
7175

7276
return (

0 commit comments

Comments
 (0)