diff --git a/.gitignore b/.gitignore
index c6f9a44..fc34e83 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
.vscode/settings.json
+part2/countries/.env
diff --git a/part2/countries/src/components/Countries.js b/part2/countries/src/components/Countries.js
index e9c3492..03c654b 100644
--- a/part2/countries/src/components/Countries.js
+++ b/part2/countries/src/components/Countries.js
@@ -1,23 +1,17 @@
-import { useState } from "react";
import CountryData from "./CountryData";
-const Countries = ({ showedCountries }) => {
- const [country, setCountry] = useState("");
+const Countries = ({ showedCountries, setShowedCountries }) => {
if (showedCountries.length === 1) {
return ;
} else if (showedCountries.length <= 10) {
- return (
-
- {showedCountries.map((country) => (
-
- {country.name.common}{" "}
-
-
- ))}
- {country &&
}
+ return showedCountries.map((country) => (
+
+ {country.name.official}
+ {""}
+
- );
- } else if (showedCountries.length > 10) {
+ ));
+ } else {
return
Too many matches, specify another filter
;
}
};
diff --git a/part2/countries/src/components/CountryData.js b/part2/countries/src/components/CountryData.js
index c088917..6e2c7e4 100644
--- a/part2/countries/src/components/CountryData.js
+++ b/part2/countries/src/components/CountryData.js
@@ -1,3 +1,5 @@
+import Weather from "./Weather";
+
const CountryData = ({ country }) => {
return (
@@ -11,6 +13,7 @@ const CountryData = ({ country }) => {
))}

+
);
};
diff --git a/part2/countries/src/components/Weather.js b/part2/countries/src/components/Weather.js
new file mode 100644
index 0000000..0058842
--- /dev/null
+++ b/part2/countries/src/components/Weather.js
@@ -0,0 +1,30 @@
+import { useState, useEffect } from "react";
+import axios from "axios";
+
+const Weather = ({ capital }) => {
+ const OPENWEATHER_API_KEY = process.env.REACT_APP_OPENWEATHER_API_KEY;
+ const [weather, setWeather] = useState([]);
+
+ useEffect(() => {
+ axios
+ .get(
+ `https://api.openweathermap.org/data/2.5/weather?q=${capital}&units=metric&appid=${OPENWEATHER_API_KEY}`
+ )
+ .then((response) => {
+ setWeather(response.data);
+ });
+ }, [OPENWEATHER_API_KEY, capital]);
+ return weather.weather ? (
+
+
Weather in {capital}
+
Temperature: {weather.main.temp}°C
+

+
Wind: {weather.wind.speed}m/s
+
+ ) : null;
+};
+
+export default Weather;