Download TravelYaari-react/src/auth/AdminRoute.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 675 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/TravelYaari-react/src/auth/AdminRoute.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/TravelYaari-react/src/auth/AdminRoute.js
-
curl -L -o AdminRoute.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/TravelYaari-react/src/auth/AdminRoute.js
675 Bytes
| /* eslint-disable no-unused-vars */ | |
| import React, { Component } from "react"; | |
| import { Route, Redirect } from "react-router-dom"; | |
| import { isAuthenticated } from "./index"; | |
| const AdminRoute = ({ component: Component, ...rest }) => ( | |
| <Route | |
| {...rest} | |
| render={props => | |
| isAuthenticated() && isAuthenticated().user.role === 1 ? ( | |
| <Component {...props} /> | |
| ) : ( | |
| <Redirect | |
| to={{ | |
| pathname: "/signin", | |
| state: { from: props.location } | |
| }} | |
| /> | |
| ) | |
| } | |
| /> | |
| ); | |
| export default AdminRoute; | |