diff --git a/src/client/components/Settings/QbittorrentSettings/QbittorrentConnectionForm.tsx b/src/client/components/Settings/QbittorrentSettings/QbittorrentConnectionForm.tsx
index 074f048..dce90cc 100644
--- a/src/client/components/Settings/QbittorrentSettings/QbittorrentConnectionForm.tsx
+++ b/src/client/components/Settings/QbittorrentSettings/QbittorrentConnectionForm.tsx
@@ -1,15 +1,10 @@
-import React, { ReactElement, useCallback, useEffect } from "react";
-import { useAppDispatch, useAppSelector } from "../../../hooks/store";
-import { getQBitTorrentClientInfo } from "../../../actions/settings.actions";
+import React, { ReactElement, useCallback } from "react";
import { saveSettings } from "../../../actions/settings.actions";
import { ConnectionForm } from "../../shared/ConnectionForm/ConnectionForm";
-import { useGetAllSettingsQuery } from "../../../services/settings.api";
-import { isUndefined } from "lodash";
import { useConnectToQBittorrentClientQuery } from "../../../services/torrents.api";
export const QbittorrentConnectionForm = (): ReactElement => {
- const dispatch = useAppDispatch();
-
+ const { data, isLoading } = useConnectToQBittorrentClientQuery({});
const onSubmit = useCallback(async (values) => {
try {
dispatch(saveSettings(values, "bittorrent"));
@@ -18,7 +13,18 @@ export const QbittorrentConnectionForm = (): ReactElement => {
}
}, []);
- return <>>;
+ return (
+ <>
+ {!isLoading && (
+
{JSON.stringify(data?.qbittorrentClientInfo, null, 2)}
+ >
+ );
};
export default QbittorrentConnectionForm;
diff --git a/src/client/services/settings.api.ts b/src/client/services/settings.api.ts
index bce1989..be49bc1 100644
--- a/src/client/services/settings.api.ts
+++ b/src/client/services/settings.api.ts
@@ -6,12 +6,6 @@ export const settingsApi = emptySplitApi.injectEndpoints({
getAllSettings: builder.query({
query: () => "localhost:3000/api/settings/getAllSettings",
}),
- getQBitTorrentClientInfo: builder.query({
- queryFn: async () => {
- try {
- } catch (err) {}
- },
- }),
}),
overrideExisting: false,
});
diff --git a/src/client/services/torrents.api.ts b/src/client/services/torrents.api.ts
index ee496ef..00aa6cb 100644
--- a/src/client/services/torrents.api.ts
+++ b/src/client/services/torrents.api.ts
@@ -4,20 +4,26 @@ export const torrentsApi = emptySplitApi.injectEndpoints({
endpoints: (builder) => ({
connectToQBittorrentClient: builder.query({
queryFn: async (_arg, _queryApi, _extraOptions, fetchWithBQ) => {
- const qBittorrentHostInfo = await fetchWithBQ(
- "localhost:3000/api/settings/getAllSettings",
- );
- await fetchWithBQ({
- url: "localhost:3060/api/qbittorrent/connect",
- method: "POST",
- data: qBittorrentHostInfo,
- });
- console.log(qBittorrentHostInfo);
- return {
- url: "",
- method: "GET",
- data: qBittorrentHostInfo,
- };
+ try {
+ const {
+ data: { bittorrent },
+ } = await fetchWithBQ("localhost:3000/api/settings/getAllSettings");
+ await fetchWithBQ({
+ url: "localhost:3060/api/qbittorrent/connect",
+ method: "POST",
+ body: bittorrent?.client?.host,
+ });
+ const { data } = await fetchWithBQ({
+ url: "localhost:3060/api/qbittorrent/getClientInfo",
+ method: "GET",
+ });
+
+ return {
+ data: { bittorrent, qbittorrentClientInfo: data },
+ };
+ } catch (err) {
+ throw err;
+ }
},
}),
}),