import { Button } from "@mui/joy"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import CollectionView from "@/components/CollectionView"; import CreateCollectionDialog from "@/components/CreateCollectionDialog"; import { shortcutService } from "@/services"; import useCollectionStore from "@/stores/v1/collection"; import FilterView from "../components/FilterView"; import Icon from "../components/Icon"; import useLoading from "../hooks/useLoading"; interface State { showCreateCollectionDialog: boolean; } const CollectionDashboard: React.FC = () => { const { t } = useTranslation(); const loadingState = useLoading(); const collectionStore = useCollectionStore(); const collections = collectionStore.getCollectionList(); const [state, setState] = useState({ showCreateCollectionDialog: false, }); useEffect(() => { Promise.all([shortcutService.getMyAllShortcuts(), collectionStore.fetchCollectionList()]).finally(() => { loadingState.setFinish(); }); }, []); const setShowCreateCollectionDialog = (show: boolean) => { setState({ ...state, showCreateCollectionDialog: show, }); }; return ( <>
{loadingState.isLoading ? (
{t("common.loading")}
) : collections.length === 0 ? (

No collections found.

) : (
{collections.map((collection) => { return ; })}
)}
{state.showCreateCollectionDialog && ( setShowCreateCollectionDialog(false)} onConfirm={() => setShowCreateCollectionDialog(false)} /> )} ); }; export default CollectionDashboard;