MyPosts.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from "react";
  2. import {Link} from 'react-router-dom';
  3. import { Container } from "react-bootstrap";
  4. import nofoto from '../images/placeholder.png'
  5. export const MyFeed=({_id, price, owner,title,description,images,comments,createdAt}) => {
  6. function timeConverter(t){
  7. let a = new Date(+t);
  8. let months = ['Января','Февраля','Марта','Апреля','Мая','Июня','Июля','Августа','Сентября','Октября','Ноября','Декабря'];
  9. let year = a.getFullYear();
  10. let month = months[a.getMonth()];
  11. let date = a.getDate();
  12. let hour = a.getHours();
  13. let min = a.getMinutes();
  14. let sec = a.getSeconds();
  15. let time = date + ' ' + month + ' ' + year + ' в ' + hour + ':' + min ;
  16. return time;
  17. }
  18. return (
  19. <Container>
  20. <div className="row ad">
  21. <div className="col img">
  22. {images ?
  23. <img src = {`http://marketplace.asmer.fs.a-level.com.ua/${images[0]?.url}`} />
  24. : <img src={nofoto} />
  25. }
  26. </div>
  27. <div className="col-6" info>
  28. <Link to={ `/home/${_id}`}>{title}</Link>
  29. <p>{description}</p>
  30. </div>
  31. <div className="col price">
  32. <p>{`${price ? price : "0"} грн.`}</p>
  33. </div>
  34. <div>
  35. <Link className='href' to={`/home/edit/${_id}`}>Редактировать</Link>
  36. </div>
  37. </div>
  38. </Container>
  39. )
  40. }