Skip to content

Commit 85894c1

Browse files
committed
Fix rendering of questions in table
1 parent a394458 commit 85894c1

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { QuestionDifficulty, QuestionMinified } from "@/types/find-match";
1+
import { QuestionMinified } from "@/types/find-match";
22

33
const QUESTION_SERVICE = process.env.NEXT_PUBLIC_QUESTION_SERVICE;
44

5-
export const getLeetcodeDashboardData = async () => {
5+
export const getLeetcodeDashboardData = async (): Promise<
6+
QuestionMinified[]
7+
> => {
68
const url = `${QUESTION_SERVICE}/all`;
79
const response = await fetch(url);
810
const data = await response.json();
911
console.log(data);
1012
return data;
11-
}
13+
};

frontend/src/app/(auth)/leetcode-dashboard/LeetcodeDashboardTable.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,29 @@ const Cell = ({
3737

3838
export const columns: ColumnDef<QuestionMinified>[] = [
3939
{
40-
accessorKey: "questionId",
40+
accessorKey: "questionid",
4141
header: () => <Cell>ID</Cell>,
4242
cell: ({ row }) => (
43-
<Cell className="capitalize">{row.getValue("questionId")}</Cell>
43+
<Cell className="capitalize">{row.getValue("questionid")}</Cell>
4444
),
4545
},
4646
{
47-
accessorKey: "questionTitle",
47+
accessorKey: "title",
4848
header: () => <Cell>Question Title</Cell>,
49-
cell: ({ row }) => <Cell>{row.getValue("questionTitle")}</Cell>,
49+
cell: ({ row }) => <Cell>{row.getValue("title")}</Cell>,
5050
},
5151
{
52-
accessorKey: "questionDifficulty",
52+
accessorKey: "complexity",
5353
header: () => <Cell>Difficulty</Cell>,
5454
cell: ({ row }) => {
55-
return <Cell>{row.getValue("questionDifficulty")}</Cell>;
55+
return <Cell>{row.getValue("complexity")}</Cell>;
56+
},
57+
},
58+
{
59+
accessorKey: "category",
60+
header: () => <Cell>Topics</Cell>,
61+
cell: ({ row }) => {
62+
return <Cell>{row.getValue("category")}</Cell>;
5663
},
5764
},
5865
{
@@ -79,7 +86,7 @@ export function LeetcodeDashboardTable() {
7986
pageIndex: 0,
8087
pageSize: 10,
8188
});
82-
89+
8390
React.useEffect(() => {
8491
getLeetcodeDashboardData().then((data) => setData(data));
8592
}, []);

frontend/src/app/(auth)/leetcode-dashboard/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const LeetcodeDashboard = () => {
3434
<AddQuestionDialog />
3535
</Dialog>
3636
</div>
37-
{/* <LeetcodeDashboardTable /> */}
37+
<LeetcodeDashboardTable />
3838
</Container>
3939
);
4040
};

frontend/src/types/find-match.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export enum QuestionTopics {
7878
}
7979

8080
export interface QuestionMinified {
81-
questionId: string;
82-
questionTitle: string;
83-
questionDifficulty: string;
81+
questionid: string;
82+
title: string;
83+
complexity: string;
8484
}

0 commit comments

Comments
 (0)