Advertisement
Guest User

Untitled

a guest
May 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import React from "react";
  2. import axios from "axios";
  3.  
  4. import moment from "moment";
  5.  
  6. import {
  7. Container,
  8. Row,
  9. Col,
  10. Card,
  11. CardText,
  12. CardBody,
  13. CardLink,
  14. CardTitle,
  15. CardSubtitle,
  16. Button
  17. } from "reactstrap";
  18.  
  19. import "./Article.css";
  20.  
  21. this.handleDelete = this.handleDelete.bind(this);
  22.  
  23. handleDelete(_id) {
  24. axios
  25. .delete(`http://localhost:3000/${_id}`)
  26. .then( function(response) {
  27. toast.success("Successfully deleted article.");
  28. this.setState({ artcles: res.data.articles });
  29. })
  30. .catch( () => toast.error("Failed to delete article.") );
  31. }
  32.  
  33. const Article = props => {
  34. const { title, author, date, url, votes } = props;
  35. return (
  36. <Container>
  37. <Row>
  38. <Col>
  39. <Card>
  40. <CardBody>
  41. <a href={url}>
  42. <CardTitle className="naslov">{title}</CardTitle>
  43. </a>
  44. <CardSubtitle className="autor">Author: {author}</CardSubtitle>
  45. </CardBody>
  46. <CardBody>
  47. <CardText className="glas">Votes: {votes}</CardText>
  48. <CardText>
  49. {moment(date).format("dddd, MMMM Do YYYY, h:mm:ss a")}
  50. </CardText>
  51. <Button color="danger" onClick={this.handleDelete}>
  52. Delete
  53. </Button>
  54. </CardBody>
  55. </Card>
  56. </Col>
  57. </Row>
  58. </Container>
  59. );
  60. };
  61.  
  62. export default Article;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement