Skip to content

Commit adf2977

Browse files
committed
Add bug fixes
- Match service sending improper params to get random qn - FE sending improper difficulty values Signed-off-by: SeeuSim <[email protected]>
1 parent 97f8c31 commit adf2977

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

backend/matching/src/services/get-match-items.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { IMatchItemsResponse, IMatchType } from '../types/index';
1+
import type { IMatchItemsResponse, IMatchType } from '@/types';
2+
23
import { createRoom } from './collab';
34
import { getRandomQuestion } from './question';
45
import { fetchAttemptedQuestions } from './user';
@@ -21,24 +22,26 @@ export async function getMatchItems(
2122
]);
2223

2324
const allAttemptedQuestions = [...new Set([...attemptedQuestions1, ...attemptedQuestions2])];
24-
25+
const topics = topic?.split('|') ?? [];
2526
const payload = {
2627
attemptedQuestions: allAttemptedQuestions,
2728
...(searchIdentifier === 'difficulty' && difficulty ? { difficulty } : {}),
28-
...(searchIdentifier === 'topic' && topic ? { topic } : {}),
29-
...(searchIdentifier === 'exact match' && topic && difficulty ? { topic, difficulty } : {}),
29+
...(searchIdentifier === 'topic' && topic ? { topic: topics } : {}),
30+
...(searchIdentifier === 'exact match' && topic && difficulty
31+
? { topic: topics, difficulty }
32+
: {}),
3033
};
3134

3235
// Get a random question
3336
const question = await getRandomQuestion(payload);
3437

35-
const roomName = await createRoom(userId1, userId2, question.id.toString());
38+
const roomId = await createRoom(userId1, userId2, question.id.toString());
3639

3740
console.log('Successfully got match items');
3841
return {
39-
roomName,
42+
roomId,
4043
questionId: question.id,
41-
question,
44+
// question,
4245
};
4346
} catch (error) {
4447
console.error('Error in getMatchItems:', error);

backend/matching/src/types/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@ export interface IServiceResponse<T> {
5454

5555
export interface IQuestion {
5656
id: number;
57-
title: string;
58-
description: string;
59-
difficulty: string;
60-
topic: string[];
57+
// title: string;
58+
// description: string;
59+
// difficulty: string;
60+
// topic: string[];
6161
}
6262

6363
export interface IGetRandomQuestionPayload {
6464
attemptedQuestions: number[];
6565
difficulty?: string;
66-
topic?: string;
66+
topic?: Array<string>;
6767
}
6868

6969
export interface IMatchItemsResponse {
70-
roomName: string;
70+
roomId: string;
7171
questionId: number;
72-
question: IQuestion;
72+
// question: IQuestion;
7373
}

frontend/src/routes/match/match-form.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ interface MatchFormProps {
2929
topics: string[];
3030
}
3131

32+
const DIFFICULTIES = ['Easy', 'Medium', 'Hard'] as const;
33+
3234
export const MatchForm = ({ topics }: MatchFormProps) => {
3335
const [isModalOpen, setIsModalOpen] = useState(false);
3436

@@ -105,9 +107,11 @@ export const MatchForm = ({ topics }: MatchFormProps) => {
105107
</SelectTrigger>
106108
</FormControl>
107109
<SelectContent>
108-
<SelectItem value='easy'>Easy</SelectItem>
109-
<SelectItem value='medium'>Medium</SelectItem>
110-
<SelectItem value='hard'>Hard</SelectItem>
110+
{DIFFICULTIES.map((value, index) => (
111+
<SelectItem key={index} value={value}>
112+
{value}
113+
</SelectItem>
114+
))}
111115
</SelectContent>
112116
</Select>
113117
<FormMessage />

0 commit comments

Comments
 (0)