Skip to content

Commit 12cb2d0

Browse files
committed
Add loading state and improve empty dataset handling in ListingComponent
1 parent 860cd72 commit 12cb2d0

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

app/[locale]/(user)/components/ListingComponent.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ const ListingComponent: React.FC<ListingProps> = ({
232232
}
233233
}, [variables, fetchDatasets]);
234234

235+
const [hasMounted, setHasMounted] = useState(false);
236+
237+
useEffect(() => {
238+
setHasMounted(true);
239+
}, []);
240+
241+
if (!hasMounted) return <Loading />;
242+
235243
const handlePageChange = (newPage: number) => {
236244
setQueryParams({ type: 'SET_CURRENT_PAGE', payload: newPage });
237245
};
@@ -301,7 +309,11 @@ const ListingComponent: React.FC<ListingProps> = ({
301309
</Text>
302310
)}
303311

304-
<Text variant="headingLg" fontWeight="regular" className=' leading-3 '>
312+
<Text
313+
variant="headingLg"
314+
fontWeight="regular"
315+
className=" leading-3 "
316+
>
305317
{categoryDescription
306318
? categoryDescription
307319
: 'No Description Provided'}
@@ -440,7 +452,9 @@ const ListingComponent: React.FC<ListingProps> = ({
440452
</div>
441453
)}
442454

443-
{facets && datasetDetails?.length > 0 ? (
455+
{facets === null ? (
456+
<Loading />
457+
) : facets.results.length > 0 ? (
444458
<GraphqlPagination
445459
totalRows={count}
446460
pageSize={queryParams.pageSize}
@@ -503,7 +517,9 @@ const ListingComponent: React.FC<ListingProps> = ({
503517
})}
504518
</GraphqlPagination>
505519
) : (
506-
<Loading />
520+
<div className="flex h-screen items-center justify-center">
521+
<Text variant="heading2xl">No datasets found</Text>
522+
</div>
507523
)}
508524
</div>
509525
</div>

0 commit comments

Comments
 (0)