rqbit/crates/librqbit/webui/src/components/RootContent.tsx

42 lines
1.5 KiB
TypeScript
Raw Normal View History

import { useState } from "react";
import { TorrentsList } from "./TorrentsList";
import { ErrorComponent } from "./ErrorComponent";
2023-12-17 19:27:22 +00:00
import { useTorrentStore } from "../stores/torrentStore";
import { useErrorStore } from "../stores/errorStore";
import { IconButton } from "./buttons/IconButton";
import { FiTrash2 } from "react-icons/fi";
import { DeleteAllTorrentsModal } from "./modal/DeleteAllTorrentsModal";
2023-12-17 19:27:22 +00:00
export const RootContent = (props: {}) => {
let closeableError = useErrorStore((state) => state.closeableError);
let setCloseableError = useErrorStore((state) => state.setCloseableError);
let otherError = useErrorStore((state) => state.otherError);
let torrents = useTorrentStore((state) => state.torrents);
2023-12-19 23:05:57 +00:00
let torrentsInitiallyLoading = useTorrentStore(
(state) => state.torrentsInitiallyLoading
);
const [deleteAllOpened, setDeleteAllOpened] = useState(false);
return (
<div className="container mx-auto">
<ErrorComponent
2023-12-17 19:27:22 +00:00
error={closeableError}
remove={() => setCloseableError(null)}
/>
2023-12-17 19:27:22 +00:00
<ErrorComponent error={otherError} />
{torrents && torrents.length > 0 && (
<div className="flex justify-end px-4 py-2">
<IconButton onClick={() => setDeleteAllOpened(true)}>
<FiTrash2 className="hover:text-red-500" />
</IconButton>
</div>
)}
2023-12-19 23:05:57 +00:00
<TorrentsList torrents={torrents} loading={torrentsInitiallyLoading} />
<DeleteAllTorrentsModal
show={deleteAllOpened}
onHide={() => setDeleteAllOpened(false)}
/>
</div>
);
};