Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBeast229 committed Jan 21, 2024
2 parents b3454c3 + 6bfd877 commit 48b1ad4
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 5 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
155 changes: 155 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"moment": "^2.30.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.21.3",
"react-scripts": "5.0.1",
"semantic-ui-css": "^2.5.0",
"semantic-ui-react": "^2.1.5",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import './App.css';
// Import Home, Weather, Transportation, Maps, Resources
// import React, { useEffect, useState } from "react";
import React from 'react';
import Home from './Home';
import Weather from './Weather';
Expand All @@ -8,7 +9,6 @@ import Maps from './Maps';
import Resources from './Resources';
import Layout from './Layout';


import { BrowserRouter, Routes, Route } from "react-router-dom";

function App() {
Expand Down
38 changes: 34 additions & 4 deletions src/Weather.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
import React from 'react';
import './App.css';
import React, { useEffect, useState } from "react";

function Weather() {
return <div>
<h2> Weather Page </h2>

const [lat, setLat] = useState([]);
const [long, setLong] = useState([]);
const [data, setData] = useState([]);

useEffect(() => {
const fetchData = async () => {
navigator.geolocation.getCurrentPosition(function(position) {
setLat(position.coords.latitude);
setLong(position.coords.longitude);
});

console.log("Latitude is:", lat);
console.log("Longitude is:", long);

const response = await fetch(`${process.env.REACT_APP_API_URL}/weather/?lat=${lat}&lon=${long}&units=metric&APPID=${process.env.REACT_APP_API_KEY}`);
const result = await response.json();

setData(result);
console.log(result);
};

fetchData();
}, [lat, long]);

return (
<div>
<h2> Weather Page </h2>
{/* Render your weather data here */}
</div>
);
}

export default Weather;

export default Weather;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import 'semantic-ui-css/semantic.min.css'

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
Expand Down

0 comments on commit 48b1ad4

Please sign in to comment.