import React from "react"; import { Route, Redirect } from "react-router-dom"; import Storage from "../services/storage.service"; import Permissions from "./permission.router"; import { RandomKey } from "../utils/random.key"; export const CustomRouter = ({ xComponent: Component, ...xProps }) => { return ( { let returnProps = {...xProps, ...props}; let token = Storage.get("token"); let pathName = props.match.path; if (!token && pathName !== "/login") { return ; } else if (pathName === "/login" && token) { return ; }else if (pathName === "/" && token) { return ; } return ; }} /> ); };