diff --git a/src/App.css b/src/App.css
index c7f4da8..ba77ade 100644
--- a/src/App.css
+++ b/src/App.css
@@ -3,4 +3,20 @@
padding: 20px;
color: white;
text-align: center;
+
+}
+.city{
+ margin-top: 40px;
+ border: solid;
+ border-radius: 5px;
+ border-color: #c1c1c1;
+}
+.city-header{
+ padding:20px;
+ background-color: #e9e6e6;
+ border-color: #c1c1c1;
+ border-bottom-style: solid;
+}
+.city-body{
+ margin:20px;
}
diff --git a/src/App.jsx b/src/App.jsx
index 6478b09..c9abac1 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,25 +1,71 @@
-import { useState } from "react";
+import { useEffect, useState } from 'react';
import "./App.css";
function City(props) {
- return
This is the City component
;
+ console.log(props.State)
+ return
+
{props.LocationText}
+
+ - State: {props.State}
+ - Location: {props.Lat}, {props.Long}
+ - Population (estimated): {props.EstimatedPopulation}
+ - Total Wages: {props.TotalWages}
+
+
;
}
-function ZipSearchField(props) {
- return This is the ZipSearchField component
;
+function ZipSearchField({setCitydata, SetMessage}) {
+ const [query, setQuery] = useState('');
+
+ useEffect(() => {
+ const fetchData = async () => {
+ if (query.length === 5) {
+ try {
+ const response = await fetch(`https://ctp-zip-code-api.onrender.com/zip/${query}`)
+ const data = await response.json()
+ if (data) {
+ setCitydata(data)
+ SetMessage('')
+ }
+ } catch (error) {
+ SetMessage('Error fetching city data', error)
+ setCitydata([])
+ }
+ } else {
+ SetMessage('No results found')
+ setCitydata([])
+ }
+ }
+ fetchData()
+ }, [query, setCitydata, SetMessage])
+
+ return (
+ <>
+
+
+ >
+ );
}
function App() {
+ const [cityData, setCitydata] = useState([]);
+ const [message, SetMessage] = useState('No results found')
return (
Zip Code Search
-
+
+
{message}
-
-
+ {cityData.map((city) => {
+ console.log(city)
+ return
+ })}