// - Import react components import React, { Component } from 'react' import { withRouter } from 'react-router-dom'; import { connect } from 'react-redux' import PropTypes from 'prop-types' import { Card, CardActions, CardHeader, CardMedia, CardTitle, CardText } from 'material-ui/Card' import FlatButton from 'material-ui/FlatButton' import { grey400, grey800, darkBlack, lightBlack } from 'material-ui/styles/colors' import SvgCamera from 'material-ui/svg-icons/image/photo-camera' import Paper from 'material-ui/Paper' import { List, ListItem } from 'material-ui/List' // - Import app components import Post from 'Post' import PostWrite from 'PostWrite' import UserAvatar from 'UserAvatar' // - Import API import * as AuthAPI from 'AuthAPI' import * as PostAPI from 'PostAPI' // - Import actions import * as globalActions from 'globalActions' // - Create Blog component class export class Blog extends Component { static propTypes = { /** * If it's true , writing post block will be visible */ displayWriting: PropTypes.bool.isRequired, /** * A list of post */ posts: PropTypes.object, } /** * Component constructor * @param {object} props is an object properties of component */ constructor(props) { super(props) this.state = { /** * It's true if we want to have two column of posts */ divided: false, /** * If it's true comment will be disabled on post */ disableComments: this.props.disableComments, /** * If it's true share will be disabled on post */ disableSharing: this.props.disableSharing, /** * If it's true, post write will be open */ openPostWrite: false, /** * The title of home header */ homeTitle: PropTypes.string } // Binding functions to `this` this.postLoad = this.postLoad.bind(this) this.handleOpenPostWrite = this.handleOpenPostWrite.bind(this) this.handleClosePostWrite = this.handleClosePostWrite.bind(this) } /** * Open post write * * * @memberof Blog */ handleOpenPostWrite = () => { this.setState({ openPostWrite: true }) } /** * Close post write * * * @memberof Blog */ handleClosePostWrite = () => { this.setState({ openPostWrite: false }) } /** * Create a list of posts * @return {DOM} posts */ postLoad = () => { let { posts,match } = this.props let {tag} = match.params if (posts === undefined || !Object.keys(posts).length > 0) { return (