import SearchResultsComp from '@/components/searchresults/SearchResultsComp'
import { fetchSearchResults } from './action'

const SearchResults = async ({
  params,
  searchParams,
}: {
  params: Promise<{ slug: string }>
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}) => {
  const searchResults = (await searchParams)?.query
  const searchResultsLan = (await searchParams)?.lang

  // Get the current URL
  const results = await fetchSearchResults(
    Number(searchResultsLan),
    searchResults,
    1,
    1,
  )
  return <SearchResultsComp results={results} selectedLan={Number(searchResultsLan)} />
}

export default SearchResults
