Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. import React from "react";
  2. import Link from "next/link";
  3. import PropTypes from "prop-types";
  4. import formatMoney from "../lib/formatMoney";
  5. import Title from "../components/styles/Title";
  6. import ItemStyles from "../components/styles/ItemStyles";
  7. import PriceTag from "../components/styles/PriceTag";
  8. import DeleteItem from "../components/DeleteItem";
  9. import AddToCart from "../components/AddToCart";
  10.  
  11. export default class Item extends React.Component {
  12. static propTypes = {
  13. item: PropTypes.shape({
  14. id: PropTypes.string.isRequired,
  15. title: PropTypes.string.isRequired,
  16. price: PropTypes.number.isRequired,
  17. description: PropTypes.string.isRequired,
  18. image: PropTypes.string,
  19. largeImage: PropTypes.string
  20. })
  21. };
  22.  
  23. render() {
  24. const { item } = this.props;
  25. return (
  26. <ItemStyles>
  27. {item.image && <img src={item.image} alt={item.title} />}
  28. <Title>
  29. <Link
  30. href={{
  31. pathname: "/item",
  32. query: { id: item.id }
  33. }}
  34. >
  35. <a>{item.title}</a>
  36. </Link>
  37. </Title>
  38. <PriceTag>{formatMoney(item.price)}</PriceTag>
  39. <p>{item.description}</p>
  40.  
  41. <div className="buttonList">
  42. <Link
  43. href={{
  44. pathname: "update",
  45. query: { id: item.id }
  46. }}
  47. >
  48. <a>Edit</a>
  49. </Link>
  50. <AddToCart id={item.id} />
  51. <DeleteItem id={item.id}>Delete This Thing</DeleteItem>
  52. </div>
  53. </ItemStyles>
  54. );
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement