diff --git a/src/client/components/ComicDetail/ComicDetail.tsx b/src/client/components/ComicDetail/ComicDetail.tsx
index da1b4a7..be36862 100644
--- a/src/client/components/ComicDetail/ComicDetail.tsx
+++ b/src/client/components/ComicDetail/ComicDetail.tsx
@@ -351,7 +351,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => {
),
name: "Torrent Search",
- content: ,
+ content: ,
shouldShow: true,
},
{
diff --git a/src/client/components/ComicDetail/DownloadsPanel.tsx b/src/client/components/ComicDetail/DownloadsPanel.tsx
index 8d1f796..618e78c 100644
--- a/src/client/components/ComicDetail/DownloadsPanel.tsx
+++ b/src/client/components/ComicDetail/DownloadsPanel.tsx
@@ -46,22 +46,6 @@ export const DownloadsPanel = (
}),
});
- const { data: qbittorrentConnectionResult } = useQuery({
- queryFn: async () =>
- axios({
- url: `${QBITTORRENT_SERVICE_BASE_URI}/connect`,
- method: "POST",
- data: {
- hostname: "localhost",
- protocol: "http",
- port: "8080",
- username: "admin",
- password: "password",
- },
- }),
- queryKey: ["qbittorrentConnection"],
- });
-
const {
data: torrentProperties,
isSuccess: torrentPropertiesFetched,
diff --git a/src/client/components/ComicDetail/TorrentSearchPanel.tsx b/src/client/components/ComicDetail/TorrentSearchPanel.tsx
index af3eed9..7a0c657 100644
--- a/src/client/components/ComicDetail/TorrentSearchPanel.tsx
+++ b/src/client/components/ComicDetail/TorrentSearchPanel.tsx
@@ -1,39 +1,23 @@
-import React, { useCallback, ReactElement, useEffect, useState } from "react";
-
-import { useQuery, useQueryClient } from "@tanstack/react-query";
+import React, { useState } from "react";
+import { useQuery } from "@tanstack/react-query";
import axios from "axios";
import { Form, Field } from "react-final-form";
import {
PROWLARR_SERVICE_BASE_URI,
QBITTORRENT_SERVICE_BASE_URI,
} from "../../constants/endpoints";
-import { isEmpty, isNil } from "lodash";
+import { isNil } from "lodash";
-export const TorrentSearchPanel = (props): ReactElement => {
- const { comicObjectId } = props;
- const [prowlarrSettingsData, setProwlarrSettingsData] = useState({});
- const [searchTerm, setSearchTerm] = useState("");
+export const TorrentSearchPanel = (props) => {
+ const { comicObjectId, issueName } = props;
+ // Initialize searchTerm with issueName from props
+ const [searchTerm, setSearchTerm] = useState({ issueName });
const [torrentToDownload, setTorrentToDownload] = useState("");
- const { data: qbittorrentConnectionResult } = useQuery({
- queryFn: async () =>
- axios({
- url: `${QBITTORRENT_SERVICE_BASE_URI}/connect`,
- method: "POST",
- data: {
- hostname: "localhost",
- protocol: "http",
- port: "8080",
- username: "admin",
- password: "password",
- },
- }),
- queryKey: ["qbittorrentConnection"],
- });
-
const { data, isSuccess } = useQuery({
- queryFn: async () =>
- axios({
+ queryKey: ["searchResults", searchTerm.issueName],
+ queryFn: async () => {
+ return await axios({
url: `${PROWLARR_SERVICE_BASE_URI}/search`,
method: "POST",
data: {
@@ -41,97 +25,76 @@ export const TorrentSearchPanel = (props): ReactElement => {
apiKey: "c4f42e265fb044dc81f7e88bd41c3367",
offset: 0,
categories: [7030],
- query: searchTerm,
+ query: searchTerm.issueName,
host: "localhost",
limit: 100,
type: "search",
indexerIds: [2],
},
- }),
- queryKey: ["prowlarrSettingsData", searchTerm],
- enabled: searchTerm !== "",
+ });
+ },
+ 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: {
- torrentToDownload,
- comicObjectId,
- },
- }),
- queryKey: ["addTorrentResult"],
- enabled: !isNil(torrentToDownload) && searchTerm !== "",
- });
- console.log(torrentToDownload);
- const searchProwlarrIndexer = (evt) => {
- setSearchTerm(evt.searchTerm);
- };
- const downloadTorrent = (evt) => {
- console.log(evt);
- setTorrentToDownload(evt);
+ const searchIndexer = (values) => {
+ setSearchTerm({ issueName: values.issueName }); // Update searchTerm based on the form submission
};
+
return (
<>