import PropTypes from 'prop-types'; import React, { useState } from 'react'; import StarRatings from 'react-star-ratings'; import { Card, Row, Col } from 'react-bootstrap'; import AmazonURL from '../components/amazonurl'; import Bookmark from '../components/bookmark'; import GoodReadsImage from '../components/goodreadsimage'; const truncateContent = (content) => { if (!content) { return ''; } return content.length > 350 ? content.substring(0, 350) + '...' : content; }; const showFullText = (content) => { if (!content) { return ''; } return content; }; const BookCard = ({ book }) => { const [ show, toggleShow ] = useState(false); return ( {book.title} {book.author} {book.year ? book.year : null}
{book.amazon_url ? : null}

{!show && truncateContent(book.description)} {show && showFullText(book.description)}

{!show && book.description.length>350 &&( )} {show && ( )}
); }; BookCard.propTypes = { siteTitle: PropTypes.object }; BookCard.defaultProps = { book: {} }; export default BookCard;