import { filterProducts, parseSearchParams } from '@/lib/filterProducts';
import { CatalogView } from '@/components/CatalogView/CatalogView';
import { getProducts } from '@/lib/api';

export async function CatalogContent({
  params,
}: {
  params: Record<string, string | string[] | undefined>;
}) {
  const products = await getProducts();
  const filters = parseSearchParams(params);
  const filtered = filterProducts(products, filters);

  const breadcrumbItems = [
    { label: 'Главная', href: '/' },
    { label: 'Каталог' },
  ];

  return (
    <CatalogView
      products={filtered}
      breadcrumbItems={breadcrumbItems}
    />
  );
}
