import logo from "./card.png";
import logo1 from "./location.png";
import logo2 from "./car.png";
import logo3 from "./car.jpg"
import './home.css';
import PropTypes from 'prop-types'; // Import PropTypes
import axios from 'axios'
import { useNavigate } from "react-router-dom";
`import { useState } from "react";
import logo from "./card.png"; import logo1 from "./location.png"; import logo2 from "./car.png"; import logo3 from "./car.jpg" import './home.css'; import PropTypes from 'prop-types'; // Import PropTypes import axios from 'axios' import { useNavigate } from "react-router-dom";
export const Home = ({setResults}) => {
// Function to fetch data based on input value const fetchDate = (value, setterFunction, setFilteredResultsFunction) => { fetch("https://jsonplaceholder.typicode.com/users") .then((response) => response.json()) .then((json) => { const filteredResults = json.filter((user) => { return ( value && user && user.name && user.name.toLowerCase().includes(value.toLowerCase()) ); }); setFilteredResultsFunction(filteredResults); }); };
// Function to handle input change and fetch suggestions const handleInputChange = (value, setterFunction, setFilteredResultsFunction) => { setterFunction(value); if (value.trim() === "") { setFilteredResultsFunction([]); return; } fetchDate(value, setterFunction, setFilteredResultsFunction); };
}
// Add prop types validation Home.propTypes = { setResults: PropTypes.func.isRequired,// Ensure results is an array and required }; export default Home;`