import React, {Component,useState, useEffect} from 'react';
import BlogItems from '../components/BlogItems';
import SiteService from "../svs/SiteService";

class Blog_listing extends React.Component {

  constructor(props) {
    super(props);
    // Don't call this.setState() here!
    // this.state = { counter: 0 };
    // this.handleClick = this.handleClick.bind(this);
    console.log("OLU-AMEY BLOG LISTING ",props.blogData);
  }

  
  render() {
     // const [blogData, setBlogData] = useState([]) // for holding
      //const siteApi = new SiteService(); // instantiating the API SERVICE


        return(
            <div>


        {/* PRELOADER SPINNER
		============================================= */}	
        <div id="loader-wrapper">
          <div id="loading">
            <span className="cssload-loader"><span className="cssload-loader-inner" /></span>
          </div>
        </div>
        {/* PAGE CONTENT
		============================================= */}	
        <div id="page" className="page">
          {/* HEADER
			============================================= */}
          
          {/* BLOG POSTS LISTING
			============================================= */}
          <section id="blog-page" className="bg_whitesmoke hero-offset-nav pb-60 blog-page-section division">
            <div className="container">
              {/* SECTION TITLE */}	
              <div className="row">	
                <div className="col-md-10 offset-md-1">
                  <div className="section-title text-center pc-50 mb-70">		
                    {/* Title */}	
                    <h3 className="h3-lg">Relevant news, tech stuff, and more for you. Welcome to our blog</h3>	
                    {/* Text */}	
                    <p className="p-xl">Aliquam a augue suscipit, luctus neque purus ipsum neque at dolor primis libero
                      tempus, blandit and cursus varius
                    </p>
                  </div>	
                </div>
              </div>
              {/* FEATURED POST */}
              {
                this.props.blogData?.featured == undefined ?  // API CALL IN PROGRESS
                <div className="text-center">
                    <div className="spinner-border spinner-border-lg" role="status" style={{width: '3rem', height: '3rem'}}>
                    </div>
                </div>
                :
                <div className="rel blog-post featured-post wide-post">
                  <div className="row d-flex align-items-center">
                    <div className="featured-badge text-center ico-30 bg_whitesmoke yellow-color">
                      <span className="flaticon-star" />
                    </div>
                    {/* BLOG POST IMAGE */}
                    <div className="col-lg-7 blog-post-img">
                      <img className="w-auto h-100" src={process.env.REACT_APP_IMAGE_LINK + this.props.blogData?.featured.meta_value} alt="blog-post-image" />
                    </div>
                    {/* BLOG POST TEXT */}
                    <div className="col-lg-5 blog-post-txt">
                      {/* Post Tag */}
                      <p className="p-2 post-tag">Float News</p>	
                      {/* Post Link */}
                      <h5 className="h5-xl">
                        <a href="single-post.html">{this.props.blogData?.featured.post_title}</a>
                      </h5>
                      {/* Text */}
                      {/* <p className="p-md">Aliqum mullam blandit vitae and tempor sapien and donec lipsum gravida a porta 
                        undo velna dolor in cubilia laoreet
                      </p> */}
                      <div className="p-2" dangerouslySetInnerHTML={{__html: this.props.blogData?.featured.post_content.substring(0,300)+'  . . .'}}></div>
                      {/* Post Meta */}
                      <div className="post-meta">
                        <div className="post-author-avatar"><img src="assets/images/post-author-1.jpg" alt="author-avatar" /></div>
                        <p>12 min read</p>
                      </div>	
                    </div>	{/* END BLOG POST TEXT */}
                  </div>   {/* End row */}
                </div>	
              } {/* END FEATURED POST */}

              {/* POSTS WRAPPER */}
              <div className="posts-wrapper">
                {/* BLOG POSTS CATEGORY */} 
                <div className="row">
                  <div className="col-md-12">
                    <h5 className="h5-lg posts-category">Latest Articles</h5>
                  </div>
                </div>
                <BlogItems blogData={this.props.blogData} />
                {/* End row */}
              </div>	{/* END POSTS WRAPPER */}
            </div>     {/* End container */}
            {/* GEOMETRIC OVERLAY */}	
            <div className="bg_fixed geometric_overlay" />
          </section>	{/* END BLOG POSTS LISTING */}
          {/* PAGE PAGINATION
			============================================= */}
          <div className="bg_whitesmoke pb-100 page-pagination division">
            <div className="container">
              <div className="row">	
                <div className="col-md-12">
                  <nav aria-label="Page navigation">
                    <ul className="pagination ico-20 justify-content-center">
                      <li className="page-item disabled"><a className="page-link" href="#" tabIndex={-1}>
                          <span className="flaticon-chevron-pointing-to-the-left" />
                        </a></li>
                      <li className="page-item active"><a className="page-link" href="#">1 <span className="sr-only">(current)</span></a></li>
                      <li className="page-item"><a className="page-link" href="#">2</a></li>
                      <li className="page-item"><a className="page-link" href="#">3</a></li>
                      <li className="page-item"><a className="page-link" href="#">4</a></li>
                      <li className="page-item"><a className="page-link" href="#"><span className="flaticon-right-chevron" /></a></li>
                    </ul>	
                  </nav>					
                </div>
              </div>  {/* End row */}	
            </div> {/* End container */}
          </div>	{/* END PAGE PAGINATION */}
          {/* NEWSLETTER-1
			============================================= */}
          <section id="newsletter-1" className="bg_whitesmoke pb-20 newsletter-section division">
            <div className="container">
              <div className="newsletter-wrapper bg-white">
                <div className="row d-flex align-items-center">
                  {/* SECTION TITLE */}	
                  <div className="col-lg-6">
                    <div className="newsletter-txt">	
                      {/* Section ID */}	
                      <span className="section-id">Subscribe to Our Newsletter</span>
                      {/* Title */}	
                      <h4 className="h4-xl">Stay up to date with our news, ideas and updates</h4>	
                    </div>								
                  </div>
                  {/* NEWSLETTER FORM */}
                  <div className="col-lg-6">
                    <form className="newsletter-form">
                      <div className="input-group">
                        <input type="email" autoComplete="off" className="form-control" placeholder="Your email address" required id="s-email" />								
                        <span className="input-group-btn">
                          <button type="submit" className="btn btn-md btn-skyblue tra-skyblue-hover">Subscribe Now</button>
                        </span>										
                      </div>
                      {/* Newsletter Form Notification */}	
                      <label htmlFor="s-email" className="form-notification" />
                    </form>							
                  </div>	  {/* END NEWSLETTER FORM */}
                </div>	  {/* End row */}
              </div>    {/* End newsletter-holder */}
            </div>	   {/* End container */}	
          </section>	{/* END NEWSLETTER-1 */}
          
        </div>	{/* END PAGE CONTENT */}
      


            </div>
        )
    }
}
export default Blog_listing 