"index.95b450a5.css" did not exist on "21f2ec79fd3aae764d224b7a095c3ed696207c46"
AuthorizedRoute.js 744 Bytes
Newer Older
ddcat1115's avatar
ddcat1115 committed
1
import React from 'react';
2
import { Route, Redirect } from 'react-router-dom';
ddcat1115's avatar
ddcat1115 committed
3 4 5 6
import Authorized from './Authorized';

class AuthorizedRoute extends React.Component {
  render() {
7 8 9 10 11 12 13
    const {
      component: Component,
      render,
      authority,
      redirectPath,
      ...rest
    } = this.props;
ddcat1115's avatar
ddcat1115 committed
14 15 16
    return (
      <Authorized
        authority={authority}
17 18 19 20 21 22
        noMatch={
          <Route
            {...rest}
            render={() => <Redirect to={{ pathname: redirectPath }} />}
          />
        }
ddcat1115's avatar
ddcat1115 committed
23 24 25
      >
        <Route
          {...rest}
26 27 28
          render={props =>
            (Component ? <Component {...props} /> : render(props))
          }
ddcat1115's avatar
ddcat1115 committed
29 30 31 32 33 34 35
        />
      </Authorized>
    );
  }
}

export default AuthorizedRoute;