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"; import { Order } from "../cart/CartProductRow"; interface PurchasedProductRowProps { order: Order; } interface PurchasedProductRowState { book: Book | undefined; } export class PurchasedProductRow extends React.Component { constructor(props: PurchasedProductRowProps) { super(props); this.state = { book: undefined }; } async componentDidMount() { try { const book = await this.getBook(this.props.order); this.setState({ book }); } catch (e) { alert(e); } } getBook(order: Order) { return API.get("books", `/books/${order.bookId}`, null); } render() { if (!this.state.book) { return (
); } return (
{`${this.state.book.name}

{this.state.book.name}
{`${this.props.order.quantity} @ ${this.state.book.price}`}

{this.state.book.category}
Rating
); } } export default PurchasedProductRow;