Skip to content

Commit 8695d31

Browse files
committed
Add 'No data found' if there are no questions after filtering
1 parent 34ad15d commit 8695d31

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export function LeetcodeDashboardTable({
114114
const [searchDifficulty, setSearchDifficulty] = React.useState<string[]>([]);
115115
const [searchTopic, setSearchTopic] = React.useState<string[]>([]);
116116
const [isFilterOpen, setIsFilterOpen] = React.useState<boolean>(false);
117+
const [isLoading, setIsLoading] = React.useState<boolean>(false);
117118

118119
const questionDifficulty = Object.values(QuestionDifficulty).map((q1) => {
119120
return {
@@ -202,6 +203,7 @@ export function LeetcodeDashboardTable({
202203
];
203204

204205
useEffect(() => {
206+
setIsLoading(true);
205207
getLeetcodeDashboardData(
206208
pagination.pageIndex + 1,
207209
pagination.pageSize,
@@ -225,6 +227,7 @@ export function LeetcodeDashboardTable({
225227
setData(data.questions);
226228
}
227229
});
230+
setIsLoading(false);
228231
}, [
229232
refreshKey,
230233
pagination.pageIndex,
@@ -249,7 +252,7 @@ export function LeetcodeDashboardTable({
249252
return (
250253
<div className="w-full test">
251254
<div>
252-
<Table className="font-light min-h-[40vh]">
255+
<Table className="font-light min-h-[280px]">
253256
<TableHeader className="w-full">
254257
<TableRow className="text-white bg-primary-900 font-medium hover:bg-transparent h-[5rem] text-md">
255258
<TableCell colSpan={5} className="pl-10">
@@ -344,7 +347,11 @@ export function LeetcodeDashboardTable({
344347
<TableRow>
345348
<TableCell colSpan={columns.length}>
346349
<div className="w-full flex justify-center items-center">
347-
<MoonLoader color="#FFFFFF" size="30" />
350+
{isLoading ? (
351+
<MoonLoader color="#FFFFFF" size="30" />
352+
) : (
353+
<div className="text-base">No data found</div>
354+
)}
348355
</div>
349356
</TableCell>
350357
</TableRow>

0 commit comments

Comments
 (0)