From 938c9eb4a535308212cff28b35193e7cd7be4ddd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E3=83=A2=E3=83=8F=E3=83=A1=E3=83=83=E3=83=89?=
<154572400+Mbensassi2026@users.noreply.github.com>
Date: Tue, 8 Oct 2024 17:49:09 -0400
Subject: [PATCH] Update App.jsx
---
src/App.jsx | 68 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 60 insertions(+), 8 deletions(-)
diff --git a/src/App.jsx b/src/App.jsx
index 6478b09..8b5693e 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,25 +1,77 @@
import { useState } from "react";
import "./App.css";
-function City(props) {
- return
This is the City component
;
+function City({ city }) {
+ return (
+
+
+
+ {city.LocationText}
+
+
+
+ - State: {city.State}
+ - Location: ({city.Lat}, {city.Long})
+ - Population (estimated): {city.EstimatedPopulation}
+ - Total Wages: {city.TotalWages}
+
+
+
+
+ );
}
-function ZipSearchField(props) {
- return This is the ZipSearchField component
;
+function ZipSearchField({ setCityData }) {
+ const fetchZipcodes = (zipcode) => {
+ fetch(`https://ctp-zip-code-api.onrender.com/zip/${zipcode}`)
+ .then((response) => response.json())
+ .then((data) => setCityData(data))
+ .catch(() => setCityData(null));
+ };
+
+ const onChange = () => {
+ const zip = document.getElementById("zipcode");
+ fetchZipcodes(zip.value);
+ };
+
+ return (
+
+ );
}
function App() {
+ const [cityData, setCityData] = useState();
+
return (
Zip Code Search
-
-
-
-
+
+
+ {cityData && cityData.length > 0
+ ? cityData.map((city, index) => )
+ : null}