diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 06f9d0b0a..b688fdb7b 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -300,7 +300,7 @@ export default function ParameterComponent({ ) : (
<>
{ - const { isAdmin, isAuthenticated, logout, userData, autoLogin } = - useContext(AuthContext); + const { + isAdmin, + isAuthenticated, + logout, + userData, + autoLogin, + } = useContext(AuthContext); if (!isAuthenticated) { logout(); diff --git a/src/frontend/src/components/authGuard/index.tsx b/src/frontend/src/components/authGuard/index.tsx index 93735e977..713862e00 100644 --- a/src/frontend/src/components/authGuard/index.tsx +++ b/src/frontend/src/components/authGuard/index.tsx @@ -3,7 +3,8 @@ import { Navigate } from "react-router-dom"; import { AuthContext } from "../../contexts/authContext"; export const ProtectedRoute = ({ children }) => { - const { isAuthenticated, logout } = useContext(AuthContext); + const { isAuthenticated, logout} = + useContext(AuthContext); if (!isAuthenticated) { logout(); return ; diff --git a/src/frontend/src/contexts/authContext.tsx b/src/frontend/src/contexts/authContext.tsx index 74969d9f2..e00ac93b6 100644 --- a/src/frontend/src/contexts/authContext.tsx +++ b/src/frontend/src/contexts/authContext.tsx @@ -81,7 +81,7 @@ export function AuthProvider({ children }): React.ReactElement { }); }, [setUserData, setLoading, autoLogin, setIsAdmin]); - function getUser() { + function getUser(){ getLoggedUser() .then((user) => { setUserData(user); @@ -101,9 +101,8 @@ export function AuthProvider({ children }): React.ReactElement { setAccessToken(newAccessToken); setRefreshToken(refreshToken); setIsAuthenticated(true); - setTimeout(() => { - getUser(); - }, 500); + setTimeout(() => {getUser();}, 500) + } function logout() { diff --git a/src/frontend/src/contexts/typesContext.tsx b/src/frontend/src/contexts/typesContext.tsx index c785495aa..16deecf00 100644 --- a/src/frontend/src/contexts/typesContext.tsx +++ b/src/frontend/src/contexts/typesContext.tsx @@ -1,9 +1,16 @@ import _ from "lodash"; -import { createContext, ReactNode, useState } from "react"; +import { + createContext, + ReactNode, + useContext, + useEffect, + useState, +} from "react"; import { getAll, getHealth } from "../controllers/API"; import useAlertStore from "../stores/alertStore"; import { APIKindType } from "../types/api"; import { typesContextType } from "../types/typesContext"; +import { AuthContext } from "./authContext"; //context to share types adn functions from nodes to flow diff --git a/src/frontend/src/pages/AdminPage/LoginPage/index.tsx b/src/frontend/src/pages/AdminPage/LoginPage/index.tsx index 765567ca9..3d0530932 100644 --- a/src/frontend/src/pages/AdminPage/LoginPage/index.tsx +++ b/src/frontend/src/pages/AdminPage/LoginPage/index.tsx @@ -4,7 +4,7 @@ import { Button } from "../../../components/ui/button"; import { Input } from "../../../components/ui/input"; import { CONTROL_LOGIN_STATE } from "../../../constants/constants"; import { AuthContext } from "../../../contexts/authContext"; -import { onLogin } from "../../../controllers/API"; +import { getLoggedUser, onLogin } from "../../../controllers/API"; import useAlertStore from "../../../stores/alertStore"; import { LoginType } from "../../../types/api"; import { diff --git a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx index 9f94871f6..d4b2b8e3b 100644 --- a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx @@ -18,6 +18,8 @@ import ReactFlow, { SelectionDragHandler, addEdge, updateEdge, + useEdgesState, + useNodesState, } from "reactflow"; import GenericNode from "../../../../CustomNodes/GenericNode"; import Chat from "../../../../components/chatComponent"; diff --git a/src/frontend/src/pages/loginPage/index.tsx b/src/frontend/src/pages/loginPage/index.tsx index 1c005da58..c8dc0815c 100644 --- a/src/frontend/src/pages/loginPage/index.tsx +++ b/src/frontend/src/pages/loginPage/index.tsx @@ -6,7 +6,7 @@ import { Button } from "../../components/ui/button"; import { Input } from "../../components/ui/input"; import { CONTROL_LOGIN_STATE } from "../../constants/constants"; import { AuthContext } from "../../contexts/authContext"; -import { onLogin } from "../../controllers/API"; +import { getLoggedUser, onLogin } from "../../controllers/API"; import useAlertStore from "../../stores/alertStore"; import { LoginType } from "../../types/api"; import {