import { useLoaderData } from "react-router-dom";
import CompanyDetails from "../../components/company_details";
import MainContentLayout from "../../components/main_content_layout";
import SearchBar from "../../components/search_bar";

export default function Companies(){
  const companies = useLoaderData().data.data.map(company =>
    <li key={company.id}>
      <CompanyDetails company={company}/>
    </li>  
  );

  return(
    <>
      <MainContentLayout>
        <SearchBar path="/companies"/>
        <ul>
          {companies}
        </ul>
      </MainContentLayout>
    </>
  );
}