@@ -8,8 +8,8 @@ import { apiGatewayClient } from "./gateway";
8
8
* @returns An array of completed questions.
9
9
*/
10
10
export async function fetchUserCompletedQuestions (
11
- userId : String
12
- ) : Promise < SolvedQuestion [ ] > {
11
+ userId : number
12
+ ) : Promise < SolvedQuestion [ ] > {
13
13
try {
14
14
const response : AxiosResponse = await apiGatewayClient . get (
15
15
`/api/users/${ userId } /questions`
@@ -19,14 +19,16 @@ export async function fetchUserCompletedQuestions(
19
19
const completedQuestions : SolvedQuestion [ ] = resData . map (
20
20
( q : any ) =>
21
21
new SolvedQuestion (
22
- q . _id ,
23
- q . id ,
24
- q . title ,
25
- q . description ,
22
+ q . question__id ,
23
+ q . questionId ,
24
+ q . questionTitle ,
25
+ "" , // not impt
26
26
q . topics ,
27
27
q . difficulty ,
28
- false , // Default value for solved
29
- undefined // Default value for solvedDate
28
+ q . verdict ,
29
+ q . sourceCode ,
30
+ q . language ,
31
+ q . answeredAt // Default value for solvedDate
30
32
)
31
33
) ;
32
34
@@ -38,50 +40,52 @@ export async function fetchUserCompletedQuestions(
38
40
}
39
41
}
40
42
41
- /**
42
- * Add a new question to the user's completed questions.
43
- * @param userId - The ID of the user to whom you want to add the question.
44
- * @param questionId - The ID of the question you want to add.
45
- * @param complexity - The complexity of the question.
46
- * @param category - The category of the question.
47
- * @returns The added question.
48
- */
49
- export async function addUserQuestion (
50
- userId : number ,
51
- questionId : string ,
52
- complexity : number ,
53
- category : string [ ]
54
- ) : Promise < SolvedQuestion > {
55
- try {
56
- const response : AxiosResponse = await apiGatewayClient . post (
57
- `/api/users/${ userId } /addquestions` ,
58
- {
59
- userId,
60
- questionId,
61
- complexity,
62
- category,
63
- }
64
- ) ;
43
+ // / **
44
+ // * Add a new question to the user's completed questions.
45
+ // * @param userId - The ID of the user to whom you want to add the question.
46
+ // * @param questionId - The ID of the question you want to add.
47
+ // * @param complexity - The complexity of the question.
48
+ // * @param category - The category of the question.
49
+ // * @returns The added question.
50
+ // */
51
+ // export async function addUserQuestion(
52
+ // userId: number,
53
+ // questionId: string,
54
+ // complexity: number,
55
+ // category: string[]
56
+ // ): Promise<SolvedQuestion> {
57
+ // try {
58
+ // const response: AxiosResponse = await apiGatewayClient.post(
59
+ // `/api/users/${userId}/addquestions`,
60
+ // {
61
+ // userId,
62
+ // questionId,
63
+ // complexity,
64
+ // category,
65
+ // }
66
+ // );
65
67
66
- const resData = response . data ;
67
- const addedQuestion : SolvedQuestion = new SolvedQuestion (
68
- resData . _id ,
69
- resData . id ,
70
- resData . title ,
71
- resData . description ,
72
- resData . topics ,
73
- resData . difficulty ,
74
- false , // Default value for solved
75
- undefined // Default value for solvedDate
76
- ) ;
68
+ // const resData = response.data;
69
+ // const addedQuestion: SolvedQuestion = new SolvedQuestion(
70
+ // resData._id,
71
+ // resData.id,
72
+ // resData.title,
73
+ // resData.description,
74
+ // resData.topics,
75
+ // resData.difficulty,
76
+ // resData.verdict,
77
+ // resData.sourceCode,
78
+ // resData.language,
79
+ // undefined // Default value for solvedDate
80
+ // );
77
81
78
- return addedQuestion ;
79
- } catch ( error ) {
80
- // Handle errors appropriately, e.g., log the error or throw it to be handled by the caller.
81
- console . error ( error ) ;
82
- throw error ;
83
- }
84
- }
82
+ // return addedQuestion;
83
+ // } catch (error) {
84
+ // // Handle errors appropriately, e.g., log the error or throw it to be handled by the caller.
85
+ // console.error(error);
86
+ // throw error;
87
+ // }
88
+ // }
85
89
86
90
87
91
/**
0 commit comments