diff --git a/src/App.css b/src/App.css
index c7f4da8..b7efc2f 100644
--- a/src/App.css
+++ b/src/App.css
@@ -4,3 +4,28 @@
color: white;
text-align: center;
}
+
+.App {
+ text-align: center;
+ font-family: Arial, sans-serif;
+}
+
+.city {
+ border: 1px solid #ccc;
+ padding: 10px;
+ margin: 10px 0;
+ border-radius: 5px;
+}
+
+.error-message {
+ color: red;
+}
+
+input {
+ width: 100%;
+ padding: 8px;
+ margin: 10px 0;
+ border-radius: 4px;
+ border: 1px solid #ccc;
+}
+
diff --git a/src/App.jsx b/src/App.jsx
index 6478b09..1f22de9 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,26 +1,80 @@
import { useState } from "react";
import "./App.css";
-function City(props) {
- return
This is the City component
;
+function City({ city }) {
+ return (
+
+
{city.City}
+
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({ onSearch }) {
+ const [zip, setZip] = useState("");
+
+ const handleInputChange = (e) => {
+ setZip(e.target.value);
+ };
+
+ const handleKeyDown = (e) => {
+ if (e.key === "Enter") {
+ onSearch(zip);
+ }
+ };
+
+ return (
+
+
+
+
+ );
}
function App() {
+ const [cities, setCities] = useState([]);
+ const [error, setError] = useState(null);
+
+ const fetchCityData = async (zip) => {
+ setError(null);
+ try {
+ const response = await fetch(`https://ctp-zip-code-api.onrender.com/zip/${zip}`);
+ if (!response.ok) {
+ throw new Error("No results found");
+ }
+ const data = await response.json();
+ setCities(data);
+ } catch (err) {
+ setCities([]);
+ setError(err.message);
+ }
+ };
+
return (
Zip Code Search
-
-
-
-
-
+
+ {error ? (
+
{error}
+ ) : (
+
+ {cities.map((city) => (
+
+ ))}
+
+ )}
);