CAdFeed.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 AdFeed=({_id, price,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. </Container>
  36. )
  37. }