File tree Expand file tree Collapse file tree 4 files changed +7
-5
lines changed Expand file tree Collapse file tree 4 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ const QuestionCard: React.FC<QuestionCardProps> = ({ question }) => {
35
35
</ span >
36
36
</ p >
37
37
< p className = "text-sm" >
38
- Categories: < span > { question . category . join ( ", " ) } </ span >
38
+ Categories: < span > { question . categories . join ( ", " ) } </ span >
39
39
</ p >
40
40
</ div >
41
41
Original file line number Diff line number Diff line change @@ -21,13 +21,15 @@ const QuestionList: React.FC = () => {
21
21
// make use of gateway.ts later
22
22
const fetchQuestions = async ( ) => {
23
23
try {
24
- const response = await fetch ( "/data/dummyquestions.json" ) ;
24
+ const response = await fetch (
25
+ `${ process . env . NEXT_PUBLIC_QUESTION_SERVICE } /questions`
26
+ ) ;
25
27
const data : Question [ ] = await response . json ( ) ;
26
28
setQuestions ( data ) ;
27
29
28
30
// get all present categories in all qns
29
31
const uniqueCategories = Array . from (
30
- new Set ( data . flatMap ( ( question ) => question . category ) )
32
+ new Set ( data . flatMap ( ( question ) => question . categories ) )
31
33
) ;
32
34
setCategories ( [ "all" , ...uniqueCategories ] ) ;
33
35
} catch ( error ) {
@@ -46,7 +48,7 @@ const QuestionList: React.FC = () => {
46
48
difficulties [ question . difficulty ] === difficultyFilter ;
47
49
const matchesCategory =
48
50
categoryFilter === categories [ 0 ] ||
49
- question . category . includes ( categoryFilter ) ;
51
+ question . categories . includes ( categoryFilter ) ;
50
52
const matchesSearch =
51
53
searchFilter === "" ||
52
54
question . title . toLowerCase ( ) . includes ( searchFilter . toLowerCase ( ) ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ export interface Question {
2
2
id : number ;
3
3
title : string ;
4
4
description : string ;
5
- category : string [ ] ;
5
+ categories : string [ ] ;
6
6
difficulty : number ;
7
7
test_cases : {
8
8
[ key : string ] : string ;
You can’t perform that action at this time.
0 commit comments