import React, { useState, useEffect } from "react"; import * as api from "../services/api"; function Home() { const [loadingData, setLoadingData] = useState(true); const [data, setData] = useState([]); const apiUrl = `${api.getApiBaseUrl()}solutions`; const requestOptions = { method: 'GET', headers: { 'Content-Type': 'application/json' }, }; useEffect(() => { async function getData() { fetch(apiUrl, requestOptions) .then(res => res.json()) .then( (result) => { console.log('routes found from api call', result); setData(result); setLoadingData(false); }, (error) => { console.log('*** ERROR!', error); } ) } if (loadingData) { getData(); } }, []); function handleRowClick(id, vehicleId) { console.log('navigate to ', id, vehicleId); window.location.href = `http://localhost:3000/route?id=${id}&vehicleId=${vehicleId}`; } return (

HERE AWS Tour Planning

{loadingData ? (

Loading Please wait...

) : (
{data && data.map(route => )}
Route Date Tours Vehicles
{route.id} {route.date} {route.vehicles.length}
    {route.vehicles.map(vehicle => (
  • { handleRowClick(route.id, vehicle) }} key={vehicle}>{vehicle}
  • ))}
)}
); } export default Home;