import React, { useEffect, useState } from 'react';
import { getByIdScrappe } from '../../request/scrappe';
import ScrappeDetails from '../../components/ScrappeDetails/ScrappeDetails'
//import ScrappeResult from '../../components/ScrappeResult/ScrappeResult'
import PropTypes from 'prop-types';

const ScrapeResultsPage = ({ location }) => {

  const [scrappeResults, setScrappeResults] = useState()
  const [scrappeDetails, setScrappeDetails] = useState()
  useEffect(() => {
    getByIdScrappe(location.id)
    .then(res => {
        setScrappeDetails(res.data)
    if(res.data.status==='done')
    setScrappeResults(res.data.result)})
  }, [setScrappeResults])
  console.log("scrappeDetails", scrappeDetails)
  console.log("scrappeResults", scrappeResults)
 
  return (
    <>
        {/* ScrappeDetail */}
        {console.log(scrappeDetails)}
     
        <ScrappeDetails details = {scrappeDetails} />
        {/* {(scrappeResults !==undefined) 
                    ? scrappeResults.map((result, i) => <ScrappeResult key={i} result = {result} />) 
                    :''
        */}
     </> 
  );
};

ScrapeResultsPage.propTypes = {
  location: PropTypes.object
};

export default ScrapeResultsPage;
