Revert "Refactor code and fix formatting issues"
This reverts commit 334ec24addf783990850b835d911ac778dfce6a2.
This commit is contained in:
parent
f8f71fb603
commit
c7435c0c49
8 changed files with 26 additions and 12 deletions
|
|
@ -300,7 +300,7 @@ export default function ParameterComponent({
|
|||
) : (
|
||||
<div
|
||||
ref={ref}
|
||||
className="relative mt-1 flex w-full flex-wrap items-center justify-between bg-muted px-5 py-2"
|
||||
className="mt-1 flex w-full flex-wrap items-center justify-between relative bg-muted px-5 py-2"
|
||||
>
|
||||
<>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
import { useContext } from "react";
|
||||
import { useContext, useEffect } from "react";
|
||||
import { Navigate } from "react-router-dom";
|
||||
import { AuthContext } from "../../contexts/authContext";
|
||||
|
||||
export const ProtectedAdminRoute = ({ children }) => {
|
||||
const { isAdmin, isAuthenticated, logout, userData, autoLogin } =
|
||||
useContext(AuthContext);
|
||||
const {
|
||||
isAdmin,
|
||||
isAuthenticated,
|
||||
logout,
|
||||
userData,
|
||||
autoLogin,
|
||||
} = useContext(AuthContext);
|
||||
|
||||
if (!isAuthenticated) {
|
||||
logout();
|
||||
|
|
|
|||
|
|
@ -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 <Navigate to="/login" replace />;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ import ReactFlow, {
|
|||
SelectionDragHandler,
|
||||
addEdge,
|
||||
updateEdge,
|
||||
useEdgesState,
|
||||
useNodesState,
|
||||
} from "reactflow";
|
||||
import GenericNode from "../../../../CustomNodes/GenericNode";
|
||||
import Chat from "../../../../components/chatComponent";
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue