diff --git a/src/App.tsx b/src/App.tsx index a1fc0a6..4fa6799 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,13 +1,16 @@ +import { useState } from "react" import "./App.css" import LocationList from "./components/location-list" import ViewCity from "./components/ViewCity" function App() { + const [selectedCity, setSelectedCity] = useState("Sørumsand") + return ( <>
- - + +
diff --git a/src/components/ViewCity.tsx b/src/components/ViewCity.tsx index 9941306..8a5cb18 100644 --- a/src/components/ViewCity.tsx +++ b/src/components/ViewCity.tsx @@ -6,8 +6,7 @@ interface ViewCityProp { } export default function ViewCity(arg: ViewCityProp) { - const cityFilter = { cityName: arg.city } - const data = useGetCityCoordinates(cityFilter) + const data = useGetCityCoordinates({ cityName: arg.city }) const { isLoading, error, result } = useGetWeather( data.result[0]?.latitude, diff --git a/src/components/location-list.tsx b/src/components/location-list.tsx index 0b5f007..e00be25 100644 --- a/src/components/location-list.tsx +++ b/src/components/location-list.tsx @@ -41,7 +41,11 @@ const getNextDays = (data?: WeatherApiResponse) => { return noonTemperatures } -const LocationList = () => { +interface LocationListProps { + onCitySelect: (cityName: string) => void +} + +const LocationList = ({ onCitySelect }: LocationListProps) => { const { isLoading, results } = useGetWeatherForCities(cities) if (isLoading) { @@ -90,7 +94,9 @@ const LocationList = () => { }} > {cityWeather.map((item) => ( - +
onCitySelect(item.name || "")}> + +
))}