import React from "react"; import "../../common/styles/productRow.css"; import StarRating from "../../common/starRating/StarRating"; import { API } from "aws-amplify"; import AddToCart from "../../common/AddToCart"; import FriendRecommendations from "../../common/friendRecommendations/FriendRecommendations"; import { Book } from "../bestSellers/BestSellerProductRow"; interface ProductRowProps { bookId: string; } interface ProductRowState { book: Book | undefined; } export class ProductRow extends React.Component { constructor(props: ProductRowProps) { super(props); this.state = { book: undefined, }; } componentDidMount() { API.get("books", `/books/${this.props.bookId}`, null) .then(response => this.setState({ book: response })) .catch(error => alert(error)); } render() { if (!this.state.book) return null; return (
{`${this.state.book.name}

{this.state.book.name} ${this.state.book.price}

{this.state.book.category}

Rating
); } } export default ProductRow;