Guest User

Untitled

a guest
Jul 23rd, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. interface Props {
  2.     children?: React.ReactNode;
  3.     Auth: AuthService,
  4.     logout: boolean
  5. }
  6.  
  7. export class AdminLayout extends React.Component<any,Props> {
  8.     constructor(props) {
  9.         super(props);
  10.         this.state = {
  11.             Auth: new AuthService(),
  12.             logout: false
  13.         }
  14.        
  15.        
  16.     }
  17.     onLogout = (logout) => {
  18.         this.setState({
  19.             logout
  20.         });
  21.       }
  22.  
  23.    
  24.     public render() {
  25.         const {Auth, logout} = this.state;
  26.         if(!Auth.loggedIn() || logout ){
  27.            
  28.             return (<Redirect to="/admin/login" />);
  29.         }
  30.         else
  31.         return<span>
  32.             <AdminHeader logoutC={this.onLogout} />
  33.             <div className='container blog-container'>
  34.          
  35.                  { this.props.children }
  36.              
  37.            
  38.         </div>
  39.         </span>;
  40.     }
  41. }
  42.  
  43. export class AdminHeader extends React.Component{
  44.     constructor(props) {
  45.         super(props);
  46.        
  47.         this.handleLogout = this.handleLogout.bind(this);
  48.     }
  49.     handleLogout(){
  50.        
  51.       /nie wiem co tutaj
  52.     }
  53.  
  54.     render() {
  55.  
  56.         return(
  57.            
  58.                     <input
  59.                         value="Wyloguj"
  60.                         name="logout"
  61.                         type="button"
  62.                         onClick={this.handleLogout}
  63.                     />
  64.      
  65.         )}
  66. }
Advertisement
Add Comment
Please, Sign In to add comment