Skip to content

Commit 2c96948

Browse files
committed
PEER-248: Edit questions table title
1 parent 7cb637b commit 2c96948

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

frontend/src/assets/dummyData.ts

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,87 +2,80 @@ import { Question } from '@/types/question-types';
22

33
export const dummyData: Question[] = [
44
{
5-
number: 1,
5+
id: 1,
66
attempted: true,
7-
name: 'Basic Arrays',
7+
title: 'Basic Arrays',
88
difficulty: 'Easy',
99
topic: ['Arrays', 'Basic'],
1010
},
1111
{
12-
number: 2,
12+
id: 2,
1313
attempted: false,
14-
name: 'Sorting Algorithms',
14+
title: 'Sorting Algorithms',
1515
difficulty: 'Medium',
1616
topic: ['Algorithms', 'Sorting'],
1717
},
1818
{
19-
number: 3,
19+
id: 3,
2020
attempted: true,
21-
name: 'Graph Traversal',
21+
title: 'Graph Traversal',
2222
difficulty: 'Hard',
2323
topic: ['Graphs', 'DFS', 'BFS'],
2424
},
2525
{
26-
number: 4,
26+
id: 4,
2727
attempted: false,
28-
name: 'Dynamic Programming',
28+
title: 'Dynamic Programming',
2929
difficulty: 'Hard',
3030
topic: ['Dynamic Programming'],
3131
},
3232
{
33-
number: 5,
33+
id: 5,
3434
attempted: true,
35-
name: 'Binary Search Trees',
35+
title: 'Binary Search Trees',
3636
difficulty: 'Medium',
3737
topic: ['Trees', 'Binary Search'],
3838
},
3939
{
40-
number: 6,
40+
id: 6,
4141
attempted: false,
42-
name: 'Recursion Basics',
42+
title: 'Recursion Basics',
4343
difficulty: 'Easy',
4444
topic: ['Recursion'],
4545
},
4646
{
47-
number: 7,
47+
id: 7,
4848
attempted: true,
49-
name: 'Hash Tables',
49+
title: 'Hash Tables',
5050
difficulty: 'Easy',
5151
topic: ['Data Structures', 'Hashing'],
5252
},
5353
{
54-
number: 8,
54+
id: 8,
5555
attempted: false,
56-
name: 'Graph Algorithms',
56+
title: 'Graph Algorithms',
5757
difficulty: 'Medium',
5858
topic: ['Graphs', 'Shortest Path'],
5959
},
6060
{
61-
number: 9,
61+
id: 9,
6262
attempted: true,
63-
name: 'Object-Oriented Programming',
63+
title: 'Object-Oriented Programming',
6464
difficulty: 'Medium',
6565
topic: ['OOP', 'Classes', 'Inheritance'],
6666
},
6767
{
68-
number: 10,
68+
id: 10,
6969
attempted: false,
70-
name: 'Concurrency Basics',
70+
title: 'Concurrency Basics',
7171
difficulty: 'Hard',
7272
topic: ['Concurrency', 'Multithreading'],
7373
},
7474
{
75-
number: 11,
75+
id: 11,
7676
attempted: true,
77-
name: 'Machine Learning Introduction',
77+
title: 'Machine Learning Introduction',
7878
difficulty: 'Medium',
7979
topic: ['Machine Learning', 'Algorithms'],
8080
},
81-
{
82-
number: 12,
83-
attempted: false,
84-
name: 'Database Normalization',
85-
difficulty: 'Medium',
86-
topic: ['Databases', 'Normalization'],
87-
},
8881
];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ export function QuestionTable<TData, TValue>({
103103
</div>
104104
<Input
105105
placeholder='Search questions...'
106-
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
107-
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
106+
value={(table.getColumn('title')?.getFilterValue() as string) ?? ''}
107+
onChange={(event) => table.getColumn('title')?.setFilterValue(event.target.value)}
108108
className='max-w-sm'
109109
/>
110110
</div>

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ export const columns: ColumnDef<Question>[] = [
1414
filterFn: 'equals',
1515
},
1616
{
17-
accessorKey: 'name',
18-
header: 'Name',
17+
accessorKey: 'title',
18+
header: 'Title',
19+
cell: ({ row }) => {
20+
const id: number = row.original.id;
21+
const title: string = row.getValue('title');
22+
console.log(row);
23+
return (
24+
<p>
25+
{id}.&nbsp;{title}
26+
</p>
27+
);
28+
},
1929
},
2030
{
2131
accessorKey: 'difficulty',

frontend/src/types/question-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export type Question = {
2-
number: number;
3-
name: string;
2+
id: number;
3+
title: string;
44
difficulty: 'Easy' | 'Medium' | 'Hard';
55
topic: Array<string>;
66
attempted: boolean;

0 commit comments

Comments
 (0)