-
Notifications
You must be signed in to change notification settings - Fork 0
/
Result.tsx
38 lines (32 loc) · 1.1 KB
/
Result.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function Result(props: any): JSX.Element {
const { weatherData } = props;
const headingStyle = {
display: "flex",
alignItems: "center",
fontSize: "2em"
}
const iconStyle = {
height: "2.5em",
width: "2.5em"
}
let weatherIcon, weatherResults;
if (weatherData?.success) {
weatherIcon = <img src={`https://openweathermap.org/img/wn/${weatherData.icon}@2x.png`}
alt="Weather icon"
style={iconStyle} />
weatherResults = <>
<h2 style={headingStyle}>{weatherData.city} {weatherIcon}</h2>
<p>Description: {weatherData.description}</p>
<p>Current temp: {weatherData.currentTemp}°F</p>
<p>Feels like: {weatherData.feelsLike}°F</p>
<p>Wind Speed: {weatherData.windSpeed}mph</p>
</>
}
return (
<section className="weather-result">
{weatherData?.error && <h2 style={headingStyle}>{weatherData.error}</h2>}
{weatherData?.success && weatherResults}
</section>
)
}
export default Result