import type { Metadata } from "next";
import SearchPageClient from "@/features/search/components/SearchPageClient";

type Props = {
  params: Promise<{ locale: string }>;
  searchParams: Promise<{ q?: string }>;
};

export async function generateMetadata({
  searchParams,
}: Props): Promise<Metadata> {
  const { q } = await searchParams;
  return {
    title: q ? `Search: ${q} | SmartElectronics` : "Search | SmartElectronics",
  };
}

export default async function SearchPage(props: Props) {
  const params = await props.params;
  const searchParams = await props.searchParams;

  return <SearchPageClient params={params} searchParams={searchParams} />;
}
