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
|
<div
|
||||||
ref={ref}
|
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
|
<div
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
import { useContext } from "react";
|
import { useContext, useEffect } from "react";
|
||||||
import { Navigate } from "react-router-dom";
|
import { Navigate } from "react-router-dom";
|
||||||
import { AuthContext } from "../../contexts/authContext";
|
import { AuthContext } from "../../contexts/authContext";
|
||||||
|
|
||||||
export const ProtectedAdminRoute = ({ children }) => {
|
export const ProtectedAdminRoute = ({ children }) => {
|
||||||
const { isAdmin, isAuthenticated, logout, userData, autoLogin } =
|
const {
|
||||||
useContext(AuthContext);
|
isAdmin,
|
||||||
|
isAuthenticated,
|
||||||
|
logout,
|
||||||
|
userData,
|
||||||
|
autoLogin,
|
||||||
|
} = useContext(AuthContext);
|
||||||
|
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
logout();
|
logout();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ import { Navigate } from "react-router-dom";
|
||||||
import { AuthContext } from "../../contexts/authContext";
|
import { AuthContext } from "../../contexts/authContext";
|
||||||
|
|
||||||
export const ProtectedRoute = ({ children }) => {
|
export const ProtectedRoute = ({ children }) => {
|
||||||
const { isAuthenticated, logout } = useContext(AuthContext);
|
const { isAuthenticated, logout} =
|
||||||
|
useContext(AuthContext);
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
logout();
|
logout();
|
||||||
return <Navigate to="/login" replace />;
|
return <Navigate to="/login" replace />;
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ export function AuthProvider({ children }): React.ReactElement {
|
||||||
});
|
});
|
||||||
}, [setUserData, setLoading, autoLogin, setIsAdmin]);
|
}, [setUserData, setLoading, autoLogin, setIsAdmin]);
|
||||||
|
|
||||||
function getUser() {
|
function getUser(){
|
||||||
getLoggedUser()
|
getLoggedUser()
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
setUserData(user);
|
setUserData(user);
|
||||||
|
|
@ -101,9 +101,8 @@ export function AuthProvider({ children }): React.ReactElement {
|
||||||
setAccessToken(newAccessToken);
|
setAccessToken(newAccessToken);
|
||||||
setRefreshToken(refreshToken);
|
setRefreshToken(refreshToken);
|
||||||
setIsAuthenticated(true);
|
setIsAuthenticated(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {getUser();}, 500)
|
||||||
getUser();
|
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,16 @@
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { createContext, ReactNode, useState } from "react";
|
import {
|
||||||
|
createContext,
|
||||||
|
ReactNode,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
import { getAll, getHealth } from "../controllers/API";
|
import { getAll, getHealth } from "../controllers/API";
|
||||||
import useAlertStore from "../stores/alertStore";
|
import useAlertStore from "../stores/alertStore";
|
||||||
import { APIKindType } from "../types/api";
|
import { APIKindType } from "../types/api";
|
||||||
import { typesContextType } from "../types/typesContext";
|
import { typesContextType } from "../types/typesContext";
|
||||||
|
import { AuthContext } from "./authContext";
|
||||||
|
|
||||||
//context to share types adn functions from nodes to flow
|
//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 { Input } from "../../../components/ui/input";
|
||||||
import { CONTROL_LOGIN_STATE } from "../../../constants/constants";
|
import { CONTROL_LOGIN_STATE } from "../../../constants/constants";
|
||||||
import { AuthContext } from "../../../contexts/authContext";
|
import { AuthContext } from "../../../contexts/authContext";
|
||||||
import { onLogin } from "../../../controllers/API";
|
import { getLoggedUser, onLogin } from "../../../controllers/API";
|
||||||
import useAlertStore from "../../../stores/alertStore";
|
import useAlertStore from "../../../stores/alertStore";
|
||||||
import { LoginType } from "../../../types/api";
|
import { LoginType } from "../../../types/api";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ import ReactFlow, {
|
||||||
SelectionDragHandler,
|
SelectionDragHandler,
|
||||||
addEdge,
|
addEdge,
|
||||||
updateEdge,
|
updateEdge,
|
||||||
|
useEdgesState,
|
||||||
|
useNodesState,
|
||||||
} from "reactflow";
|
} from "reactflow";
|
||||||
import GenericNode from "../../../../CustomNodes/GenericNode";
|
import GenericNode from "../../../../CustomNodes/GenericNode";
|
||||||
import Chat from "../../../../components/chatComponent";
|
import Chat from "../../../../components/chatComponent";
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { Button } from "../../components/ui/button";
|
||||||
import { Input } from "../../components/ui/input";
|
import { Input } from "../../components/ui/input";
|
||||||
import { CONTROL_LOGIN_STATE } from "../../constants/constants";
|
import { CONTROL_LOGIN_STATE } from "../../constants/constants";
|
||||||
import { AuthContext } from "../../contexts/authContext";
|
import { AuthContext } from "../../contexts/authContext";
|
||||||
import { onLogin } from "../../controllers/API";
|
import { getLoggedUser, onLogin } from "../../controllers/API";
|
||||||
import useAlertStore from "../../stores/alertStore";
|
import useAlertStore from "../../stores/alertStore";
|
||||||
import { LoginType } from "../../types/api";
|
import { LoginType } from "../../types/api";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue