https://github.com/kislaykashyap-hub/weather-forecast-lwc
Welcome to the Weather Forecast LWC Project! This Salesforce Lightning Web Component (LWC) app connects to the OpenWeather API to bring you real-time weather updates.
https://github.com/kislaykashyap-hub/weather-forecast-lwc
apex github html javascript lwc-component openweather-api salesforce sfdx soql xml
Last synced: 27 days ago
JSON representation
Welcome to the Weather Forecast LWC Project! This Salesforce Lightning Web Component (LWC) app connects to the OpenWeather API to bring you real-time weather updates.
- Host: GitHub
- URL: https://github.com/kislaykashyap-hub/weather-forecast-lwc
- Owner: KislayKashyap-hub
- Created: 2024-11-29T10:29:19.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-11-29T11:20:51.000Z (5 months ago)
- Last Synced: 2025-02-08T22:27:48.567Z (3 months ago)
- Topics: apex, github, html, javascript, lwc-component, openweather-api, salesforce, sfdx, soql, xml
- Language: JavaScript
- Homepage: https://github.com/KislayKashyap-hub/Weather-Forecast-LWC
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π¦οΈ **Weather Forecast LWC Project** π
### **Overview** π
Welcome to the **Weather Forecast LWC Project**! This Salesforce Lightning Web Component (LWC) app connects to the [OpenWeather API](https://openweathermap.org/api) to bring you **real-time weather updates**. The app lets you:
- Fetch a **5-day weather forecast** by entering a **city name** π.
- Automatically fetch weather data based on the **Billing City** of an **Account** record π’.---
### **Key Features** β¨
1. **City-Based Weather Forecast** π:
- Enter a city name to get a **5-day weather forecast**.
- Displays temperature, date, and weather conditions in a **user-friendly table**.2. **Billing City-Based Weather Forecast** ποΈ:
- Automatically fetches weather data for the **Billing City** of an `Account` record.
- Perfect for Account-specific insights! πΊοΈ3. **Reusable Weather Table** π:
- A **reusable** LWC component that can be used across different parts of your app to display weather data.---
### **How It Works** π
1. **City-Based Forecast** π:
- Go to the page with `searchWeather` and enter a city name.
- Click **Search** to display the 5-day forecast in a table.2. **Billing City Forecast** ποΈ:
- Go to an `Account` record that has the `Billing City` filled.
- The `weatherForecastByBillingCity` component will automatically show the weather for the **Billing City**.---
### **Screenshots** πΈ
#### City-Based Weather Forecast
#### Billing City Weather Forecast
---
### **Project Structure** π
```
Weather-Forecast-LWC/
βββ force-app/
β βββ main/
β βββ default/
β βββ aura/
β βββ classes/
β β βββ WeatherForecastController.cls
β βββ lwc/
β β βββ SearchWeatherForecoast/
β β βββ ForecastByBillingCity/
β β βββ WeatherTableForecast/
β βββ layouts/
βββ .gitignore
βββ README.md
βββ images/
βββ SearchWeather.png
βββ BillingCity.png
```---
### **Setup Instructions** π οΈ
#### **1. Prerequisites** π
- **Salesforce Developer Org** or **Sandbox** (Make sure you have **API access** enabled).
- [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli) installed.
- **OpenWeather API Key** (Sign up [here](https://openweathermap.org/api) to get one).#### **2. Clone the Repo** π₯
```bash
git clone https://github.com/KislayKashyap-hub/Weather-Forecast-LWC.git
cd Weather-Forecast-LWC
```#### **3. Deploy to Salesforce** π
```bash
sfdx force:source:deploy -p force-app
```#### **4. Add Remote Site Settings** π§
Go to **Setup** β **Remote Site Settings** β **New Remote Site** and add:
- **Name**: `OpenWeatherAPI`
- **URL**: `https://api.openweathermap.org`#### **5. Replace API Key** π
Replace `YOUR_API_KEY` in the `WeatherController` Apex class with your actual OpenWeather API key:
```apex
String endpoint = 'https://api.openweathermap.org/data/2.5/forecast?q=' + cityName + '&appid=YOUR_API_KEY&units=metric';
```#### **6. Assign Components** π²
- **Search Weather Component**: Add `searchWeather` to any Lightning App Page.
- **Billing City Weather Component**: Add `weatherForecastByBillingCity` to an `Account` Lightning Record Page.---
### **Improvements & Future Enhancements** π§
- **Error Handling**: Add better handling for incorrect city names or empty `BillingCity`.
- **Secure the API Key**: Use Salesforce **Custom Metadata** or **Custom Settings** for storing the API key securely.
- **UI Enhancements**: Display more weather details like wind speed, humidity, etc.
- **Test Classes**: Improve the test coverage for Apex code to ensure reliability.---
### **License** π
This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.---
### **Contributing** π€
Contributions are welcome! Feel free to fork the repository, create a new branch, and submit a pull request.---
### **Contact** π¬
You can reach out to me on the following platforms:
- π§ **Email**: [[email protected]](mailto:[email protected])
- π **LinkedIn**: [Kislay Kumar](https://www.linkedin.com/in/kislay-kumar-kk/)
- π **Trailhead**: [Kislay Kumar on Trailhead](https://www.salesforce.com/trailblazer/g88z22m1ullatkw2wr)---
### **Connect & Follow** π
Letβs stay connected and keep building amazing projects together! π