diff --git a/src/Main.tsx b/src/Main.tsx index 6ac42dd..f27bfca 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -24,6 +24,8 @@ enum Step { LoadSuccess, Authentication, Home, + LoginSuccess, + LoginError, FactoryReset, } @@ -35,6 +37,7 @@ const Main = () => { const [isModalVisible, setIsModalVisible] = useState(false); const [step, setStep] = useState(Step.Discovery); const [pinCounter, setPinCounter] = useState(PIN_MAX_RETRY); + const [errorMessage, setErrorMessage] = useState(""); const didMount = useRef(false); const stepRef = useRef(step); @@ -178,12 +181,14 @@ const Main = () => { const respJson = await resp.json(); if (respJson['error']) { - //TODO: handle error + setErrorMessage(respJson['error']); + setStep(Step.LoginError); } - //TODO: handle success + setStep(Step.LoginSuccess) } catch (e) { - //TODO: handle error + setErrorMessage("Login failed. Please try again."); + setStep(Step.LoginError); } } } @@ -303,6 +308,8 @@ const Main = () => { {step == Step.Authentication && } {step == Step.Home && } {step == Step.FactoryReset && } + {step == Step.LoginSuccess && } + {step == Step.LoginError && } );