Skip to content

Commit bbb7945

Browse files
committed
PEER-248: Use given data
1 parent c197306 commit bbb7945

File tree

5 files changed

+22
-295
lines changed

5 files changed

+22
-295
lines changed

frontend/src/assets/dummyData.ts

Lines changed: 0 additions & 284 deletions
This file was deleted.

frontend/src/assets/questions.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const questions = [
1+
import { Question } from '@/types/question-types';
2+
3+
export const questionDetails = [
24
{
35
id: 1,
46
title: 'Reverse a String',
@@ -176,3 +178,11 @@ export const questions = [
176178
leetcode: 'https://leetcode.com/problems/trips-and-users/',
177179
},
178180
];
181+
182+
export const questions: Question[] = questionDetails.map((question) => ({
183+
id: question.id,
184+
title: question.title,
185+
difficulty: question.difficulty as 'Easy' | 'Medium' | 'Hard',
186+
topics: question.topics,
187+
attempted: false,
188+
}));

frontend/src/routes/questions/table-columns.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ export const columns: ColumnDef<Question>[] = [
3939
filterFn: 'equals',
4040
},
4141
{
42-
accessorKey: 'topic',
42+
accessorKey: 'topics',
4343
header: 'Topics',
4444
cell: ({ row }) => {
45-
const topics: string[] = row.getValue('topic');
45+
const topics: string[] = row.getValue('topics');
4646
return (
4747
<div>
4848
{topics.map((topic) => (
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// import { questionApiClient } from "./api-clients"
2-
import { dummyData } from '@/assets/dummyData';
3-
import { questions } from '@/assets/questions';
2+
import { questionDetails, questions } from '@/assets/questions';
43
import { IGetQuestionsResponse } from '@/types/question-types';
54

6-
type Question = (typeof questions)[number];
5+
type QuestionDetails = (typeof questionDetails)[number];
76

8-
export const getQuestionDetails = (questionId: number): Promise<Question> => {
7+
export const getQuestionDetails = (questionId: number): Promise<QuestionDetails> => {
98
// return questionApiClient.get
9+
console.log(questionDetails.find(({ id }) => id === questionId));
1010
return new Promise((resolve, _reject) => {
11-
setTimeout(() => resolve(questions.find(({ id }) => id === questionId)!), 1000);
11+
setTimeout(() => resolve(questionDetails.find(({ id }) => id === questionId)!), 1000);
1212
});
1313
};
1414

@@ -18,8 +18,9 @@ export async function fetchQuestions(pageParam: number = 0): Promise<IGetQuestio
1818
const start = pageParam * ROWS_PER_PAGE;
1919
const end = start + ROWS_PER_PAGE;
2020
await new Promise((r) => setTimeout(r, 10));
21+
2122
return {
22-
questions: dummyData.slice(start, end),
23-
totalQuestions: dummyData.length,
23+
questions: questions.slice(start, end),
24+
totalQuestions: questions.length,
2425
};
2526
}

frontend/src/types/question-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export type Question = {
22
id: number;
33
title: string;
44
difficulty: 'Easy' | 'Medium' | 'Hard';
5-
topic: Array<string>;
5+
topics: Array<string>;
66
attempted: boolean;
77
};
88

0 commit comments

Comments
 (0)