diff --git a/src/app/page.tsx b/src/app/page.tsx index 11a598f..52a5b16 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -2,9 +2,21 @@ import { useEffect, useState } from "react"; +interface Advocate { + id: number; + firstName: string; + lastName: string; + city: string; + degree: string; + specialties: string[]; + yearsOfExperience: number; + phoneNumber: number; + createdAt?: string; +} + export default function Home() { - const [advocates, setAdvocates] = useState([]); - const [filteredAdvocates, setFilteredAdvocates] = useState([]); + const [advocates, setAdvocates] = useState([]); + const [filteredAdvocates, setFilteredAdvocates] = useState([]); useEffect(() => { console.log("fetching advocates..."); @@ -16,10 +28,13 @@ export default function Home() { }); }, []); - const onChange = (e) => { + const onChange = (e: React.ChangeEvent) => { const searchTerm = e.target.value; - document.getElementById("search-term").innerHTML = searchTerm; + const searchTermElement = document.getElementById("search-term"); + if (searchTermElement) { + searchTermElement.innerHTML = searchTerm; + } console.log("filtering advocates..."); const filteredAdvocates = advocates.filter((advocate) => { @@ -28,8 +43,8 @@ export default function Home() { advocate.lastName.includes(searchTerm) || advocate.city.includes(searchTerm) || advocate.degree.includes(searchTerm) || - advocate.specialties.includes(searchTerm) || - advocate.yearsOfExperience.includes(searchTerm) + advocate.specialties.some(specialty => specialty.includes(searchTerm)) || + advocate.yearsOfExperience.toString().includes(searchTerm) ); }); @@ -43,44 +58,46 @@ export default function Home() { return (
-

Solace Advocates

-
-
+
+

Solace Advocates

+
-

Search

-

+

Search

+

Searching for:

- - + +


- - - - - - - + + + + + + + + + - {filteredAdvocates.map((advocate) => { + {filteredAdvocates.map((advocate, index) => { return ( - - - - - - + + + + + - - + + ); })}
First NameLast NameCityDegreeSpecialtiesYears of ExperiencePhone Number
First NameLast NameCityDegreeSpecialtiesYears of ExperiencePhone Number
{advocate.firstName}{advocate.lastName}{advocate.city}{advocate.degree} - {advocate.specialties.map((s) => ( -
{s}
+
{advocate.firstName}{advocate.lastName}{advocate.city}{advocate.degree} + {advocate.specialties.map((s: string, index: number) => ( +
{s}
))}
{advocate.yearsOfExperience}{advocate.phoneNumber}{advocate.yearsOfExperience}{advocate.phoneNumber}