🎉 Initial Commit

This commit is contained in:
Indrajith K L
2019-12-11 18:54:05 +05:30
parent 53e5edb3d9
commit 8988233da8
22 changed files with 14007 additions and 71 deletions

27
src/core/custom.router.js Normal file
View File

@@ -0,0 +1,27 @@
import React from "react";
import { Route, Redirect } from "react-router-dom";
import Storage from "../services/storage.service";
export const CustomRouter = ({ xComponent: Component, ...xProps }) => {
return (
<Route
{...xProps}
render={props => {
console.log(props.permissions)
let token = Storage.get("token");
let pathName = props.match.path;
if (!token && pathName !== "/login") {
return <Redirect to="/login" />;
} else if (pathName === "/login" && token) {
return <Redirect to="/dashboard" />;
}else if (pathName === "/" && token) {
return <Redirect to="/dashboard" />;
}
debugger
return <Component {...props} />;
}}
/>
);
};