diff --git a/src/client/components/Settings/AirDCPPSettings/AirDCPPSettingsForm.tsx b/src/client/components/Settings/AirDCPPSettings/AirDCPPSettingsForm.tsx index 548f408..9b4290b 100644 --- a/src/client/components/Settings/AirDCPPSettings/AirDCPPSettingsForm.tsx +++ b/src/client/components/Settings/AirDCPPSettings/AirDCPPSettingsForm.tsx @@ -1,5 +1,4 @@ import React, { ReactElement, useCallback, useContext } from "react"; -import { Form, Field } from "react-final-form"; import { useDispatch } from "react-redux"; import { saveSettings, @@ -7,8 +6,8 @@ import { } from "../../../actions/settings.actions"; import { AirDCPPSettingsConfirmation } from "./AirDCPPSettingsConfirmation"; import { AirDCPPSocketContext } from "../../../context/AirDCPPSocket"; -import { isUndefined, isEmpty, isNil } from "lodash"; -import { hostNameValidator } from "../../../shared/utils/validator.utils"; +import { isUndefined, isEmpty } from "lodash"; +import { ConnectionForm } from "../../shared/ConnectionForm/ConnectionForm"; export const AirDCPPSettingsForm = (): ReactElement => { const dispatch = useDispatch(); @@ -26,7 +25,7 @@ export const AirDCPPSettingsForm = (): ReactElement => { airDCPPSettings.setSettings({}); dispatch(deleteSettings()); }, []); - const validate = async () => { }; + const initFormData = !isUndefined( airDCPPSettings.airDCPPState.settings.directConnect, ) @@ -35,94 +34,8 @@ export const AirDCPPSettingsForm = (): ReactElement => { return ( <> -
( - -

Configure AirDC++

- -
-

- - - - - - - -

-
- - {({ input, meta }) => ( -
- - {meta.error && meta.touched && ( - - {meta.error} - - )} -
- )} -
-
-

- -

-
-
- -
-
-

- - - - -

-
-
-

- - - - -

-
-
-
-
-

- -

-
-
- )} - /> + + {!isEmpty(airDCPPSettings.airDCPPState.socketConnectionInformation) ? ( { @@ -34,98 +33,11 @@ export const QbittorrentConnectionForm = (): ReactElement => { return ( <> - -
( - -

Configure Qbittorrent

- -
-

- - - - - - - -

-
- - {({ input, meta }) => ( -
- - {meta.error && meta.touched && ( - - {meta.error} - - )} -
- )} -
-
-

- -

-
- -
- -
-
-

- - - - -

-
-
-

- - - - -

-
-
-
- -
-

- -

-
-
- )} + -
 {JSON.stringify(torrents, null, 4)} 
+
 {torrents && JSON.stringify(torrents, null, 4)} 
); }; diff --git a/src/client/components/shared/ConnectionForm/ConnectionForm.tsx b/src/client/components/shared/ConnectionForm/ConnectionForm.tsx new file mode 100644 index 0000000..6b5db17 --- /dev/null +++ b/src/client/components/shared/ConnectionForm/ConnectionForm.tsx @@ -0,0 +1,101 @@ +import React, { ReactElement } from "react"; +import { Form, Field } from "react-final-form"; +import { hostNameValidator } from "../../../shared/utils/validator.utils"; +import { isEmpty } from "lodash"; + +export const ConnectionForm = ({ + initialData, + submitHandler, +}): ReactElement => { + return ( + <> +
( + +

Configure AirDC++

+ +
+

+ + + + + + + +

+
+ + {({ input, meta }) => ( +
+ + {meta.error && meta.touched && ( + + {meta.error} + + )} +
+ )} +
+
+

+ +

+
+
+ +
+
+

+ + + + +

+
+
+

+ + + + +

+
+
+
+
+

+ +

+
+
+ )} + /> + + ); +}; diff --git a/src/client/components/shared/Navbar.tsx b/src/client/components/shared/Navbar.tsx index 34b5f17..9c6792e 100644 --- a/src/client/components/shared/Navbar.tsx +++ b/src/client/components/shared/Navbar.tsx @@ -17,6 +17,9 @@ const Navbar: React.FunctionComponent = (props) => { const airDCPPSessionInfo = useSelector( (state: RootState) => state.airdcpp.airDCPPSessionInfo, ); + const qBittorrentConnectionInfo = useSelector( + (state: RootState) => state.settings.data, + ); const socketDisconnectionReason = useSelector( (state: RootState) => state.airdcpp.socketDisconnectionReason, );