Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from "react";
- import Link from "next/link";
- import PropTypes from "prop-types";
- import formatMoney from "../lib/formatMoney";
- import Title from "../components/styles/Title";
- import ItemStyles from "../components/styles/ItemStyles";
- import PriceTag from "../components/styles/PriceTag";
- import DeleteItem from "../components/DeleteItem";
- import AddToCart from "../components/AddToCart";
- export default class Item extends React.Component {
- static propTypes = {
- item: PropTypes.shape({
- id: PropTypes.string.isRequired,
- title: PropTypes.string.isRequired,
- price: PropTypes.number.isRequired,
- description: PropTypes.string.isRequired,
- image: PropTypes.string,
- largeImage: PropTypes.string
- })
- };
- render() {
- const { item } = this.props;
- return (
- <ItemStyles>
- {item.image && <img src={item.image} alt={item.title} />}
- <Title>
- <Link
- href={{
- pathname: "/item",
- query: { id: item.id }
- }}
- >
- <a>{item.title}</a>
- </Link>
- </Title>
- <PriceTag>{formatMoney(item.price)}</PriceTag>
- <p>{item.description}</p>
- <div className="buttonList">
- <Link
- href={{
- pathname: "update",
- query: { id: item.id }
- }}
- >
- <a>Edit</a>
- </Link>
- <AddToCart id={item.id} />
- <DeleteItem id={item.id}>Delete This Thing</DeleteItem>
- </div>
- </ItemStyles>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement