import { PostListProps } from "@/lib/blog.types";
import PostCard from "./PostCard";
import Pagination from "./Pagination";
import { UI } from "@/lib/config";

export default function PostList({
  posts,
  lang,
  currentPage,
  totalPages,
}: PostListProps) {
  const t = UI[lang].t;
  const dir = UI[lang].dir;

  if (!posts || posts.length === 0) {
    return (
      <div className="text-center py-16" dir={dir}>
        <p className="text-xl text-gray-600 dark:text-gray-400">
          {t.noPostsFound}
        </p>
      </div>
    );
  }

  return (
    <div className="space-y-12" dir={dir}>
      {/* Posts Grid */}
      <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
        {posts.map((post) => (
          <PostCard key={post.slug} post={post} lang={lang} />
        ))}
      </div>

      {/* Pagination */}
      {totalPages > 1 && (
        <Pagination
          currentPage={currentPage}
          totalPages={totalPages}
          lang={lang}
        />
      )}
    </div>
  );
}
