From 3c50ede5ae36a23cb0613de1395c5eda0d6b0d2b Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 6 Aug 2023 08:43:56 +0000 Subject: [PATCH 1/4] sweep: Create components/WeatherWidget.tsx --- components/WeatherWidget.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 components/WeatherWidget.tsx diff --git a/components/WeatherWidget.tsx b/components/WeatherWidget.tsx new file mode 100644 index 0000000..2901cbd --- /dev/null +++ b/components/WeatherWidget.tsx @@ -0,0 +1,27 @@ +import React, { useState, useEffect } from 'react'; + +const WeatherWidget = ({ location }) => { + const [weatherData, setWeatherData] = useState(null); + + useEffect(() => { + const fetchWeatherData = async () => { + // Fetch weather data for the specified location using an API + // Set the weather data in the state variable + }; + + fetchWeatherData(); + }, [location]); + + const formatWeatherData = (data) => { + // Format the weather data + // Return the formatted data + }; + + return ( +
+ {/* Render the formatted weather data */} +
+ ); +}; + +export default WeatherWidget; \ No newline at end of file From 9b1749e1228da0fc42b65adfbd8a4fbc4d65a51e Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 6 Aug 2023 08:44:06 +0000 Subject: [PATCH 2/4] sweep: Create components/WeatherWidgetContainer.tsx --- components/WeatherWidgetContainer.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 components/WeatherWidgetContainer.tsx diff --git a/components/WeatherWidgetContainer.tsx b/components/WeatherWidgetContainer.tsx new file mode 100644 index 0000000..49cb3f4 --- /dev/null +++ b/components/WeatherWidgetContainer.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import WeatherWidget from './WeatherWidget'; + +const WeatherWidgetContainer = () => { + const locations = ['London', 'Edinburgh', 'Alicante']; + + return ( +
+ {locations.map((location) => ( + + ))} +
+ ); +}; + +export default WeatherWidgetContainer; \ No newline at end of file From 4c1d9134f5f8e3461f6a1bbe3bae369b331ba2fe Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 6 Aug 2023 08:44:16 +0000 Subject: [PATCH 3/4] sweep: Create components/utils/api.ts --- components/utils/api.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 components/utils/api.ts diff --git a/components/utils/api.ts b/components/utils/api.ts new file mode 100644 index 0000000..f51f075 --- /dev/null +++ b/components/utils/api.ts @@ -0,0 +1,19 @@ +import axios from 'axios'; + +const BASE_URL = 'https://api.weatherapi.com/v1'; + +export const fetchWeatherData = async (location: string) => { + try { + const response = await axios.get(`${BASE_URL}/weather`, { + params: { + key: 'YOUR_API_KEY', + q: location, + }, + }); + + return response.data; + } catch (error) { + console.error('Error fetching weather data:', error); + throw error; + } +}; \ No newline at end of file From 45825b423c623b1f5cf1b71e443f8bf18dcba956 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 6 Aug 2023 08:44:28 +0000 Subject: [PATCH 4/4] sweep: Create components/utils/format.ts --- components/utils/format.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 components/utils/format.ts diff --git a/components/utils/format.ts b/components/utils/format.ts new file mode 100644 index 0000000..a8c6707 --- /dev/null +++ b/components/utils/format.ts @@ -0,0 +1,13 @@ +export const formatWeatherData = (weatherData: any) => { + const temperature = weatherData.current.temp_c; + const humidity = weatherData.current.humidity; + const windSpeed = weatherData.current.wind_kph; + + const formattedWeatherData = { + temperature: `${temperature}°C`, + humidity: `${humidity}%`, + windSpeed: `${windSpeed} km/h`, + }; + + return formattedWeatherData; +}; \ No newline at end of file