2026-08-07 17:29:33 +02:00
|
|
|
import { useState } from "react";
|
2023-12-07 16:33:37 +00:00
|
|
|
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";
|
2026-08-07 17:29:33 +02:00
|
|
|
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
|
|
|
|
|
);
|
2026-08-07 17:29:33 +02:00
|
|
|
const [deleteAllOpened, setDeleteAllOpened] = useState(false);
|
2023-12-07 16:33:37 +00:00
|
|
|
|
|
|
|
|
return (
|
2023-12-14 10:37:29 +00:00
|
|
|
<div className="container mx-auto">
|
2023-12-07 16:33:37 +00:00
|
|
|
<ErrorComponent
|
2023-12-17 19:27:22 +00:00
|
|
|
error={closeableError}
|
|
|
|
|
remove={() => setCloseableError(null)}
|
2023-12-07 16:33:37 +00:00
|
|
|
/>
|
2023-12-17 19:27:22 +00:00
|
|
|
<ErrorComponent error={otherError} />
|
2026-08-07 17:29:33 +02:00
|
|
|
{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} />
|
2026-08-07 17:29:33 +02:00
|
|
|
<DeleteAllTorrentsModal
|
|
|
|
|
show={deleteAllOpened}
|
|
|
|
|
onHide={() => setDeleteAllOpened(false)}
|
|
|
|
|
/>
|
2023-12-14 10:37:29 +00:00
|
|
|
</div>
|
2023-12-07 16:33:37 +00:00
|
|
|
);
|
|
|
|
|
};
|