- Added on{" "}
- {dayjs.unix(torrent.addition_date).format("ddd, D MMM, YYYY")}
+ Added on {dayjs.unix(torrent.added_on).format("ddd, D MMM, YYYY")}
{/* Peers */}
diff --git a/src/client/components/ComicDetail/TorrentSearchPanel.tsx b/src/client/components/ComicDetail/TorrentSearchPanel.tsx
index 7a0c657..96579a8 100644
--- a/src/client/components/ComicDetail/TorrentSearchPanel.tsx
+++ b/src/client/components/ComicDetail/TorrentSearchPanel.tsx
@@ -6,15 +6,17 @@ import {
PROWLARR_SERVICE_BASE_URI,
QBITTORRENT_SERVICE_BASE_URI,
} from "../../constants/endpoints";
-import { isNil } from "lodash";
+import { isEmpty, isNil } from "lodash";
+import ellipsize from "ellipsize";
+import prettyBytes from "pretty-bytes";
export const TorrentSearchPanel = (props) => {
- const { comicObjectId, issueName } = props;
+ const { issueName, comicObjectId } = props;
// Initialize searchTerm with issueName from props
const [searchTerm, setSearchTerm] = useState({ issueName });
const [torrentToDownload, setTorrentToDownload] = useState("");
- const { data, isSuccess } = useQuery({
+ const { data, isSuccess, isLoading } = useQuery({
queryKey: ["searchResults", searchTerm.issueName],
queryFn: async () => {
return await axios({
@@ -35,11 +37,26 @@ export const TorrentSearchPanel = (props) => {
},
enabled: !isNil(searchTerm.issueName) && searchTerm.issueName.trim() !== "", // Make sure searchTerm is not empty
});
-
+ const { data: addTorrentResult } = useQuery({
+ queryFn: async () =>
+ axios({
+ url: `${QBITTORRENT_SERVICE_BASE_URI}/addTorrent`,
+ method: "POST",
+ data: {
+ comicObjectId,
+ torrentToDownload,
+ },
+ }),
+ queryKey: ["addTorrentResult", torrentToDownload],
+ enabled: !isEmpty(torrentToDownload),
+ });
const searchIndexer = (values) => {
setSearchTerm({ issueName: values.issueName }); // Update searchTerm based on the form submission
};
-
+ const downloadTorrent = (evt) => {
+ console.log(evt);
+ setTorrentToDownload(evt);
+ };
return (
<>
@@ -81,21 +98,104 @@ export const TorrentSearchPanel = (props) => {
)}
/>
-
- {isSuccess &&
- data?.data.map((result, idx) => (
- -
-
{result.fileName}
- {result.indexer}
-
-
- ))}
-
+
+
+
+ The default search term is an auto-detected title; you may need to
+ change it to get better matches if the auto-detected one doesn't work.
+
+
+ {!isEmpty(data?.data) ? (
+
+
+
+
+ |
+ Name
+ |
+
+ Indexer
+ |
+
+
+ Action
+ |
+
+
+
+ {data?.data.map((result, idx) => (
+
+ |
+ {ellipsize(result.fileName, 90)}
+ {/* Seeders/Leechers */}
+
+
+
+
+
+
+
+ {result.seeders} seeders
+
+
+
+
+
+
+
+
+
+ {result.leechers} leechers
+
+
+ {/* Size */}
+
+
+
+
+
+
+ {prettyBytes(result.size)}
+
+
+
+ {/* Files */}
+
+
+
+
+
+
+ {result.files} files
+
+
+
+ |
+
+
+ {result.indexer}
+ |
+
+
+
+ |
+
+ ))}
+
+
+
+ ) : null}
>
);
};