import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import { openModal } from '../actions/modal' import { CX, MODAL_ALBUM_CREATE, } from '../constants' import Button from './button' import Icon from './icon' import Image from './image' import Text from './text' class Album extends React.PureComponent { handleOnOpenAlbumCreate = () => { this.props.openAlbumCreate() } render() { const { account, album, isAddable, } = this.props if (!isAddable && (!album || !account)) return null const title = isAddable ? 'New album' : album.get('title') const subtitle = isAddable ? '' : `${album.get('count')} Items` const to = isAddable ? undefined : `/${account.get('username')}/albums/${album.get('id')}` const albumImageUrl = !!album ? album.getIn(['cover', 'preview_url'], null) : null return (
) } } Album.propTypes = { account: ImmutablePropTypes.map, album: ImmutablePropTypes.map, isAddable: PropTypes.bool, } const mapStateToProps = (state, { albumId }) => ({ album: state.getIn(['albums', albumId]), }) const mapDispatchToProps = (dispatch) => ({ openAlbumCreate() { dispatch(openModal(MODAL_ALBUM_CREATE)) } }) export default connect(mapStateToProps, mapDispatchToProps)(Album)