import React from "react"; import { API } from "aws-amplify"; import AddToCart from "../../common/AddToCart"; import FriendRecommendations from "../../common/friendRecommendations/FriendRecommendations"; import StarRating from "../../common/starRating/StarRating"; import "../../common/styles/productRow.css"; interface ProductRowProps { bookId: string; } export interface Book { id: string; cover: string; price: number; category: string; name: string; rating: number; author: string; } interface ProductRowState { book: Book | undefined; } export class ProductRow extends React.Component { constructor(props: ProductRowProps) { super(props); this.state = { book: undefined, }; } async componentDidMount() { try { const book = await this.getBook(); this.setState({ book }); } catch (e) { alert(e); } } getBook() { return API.get("books", `/books/${this.props.bookId}`, null); } 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;