Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

62 строки
2.0 KiB

  1. import React, { useState, useEffect } from 'react';
  2. import Router, { withRouter } from 'next/router'
  3. // @material-ui/core components
  4. import { makeStyles } from "@material-ui/core/styles";
  5. import ReactPaginate from 'react-paginate';
  6. // component
  7. import styles from "assets/jss/nextjs-material-kit/pages/componentsSections/notificationsStyles.js";
  8. import Paginations from "components/Pagination/Pagination.js";
  9. const useStyles = makeStyles(styles);
  10. const DataLatestNews = function ({ backend, news, ...props }) {
  11. const [isLoading, setLoading] = useState(false); //State for the loading indicator
  12. const startLoading = () => setLoading(true);
  13. const stopLoading = () => setLoading(false);
  14. useEffect(() => { //After the component is mounted set router event handlers
  15. Router.events.on('routeChangeStart', startLoading);
  16. Router.events.on('routeChangeComplete', stopLoading);
  17. return () => {
  18. Router.events.off('routeChangeStart', startLoading);
  19. Router.events.off('routeChangeComplete', stopLoading);
  20. }
  21. }, [])
  22. const pagginationHandler = (page) => {
  23. const currentPath = props.router.pathname;
  24. const currentQuery = props.router.query;
  25. currentQuery.page = page.selected + 1;
  26. props.router.push({
  27. pathname: currentPath,
  28. query: currentQuery,
  29. });
  30. };
  31. const classes = useStyles();
  32. const latnews = news.map((data) => {
  33. return (
  34. <div className={classes.section} style={{padding:"40px"}}>
  35. <div align="center" style={{marginTop:"-40px"}}>
  36. <h2>{data.title}</h2>
  37. </div><br></br><br></br>
  38. <div align="center">
  39. <img src={`${backend}${data.img[0]["url"]}`} alt="First slide" className="slick-image" />
  40. </div><br></br><br></br>
  41. <h5 align="justify">
  42. {data.description}
  43. </h5>
  44. </div>
  45. );
  46. })
  47. return (
  48. <div>
  49. {latnews}
  50. </div>
  51. );
  52. }
  53. export default DataLatestNews;