diff --git a/frontend/src/views/Login/Login.tsx b/frontend/src/views/Login/Login.tsx index 16ea91718..0f3586238 100644 --- a/frontend/src/views/Login/Login.tsx +++ b/frontend/src/views/Login/Login.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { useRouter } from "next/router"; -import axios from "axios" +import axios from "axios"; import { fetchUserDetails } from "@app/hooks/api/users/queries"; import { getAuthToken, isLoggedIn } from "@app/reactQuery"; @@ -13,31 +13,36 @@ import { import { navigateUserToOrg } from "./Login.utils"; export const Login = () => { - const router = useRouter(); - const [step, setStep] = useState(0); - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); - - const queryParams = new URLSearchParams(window.location.search) - - useEffect(() => { + const router = useRouter(); + const [step, setStep] = useState(0); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + + const queryParams = new URLSearchParams(window.location.search); + + useEffect(() => { // TODO(akhilmhdh): workspace will be controlled by a workspace context const redirectToDashboard = async () => { + // TODO(daniel): Move this to select-organization page. try { // user details - const userDetails = await fetchUserDetails() + const userDetails = await fetchUserDetails(); // send details back to client if (queryParams && queryParams.get("callback_port")) { - const callbackPort = queryParams.get("callback_port") + const callbackPort = queryParams.get("callback_port"); // send post request to cli with details - const cliUrl = `http://127.0.0.1:${callbackPort}/` - const instance = axios.create() - await instance.post(cliUrl, { email: userDetails.email, privateKey: localStorage.getItem("PRIVATE_KEY"), JTWToken: getAuthToken() }) + const cliUrl = `http://127.0.0.1:${callbackPort}/`; + const instance = axios.create(); + await instance.post(cliUrl, { + email: userDetails.email, + privateKey: localStorage.getItem("PRIVATE_KEY"), + JTWToken: getAuthToken() + }); } - await navigateUserToOrg(router); + navigateUserToSelectOrg(router); } catch (error) { console.log("Error - Not logged in yet"); } @@ -80,10 +85,7 @@ export const Login = () => { return
; } } - - return ( -