From 35095b49bc67337219385623705af0eb6c2f4793 Mon Sep 17 00:00:00 2001 From: Marcos Frony Date: Tue, 2 Sep 2025 17:04:06 -0700 Subject: [PATCH 1/4] Fix bugs on src/app/page.tsx --- src/app/page.tsx | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 11a598f..5dedb4d 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) ); }); @@ -75,8 +90,8 @@ export default function Home() { {advocate.city} {advocate.degree} - {advocate.specialties.map((s) => ( -
{s}
+ {advocate.specialties.map((s: string, index: number) => ( +
{s}
))} {advocate.yearsOfExperience} From ae97ee5bea3a000ae215652a1468a1ca7e47a5f8 Mon Sep 17 00:00:00 2001 From: Marcos Frony Date: Tue, 2 Sep 2025 17:16:02 -0700 Subject: [PATCH 2/4] Added a tr between thead and th --- src/app/page.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 5dedb4d..c25281f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -58,11 +58,11 @@ export default function Home() { return (
-

Solace Advocates

+

Solace Advocates



-

Search

+

Search

Searching for:

@@ -73,13 +73,15 @@ export default function Home() {
- - - - - - - + + + + + + + + + {filteredAdvocates.map((advocate) => { From 20664f7fda6483e3a713e04a15fae46c3c808b93 Mon Sep 17 00:00:00 2001 From: Marcos Frony Date: Tue, 2 Sep 2025 17:38:17 -0700 Subject: [PATCH 3/4] Style top header and search section. Align tds to the top --- src/app/page.tsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index c25281f..cf76e82 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -58,16 +58,16 @@ export default function Home() { return (
-

Solace Advocates

-
-
+
+

Solace Advocates

+
-

Search

-

+

Search

+

Searching for:

- - + +


@@ -87,17 +87,17 @@ export default function Home() { {filteredAdvocates.map((advocate) => { return (
- - - - - + + + + - - + + ); })} From 0821fa21c2cf042a85b7a72de7be60b0ee1b9947 Mon Sep 17 00:00:00 2001 From: Marcos Frony Date: Tue, 2 Sep 2025 18:06:03 -0700 Subject: [PATCH 4/4] Style the result table --- src/app/page.tsx | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index cf76e82..52a5b16 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -74,30 +74,30 @@ export default function Home() {
First NameLast NameCityDegreeSpecialtiesYears of ExperiencePhone Number
First NameLast NameCityDegreeSpecialtiesYears of ExperiencePhone Number
{advocate.firstName}{advocate.lastName}{advocate.city}{advocate.degree} + {advocate.firstName}{advocate.lastName}{advocate.city}{advocate.degree} {advocate.specialties.map((s: string, index: number) => (
{s}
))}
{advocate.yearsOfExperience}{advocate.phoneNumber}{advocate.yearsOfExperience}{advocate.phoneNumber}
- - - - - - - + + + + + + + - {filteredAdvocates.map((advocate) => { + {filteredAdvocates.map((advocate, index) => { return ( - - - - - + + + + + - - + + ); })}
First NameLast NameCityDegreeSpecialtiesYears of ExperiencePhone NumberFirst NameLast NameCityDegreeSpecialtiesYears of ExperiencePhone Number
{advocate.firstName}{advocate.lastName}{advocate.city}{advocate.degree}
{advocate.firstName}{advocate.lastName}{advocate.city}{advocate.degree} {advocate.specialties.map((s: string, index: number) => (
{s}
))}
{advocate.yearsOfExperience}{advocate.phoneNumber}{advocate.yearsOfExperience}{advocate.phoneNumber}