2
0
mirror of synced 2025-02-24 12:58:25 +00:00
emizzle acc200fb52 reduced webpacked file size
moved getting of user details to highest level and sending data to lower level comps

add babel file
2018-07-03 16:31:10 +10:00

39 lines
1.2 KiB
JavaScript

import { withRouter } from 'react-router-dom'
import { Button, FormGroup, ControlLabel, FormControl, HelpBlock, Grid, Row, Col, Thumbnail } from 'react-bootstrap';
import React, { Component } from 'react';
import DoTweet from './DoTweet';
// The Header creates links that can be used to navigate
// between routes.
class Header extends Component{
constructor(props, context) {
super(props, context);
}
render(){
const {picture, username, description} = this.props.user;
const isEditable = Boolean(username);
let rendering = <Button onClick={(e) => {this.props.history.push('/create')}} bsStyle="primary">Create user</Button>
if(isEditable){
rendering = <Thumbnail src={picture} alt={username} onClick={isEditable ? (e) => {this.props.history.push('/update/@' + username)} : false}>
<h3>{username}</h3>
<p>{description}</p>
</Thumbnail>;
}
return (
<header>
<Grid>
<Row>
<Col xs={10}>
<DoTweet username={username} visible={isEditable}></DoTweet>
</Col>
<Col xs={2}>
{rendering}
</Col>
</Row>
</Grid>
</header>
);
}
}
export default withRouter(Header)