2021-12-22 08:07:43 +00:00
|
|
|
// IMPORT MODULES
|
|
|
|
|
import React, { useState, useEffect } from "react";
|
|
|
|
|
import { Link } from "react-router-dom";
|
2022-01-05 08:40:20 +00:00
|
|
|
import axios from "axios";
|
2021-12-22 08:07:43 +00:00
|
|
|
// IMPORT COMPONENTS
|
2022-01-05 08:40:20 +00:00
|
|
|
import Breadcrumb from "../components/Global/Breadcrumb";
|
2021-12-22 08:07:43 +00:00
|
|
|
|
|
|
|
|
// TAB_1
|
2022-01-05 08:40:20 +00:00
|
|
|
// import RightArrowBlue from "../svg/rightArrowBlue.svg";
|
|
|
|
|
// import TabIMG1 from "../img/tabImg_1.jpg";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class News extends React.Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
2021-12-22 08:07:43 +00:00
|
|
|
|
2022-01-05 08:40:20 +00:00
|
|
|
this.state = {
|
|
|
|
|
items: [],
|
|
|
|
|
DataisLoaded: false
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
// window.scrollTo(0, 0);
|
|
|
|
|
// }, []);
|
2021-12-22 08:07:43 +00:00
|
|
|
// STATE
|
2022-01-05 08:40:20 +00:00
|
|
|
// const [pageIndex, setPageIndex] = useState(1);
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.getTodos();
|
|
|
|
|
// console.log(this.state.items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getTodos() {
|
|
|
|
|
axios.get('http://127.0.0.1:8000/api/v1/categories/3')
|
|
|
|
|
.then(res => {
|
|
|
|
|
const items = res.data;
|
|
|
|
|
this.setState({
|
|
|
|
|
items: items,
|
|
|
|
|
DataisLoaded: true
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
// console.log(this.state.items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { DataisLoaded, items } = this.state;
|
|
|
|
|
if (!DataisLoaded) return <div>
|
|
|
|
|
<h1> Pleses wait some time.... </h1> </div> ;
|
|
|
|
|
// console.log(this.state.items);
|
2021-12-22 08:07:43 +00:00
|
|
|
return (
|
|
|
|
|
<section className="news">
|
|
|
|
|
<Breadcrumb path_1="Новости" currentUrl="./news" />;
|
|
|
|
|
<div className="container">
|
|
|
|
|
<div className="news-inner">
|
|
|
|
|
<div className="news-tab">
|
|
|
|
|
<div className="tab-header">
|
|
|
|
|
<h4 className="tab-header-text" id="tab-header-text">
|
|
|
|
|
Новости
|
|
|
|
|
</h4>
|
|
|
|
|
<div className="tab-header-line"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tab-wrapper">
|
2022-01-05 08:40:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
items['data'][0]['posts'].map((item) => (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="tab" key={item.id}>
|
2021-12-22 08:07:43 +00:00
|
|
|
<div className="tab-top">
|
|
|
|
|
<div>
|
2022-01-05 08:40:20 +00:00
|
|
|
<img src={ item['featured_images'][0]['path'] } alt="Turkmen carpets" />
|
2021-12-22 08:07:43 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tab-bottom">
|
2022-01-05 08:40:20 +00:00
|
|
|
<span className="tab-date">30.05.2021</span>
|
2021-12-22 08:07:43 +00:00
|
|
|
<h2 className="tab-name">
|
2022-01-05 08:40:20 +00:00
|
|
|
{ item.title }
|
2021-12-22 08:07:43 +00:00
|
|
|
</h2>
|
|
|
|
|
<div className="tab-header-link tab-link">
|
2022-01-05 08:40:20 +00:00
|
|
|
<Link to={`/blog/${item.slug}`}>
|
2021-12-22 08:07:43 +00:00
|
|
|
<span>Подробнее</span>
|
|
|
|
|
<div>
|
2022-01-05 08:40:20 +00:00
|
|
|
<img src={ item.featured_images.path } alt="RIGHTARROW" />
|
2021-12-22 08:07:43 +00:00
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-01-05 08:40:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
|
2021-12-22 08:07:43 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-01-05 08:40:20 +00:00
|
|
|
|
2021-12-22 08:07:43 +00:00
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
2022-01-05 08:40:20 +00:00
|
|
|
}
|
2021-12-22 08:07:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default News;
|