plane/web/components/workspace/views/views-list.tsx
Anmol Singh Bhatia b1989bae1b
feat: loading states update (#3639)
* dev: implement layout skeleton loader and helper function

* chore: implemented layout loader

* chore: settings loader added

* chore: cycle, module, view, pages, notification and projects loader added

* chore: kanban loader improvement

* chore: loader utils updated
2024-02-13 19:12:10 +05:30

40 lines
1.1 KiB
TypeScript

import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
import useSWR from "swr";
// store hooks
import { useGlobalView } from "hooks/store";
// components
import { GlobalViewListItem } from "components/workspace";
// ui
import { ViewListLoader } from "components/ui";
type Props = {
searchQuery: string;
};
export const GlobalViewsList: React.FC<Props> = observer((props) => {
const { searchQuery } = props;
// router
const router = useRouter();
const { workspaceSlug } = router.query;
// store hooks
const { fetchAllGlobalViews, currentWorkspaceViews, getSearchedViews } = useGlobalView();
useSWR(
workspaceSlug ? `GLOBAL_VIEWS_LIST_${workspaceSlug.toString()}` : null,
workspaceSlug ? () => fetchAllGlobalViews(workspaceSlug.toString()) : null
);
if (!currentWorkspaceViews) return <ViewListLoader />;
const filteredViewsList = getSearchedViews(searchQuery);
return (
<>
{filteredViewsList?.map((viewId) => (
<GlobalViewListItem key={viewId} viewId={viewId} />
))}
</>
);
});