import Link from "next/link";
import { AboutData } from "../../about/types";

interface AboutNewsProps {
    data: AboutData["news"];
}

const AboutNews = ({ data }: AboutNewsProps) => {
    return (
        <section className="news-section section-padding fix pt-0">
            <div className="container">
                <div className="section-title-area">
                    <div className="section-title">
                        <span className="sub-title">{data.subheading}</span>
                        <h2 className="split-text-right split-text-in-right">{data.heading}</h2>
                    </div>
                    <Link href={data.ctaButton.href} className="theme-btn">
                        {data.ctaButton.label}
                        <i className="fa-solid fa-arrow-right"></i>
                    </Link>
                </div>
                <div className="row">
                    {data.items.map((item, index) => (
                        <div key={index} className="col-xl-4 col-lg-6 col-md-6">
                            <div className="news-card-item">
                                <div className="news-image">
                                    <img src={item.thumbnail} alt="img" />
                                    <span>{item.category}</span>
                                    <div className="news-layer-wrapper">
                                        <div
                                            className="news-layer-image"
                                            style={{ backgroundImage: `url('${item.thumbnail}')` }}
                                        ></div>
                                        <div
                                            className="news-layer-image"
                                            style={{ backgroundImage: `url('${item.thumbnail}')` }}
                                        ></div>
                                        <div
                                            className="news-layer-image"
                                            style={{ backgroundImage: `url('${item.thumbnail}')` }}
                                        ></div>
                                        <div
                                            className="news-layer-image"
                                            style={{ backgroundImage: `url('${item.thumbnail}')` }}
                                        ></div>
                                    </div>
                                </div>
                                <div className="news-content">
                                    <div className="list">
                                        <span>Comment ({item.comments})</span>
                                        <span>_ {item.date}</span>
                                    </div>
                                    <h3>
                                        <Link href={item.link}>{item.title}</Link>
                                    </h3>
                                    <div className="news-bottom">
                                        <div className="info-item">
                                            <img src={item.author.avatar} alt="img" />
                                            <span>By {item.author.name}</span>
                                        </div>
                                        <Link href={item.link} className="link-btn">
                                            View Articles<i className="fa-solid fa-arrow-right"></i>
                                        </Link>
                                    </div>
                                </div>
                            </div>
                        </div>
                    ))}
                </div>
            </div>
        </section>
    );
};

export default AboutNews;
