import NewsList from "./NewsList";
import Sidebar from "./Sidebar";
import Pagination from "./Pagination";
import type { BlogPost, BlogPagination } from "@/types";

interface NewsSectionProps {
  blogs?: BlogPost[];
  categorySlug?: string;
  tagSlug?: string;
  searchQuery?: string;
  pagination?: BlogPagination;
}

export default function NewsSection({
  blogs,
  categorySlug,
  tagSlug,
  searchQuery,
  pagination,
}: NewsSectionProps) {
  const basePath = categorySlug
    ? `/blog/category/${categorySlug}`
    : tagSlug
      ? `/blog/tag/${tagSlug}`
      : "/blog";

  return (
    <section className="news-standard-section section-padding fix">
      <div className="container">
        <div className="news-standard-wrapper">
          <div className="row g-4">
            <NewsList blogs={blogs} categorySlug={categorySlug} tagSlug={tagSlug} />
            <Sidebar searchQuery={searchQuery} />
          </div>
          {pagination && pagination.total > 1 && (
            <div className="row g-4 mt-4">
              <div className="col-12">
                <Pagination basePath={basePath} pagination={pagination} searchQuery={searchQuery} />
              </div>
            </div>
          )}
        </div>
      </div>
    </section>
  );
}