Skip to content

Commit

Permalink
refactor: add loading state for common list
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed May 17, 2024
1 parent eacf7fc commit 00d40c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/client/components/CommonList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Input } from './ui/input';
import { useFuseSearch } from '@/hooks/useFuseSearch';
import { Empty } from 'antd';
import { globalEventBus } from '@/utils/event';
import { Spinner } from './ui/spinner';

export interface CommonListItem {
id: string;
Expand Down Expand Up @@ -69,6 +70,12 @@ export const CommonList: React.FC<CommonListProps> = React.memo((props) => {

<ScrollArea className="flex-1">
<div className="flex flex-col gap-2 p-4">
{props.isLoading && (
<div className="flex justify-center py-8">
<Spinner size={24} />
</div>
)}

{finalList.length === 0 && !props.isLoading && <Empty />}

{finalList.map((item) => {
Expand Down

0 comments on commit 00d40c8

Please sign in to comment.