Skip to content

Commit f9f67d3

Browse files
committed
Add topics filter
1 parent 81d41b3 commit f9f67d3

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

frontend/src/api/leetcode-dashboard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export const getLeetcodeDashboardData = async (
3030
pagination: number,
3131
pageSize: number,
3232
title: string,
33-
complexity: string[]
33+
complexity: string[],
34+
category: string[]
3435
): Promise<QuestionAll> => {
3536
const url = `${QUESTION_SERVICE}/all`;
3637
const response = await fetch(url, {
@@ -43,6 +44,7 @@ export const getLeetcodeDashboardData = async (
4344
pageSize: pageSize,
4445
title: title,
4546
complexity: complexity,
47+
category: category,
4648
}),
4749
});
4850
const data = await response.json();

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { Input } from "@/components/ui/input";
3737
import { ListFilter, Search } from "lucide-react";
3838
import { MultiSelect } from "@/components/ui/multiselect";
3939
import { capitalizeWords } from "@/utils/string_utils";
40+
import { topicsList } from "@/utils/constants";
4041

4142
const Cell = ({
4243
className,
@@ -111,6 +112,7 @@ export function LeetcodeDashboardTable({
111112
const [totalPages, setTotalPage] = React.useState<number>(1);
112113
const [searchTitle, setSearchTitle] = React.useState<string>("");
113114
const [searchDifficulty, setSearchDifficulty] = React.useState<string[]>([]);
115+
const [searchTopic, setSearchTopic] = React.useState<string[]>([]);
114116
const [isFilterOpen, setIsFilterOpen] = React.useState<boolean>(false);
115117

116118
const questionDifficulty = Object.values(QuestionDifficulty).map((q1) => {
@@ -204,7 +206,8 @@ export function LeetcodeDashboardTable({
204206
pagination.pageIndex + 1,
205207
pagination.pageSize,
206208
searchTitle,
207-
searchDifficulty
209+
searchDifficulty,
210+
searchTopic
208211
).then((data) => {
209212
setTotalPage(data.totalPages);
210213
if (data.totalPages < pagination.pageIndex + 1) {
@@ -216,7 +219,13 @@ export function LeetcodeDashboardTable({
216219
setData(data.questions);
217220
}
218221
});
219-
}, [refreshKey, pagination.pageIndex, searchTitle, searchDifficulty]);
222+
}, [
223+
refreshKey,
224+
pagination.pageIndex,
225+
searchTitle,
226+
searchDifficulty,
227+
searchTopic,
228+
]);
220229

221230
const table = useReactTable({
222231
data,
@@ -234,7 +243,7 @@ export function LeetcodeDashboardTable({
234243
return (
235244
<div className="w-full test">
236245
<div>
237-
<Table className="font-light">
246+
<Table className="font-light min-h-[50vh]">
238247
<TableHeader className="w-full">
239248
<TableRow className="text-white bg-primary-900 font-medium hover:bg-transparent h-[5rem] text-md">
240249
<TableCell colSpan={5} className="pl-10">
@@ -258,8 +267,8 @@ export function LeetcodeDashboardTable({
258267
Filter By
259268
</Button>
260269
{isFilterOpen && (
261-
<div className="absolute right-0 mt-2 h-80 w-52 bg-primary-800 text-primary-300 border border-gray-300 rounded shadow-lg z-10">
262-
<div className="flex flex-col place-items-center mt-4">
270+
<div className="absolute right-0 mt-2 w-72 min-h-[184px] bg-primary-800 text-primary-300 border border-gray-300 rounded shadow-lg z-10">
271+
<div className="flex flex-col place-items-center mt-4 gap-4">
263272
<div className="w-[90%]">
264273
<div className="text-xs">Difficulty</div>
265274
<MultiSelect
@@ -270,6 +279,16 @@ export function LeetcodeDashboardTable({
270279
className="mt-1"
271280
/>
272281
</div>
282+
<div className="w-[90%] mb-4">
283+
<div className="text-xs">Topics</div>
284+
<MultiSelect
285+
options={topicsList}
286+
onValueChange={setSearchTopic}
287+
placeholder="Select options"
288+
variant="inverted"
289+
className="mt-1"
290+
/>
291+
</div>
273292
</div>
274293
</div>
275294
)}

0 commit comments

Comments
 (0)