feat: initial commit
This commit is contained in:
19
src/component/BreadcumbComponent.js
Normal file
19
src/component/BreadcumbComponent.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import React from "react";
|
||||
import {Breadcrumb} from "antd";
|
||||
import {Link} from "react-router-dom";
|
||||
|
||||
export const BreadcumbComponent = (props) => {
|
||||
return (
|
||||
<div>
|
||||
<Breadcrumb style={{marginBottom: 10}}>
|
||||
{props.data.map((e) => (
|
||||
<Breadcrumb.Item>
|
||||
<Link to={e.route}>
|
||||
<span>{e.name}</span>
|
||||
</Link>
|
||||
</Breadcrumb.Item>
|
||||
))}
|
||||
</Breadcrumb>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
18
src/component/PrivateRoute.js
Normal file
18
src/component/PrivateRoute.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import {Redirect, Route} from 'react-router-dom';
|
||||
import {useStore} from "../utils/useStore";
|
||||
// import { isLogin } from '../utils';
|
||||
|
||||
export const PrivateRoute = ({component: Component, ...rest}) => {
|
||||
const store = useStore();
|
||||
return (
|
||||
|
||||
// Show the component only when the user is logged in
|
||||
// Otherwise, redirect the user to /signin page
|
||||
<Route {...rest} render={props => (
|
||||
store.authentication.isLoggedIn ?
|
||||
<Component {...props} />
|
||||
: <Redirect to="/login"/>
|
||||
)}/>
|
||||
);
|
||||
};
|
||||
18
src/component/PublicRoute.js
Normal file
18
src/component/PublicRoute.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import {Redirect, Route} from 'react-router-dom';
|
||||
import {useStore} from "../utils/useStore";
|
||||
|
||||
export const PublicRoute = ({component: Component, restricted, ...rest}) => {
|
||||
const store = useStore();
|
||||
|
||||
return (
|
||||
// restricted = false meaning public route
|
||||
// restricted = true meaning restricted route
|
||||
<Route {...rest} render={props => (
|
||||
store.authentication.isLoggedIn && restricted ?
|
||||
<Redirect to="/app"/>
|
||||
: <Component {...props} />
|
||||
)}/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user