import React from "react";
import { getBrandProducts } from "@/shared/api/brandsSvc";
import ProductsList from "@/features/brand-products/ui/products-list";
import MyPagionation from "@/shared/ui/my-pagionation";

export const dynamic = "force-dynamic";

type PageProps = {
  params: {
    brandId: number;
  };
  searchParams: { page?: string };
};

const Page = async ({ params, searchParams }: Readonly<PageProps>) => {
  const { brandId } = await params;
  const { page } = await searchParams;
  const products = await getBrandProducts(brandId);

  return (
    <div className={"section-wrapper"}>
      <div className={"section-wrapper"}>
        <ProductsList products={products.data} />
      </div>
      <MyPagionation
        currentPage={Number(page)}
        totalPages={products.pagination.total}
      />
    </div>
  );
};
export default Page;
