diff --git a/backend-mock/setup.js b/backend-mock/setup.js index 5acad1cc..54fd20d2 100644 --- a/backend-mock/setup.js +++ b/backend-mock/setup.js @@ -12,6 +12,16 @@ router.get("/status", function (req, res) { initialsync: "", }) ); + + // Syncscreen + // res.status(200).send( + // JSON.stringify({ + // setupPhase: "", + // state: "ready", + // message: "Node Running", + // initialsync: "running", + // }) + // ); }); router.get("/setup-start-info", function (req, res) { @@ -54,7 +64,20 @@ router.get("/shutdown", function (req, res) { router.post("/setup-sync-info", function (req, res) { console.info(`call to ${req.originalUrl}`); - res.send(true); + res.status(200).send( + JSON.stringify({ + initialsync: "", + btc_default: "1", + btc_default_ready: "1", + btc_default_sync_percentage: "20", + btc_default_peers: "3", + system_count_start_blockchain: "1", + ln_default: "1", + ln_default_ready: "1", + ln_default_locked: "1", + system_count_start_lightning: "3", + }) + ); }); module.exports = router; diff --git a/src/components/Setup/SyncScreen.tsx b/src/components/Setup/SyncScreen.tsx index 61c5f406..ce96d515 100644 --- a/src/components/Setup/SyncScreen.tsx +++ b/src/components/Setup/SyncScreen.tsx @@ -1,12 +1,15 @@ import { ChangeEvent, FC, useState } from "react"; +import { useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; -import LoadingSpinner from "../../components/Shared/LoadingSpinner/LoadingSpinner"; +import { ReactComponent as CheckCircleIcon } from "../../assets/check-circle.svg"; +import { ReactComponent as XCircleIcon } from "../../assets/x-circle.svg"; +import Message from "../../container/Message/Message"; import ProgressCircle from "../../container/ProgressCircle/ProgressCircle"; import SetupContainer from "../../container/SetupContainer/SetupContainer"; import { instance } from "../../util/interceptor"; -import { ReactComponent as CheckCircleIcon } from "../../assets/check-circle.svg"; -import { ReactComponent as XCircleIcon } from "../../assets/x-circle.svg"; +import ButtonWithSpinner from "../Shared/ButtonWithSpinner/ButtonWithSpinner"; +import InputField from "../Shared/InputField/InputField"; export interface InputData { data: SyncData | any; @@ -26,12 +29,17 @@ interface SyncData { system_count_start_lightning: string; } +interface IFormInputs { + passwordInput: string; +} + const SyncScreen: FC = ({ data, callback }) => { const { t } = useTranslation(); const navigate = useNavigate(); const [password, setPassword] = useState(""); const [runningUnlock, setRunningUnlock] = useState(false); + const [passwordWrong, setPasswordWrong] = useState(false); const changePasswordHandler = (event: ChangeEvent) => { setPassword(event.target.value); @@ -39,6 +47,7 @@ const SyncScreen: FC = ({ data, callback }) => { const unlockWallet = async () => { setRunningUnlock(true); + setPasswordWrong(false); await instance .post("/lightning/unlock-wallet", { password: password, @@ -47,9 +56,9 @@ const SyncScreen: FC = ({ data, callback }) => { if (err.response.status === 403) { navigate("/login?back=/setup"); } else { - console.log("error on unlock wallet"); setPassword(""); setRunningUnlock(false); + setPasswordWrong(true); } }); // TODO: Why setRunningUnlock always after 30s? @@ -59,6 +68,14 @@ const SyncScreen: FC = ({ data, callback }) => { }, 30000); }; + const { + register, + handleSubmit, + formState: { errors, isValid }, + } = useForm({ + mode: "onChange", + }); + return (
@@ -99,33 +116,34 @@ const SyncScreen: FC = ({ data, callback }) => { )} {data.ln_default && data.ln_default !== "none" && - data.ln_default_locked !== "0" && - !runningUnlock && ( -
- - + - -
+ + )} - {runningUnlock && ( -
- -
- )} + {passwordWrong && }
diff --git a/src/components/Shared/I18nDropdown/I18nDropdown.tsx b/src/components/Shared/I18nDropdown/I18nDropdown.tsx index 983ca974..7bee82b3 100644 --- a/src/components/Shared/I18nDropdown/I18nDropdown.tsx +++ b/src/components/Shared/I18nDropdown/I18nDropdown.tsx @@ -24,7 +24,10 @@ const I18nDropdown: FC = () => { return (
-