Initial git

This commit is contained in:
Qolzam
2017-07-06 11:20:18 +04:30
commit 7c691d8e4d
142 changed files with 13046 additions and 0 deletions

30
app/api/AuthRouterAPI.jsx Normal file
View File

@@ -0,0 +1,30 @@
// - Import react components
import React, {Component} from 'react'
import {Route, Redirect} from 'react-router-dom'
// - Import API
import * as AuthAPI from 'AuthAPI'
export var PrivateRoute = ({component: Component, ...rest}) => {
console.log('is auth ; ', AuthAPI.isAuthorized());
return (
<Route
{...rest}
render={(props) => AuthAPI.isAuthorized()
? <Component {...props} />
: <Redirect to={{pathname: '/login', state: {from: props.location}}} />}
/>
)
}
export var PublicRoute = ({component: Component,...rest}) => {
return (
<Route
{...rest}
render={(props) => !(AuthRouterAPI.isAuthorized())
? <Component {...props} />
: <Redirect to='/' />}
/>
)
}