-
Notifications
You must be signed in to change notification settings - Fork 85
Eval submission #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Eval submission #84
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| VITE_API_KEY=731a6fa24765316e8e44e6e18157a6bd | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| module.exports = { | ||
| root: true, | ||
| env: { browser: true, es2020: true }, | ||
| extends: [ | ||
| "wesbos" | ||
| ], | ||
| ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
| parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, | ||
| settings: { react: { version: '18.2' } }, | ||
| plugins: ['react-refresh'], | ||
| rules: { | ||
| 'react-refresh/only-export-components': [ | ||
| 'warn', | ||
| { allowConstantExport: true }, | ||
| ], | ||
| "no-console": 2, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,14 @@ | ||
| ## Weather Project | ||
| # Redux Weather App | ||
|
|
||
| This project has been created by a student at Parsity, an online software engineering course. The work in this repository is wholly of the student based on a sample starter project that can be accessed by looking at the repository that this project forks. | ||
| Search a city name and get back three graphs displaying the temperature, pressure, humidity, and corresponding averages for that city over the next 5 days. This app was built with React using Vite, Redux, and utilizes the [OpenWeather API](https://openweathermap.org/). | ||
|
|
||
| If you have any questions about this project or the program in general, visit [parsity.io](https://parsity.io/) or email [email protected]. | ||
| ## Run Locally | ||
|
|
||
| To run locally, fork and clone this repository. `cd` into the directory you created and execute the following commands: | ||
|
|
||
| ``` | ||
| npm install | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice job on the readme! it is great to put all instructions on how to run the app in here. |
||
| npm run dev | ||
| ``` | ||
|
|
||
| Now you can type a city name into the input box and retrieve weather data about it. If you get an error, check your spelling. If the city you want isn't coming up, enter the city, state, and two-letter country ISO code (for example, "Chicago, Illinois, US"). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Vite + React</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.jsx"></script> | ||
| </body> | ||
| </html> |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,40 @@ | ||
| { | ||
| "name": "redux-weather", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "dependencies": { | ||
| "@testing-library/jest-dom": "^5.11.10", | ||
| "@testing-library/react": "^11.2.6", | ||
| "@testing-library/user-event": "^12.8.3", | ||
| "react": "^17.0.2", | ||
| "react-dom": "^17.0.2", | ||
| "react-scripts": "4.0.3", | ||
| "web-vitals": "^1.1.1" | ||
| }, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "scripts": { | ||
| "start": "react-scripts start", | ||
| "build": "react-scripts build", | ||
| "test": "react-scripts test", | ||
| "eject": "react-scripts eject" | ||
| "dev": "vite", | ||
| "build": "vite build", | ||
| "lint": "eslint .", | ||
| "lint:fix": "eslint . --fix", | ||
| "preview": "vite preview" | ||
| }, | ||
| "eslintConfig": { | ||
| "extends": [ | ||
| "react-app", | ||
| "react-app/jest" | ||
| "wesbos" | ||
| ] | ||
| }, | ||
| "browserslist": { | ||
| "production": [ | ||
| ">0.2%", | ||
| "not dead", | ||
| "not op_mini all" | ||
| ], | ||
| "development": [ | ||
| "last 1 chrome version", | ||
| "last 1 firefox version", | ||
| "last 1 safari version" | ||
| ] | ||
| "dependencies": { | ||
| "@reduxjs/toolkit": "^1.9.7", | ||
| "axios": "^1.5.1", | ||
| "bootstrap": "^5.3.2", | ||
| "eslint-config-wesbos": "^3.2.3", | ||
| "prop-types": "^15.8.1", | ||
| "react": "^18.2.0", | ||
| "react-bootstrap": "^2.9.1", | ||
| "react-dom": "^18.2.0", | ||
| "react-redux": "^8.1.3", | ||
| "react-sparklines": "^1.7.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^18.2.15", | ||
| "@types/react-dom": "^18.2.7", | ||
| "@vitejs/plugin-react": "^4.0.3", | ||
| "eslint": "^8.45.0", | ||
| "eslint-plugin-react": "^7.32.2", | ||
| "eslint-plugin-react-hooks": "^4.6.0", | ||
| "eslint-plugin-react-refresh": "^0.4.3", | ||
| "vite": "^4.4.5" | ||
| } | ||
| } |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { useState } from 'react'; | ||
| import Container from 'react-bootstrap/Container'; | ||
| import Row from 'react-bootstrap/Row'; | ||
| import Col from 'react-bootstrap/Col'; | ||
| import Button from 'react-bootstrap/Button'; | ||
| import Form from 'react-bootstrap/Form'; | ||
| import InputGroup from 'react-bootstrap/InputGroup'; | ||
|
|
||
| import { useDispatch } from 'react-redux'; | ||
| import WeatherTable from './components/WeatherTable'; | ||
| import { searchForCity } from './reducers/weatherSlice'; | ||
|
|
||
| function App() { | ||
| const [search, setSearch] = useState(''); | ||
| const dispatch = useDispatch(); | ||
|
|
||
| const handleInput = (event) => { | ||
| setSearch(event.target.value); | ||
| }; | ||
|
|
||
| const handleSearchButton = () => { | ||
| if (search !== '') { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could be simplified to if (search) - review the concept of truthy and falsy |
||
| dispatch(searchForCity(search)); | ||
| setSearch(''); | ||
| } | ||
| }; | ||
|
|
||
| const handleEnterKey = (event) => { | ||
| if (event.key === 'Enter' && search !== '') { | ||
| dispatch(searchForCity(search)); | ||
| setSearch(''); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <Container fluid="md"> | ||
| <Row> | ||
| <Col> | ||
| <InputGroup className="mb-3 mt-3"> | ||
| <Form.Control | ||
| placeholder="Search for a city" | ||
| aria-label="Search for a city" | ||
| value={search} | ||
| onChange={handleInput} | ||
| onKeyDown={handleEnterKey} | ||
| /> | ||
| <Button | ||
| variant="outline-secondary" | ||
| id="search-button" | ||
| onClick={handleSearchButton} | ||
| > | ||
| Search | ||
| </Button> | ||
| </InputGroup> | ||
| </Col> | ||
| </Row> | ||
| <WeatherTable /> | ||
| </Container> | ||
| ); | ||
| } | ||
|
|
||
| export default App; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import Row from 'react-bootstrap/Row'; | ||
| import Col from 'react-bootstrap/Col'; | ||
|
|
||
| import { useSelector } from 'react-redux'; | ||
| import WeatherTableList from './WeatherTableList'; | ||
|
|
||
| export default function WeatherTable() { | ||
| const currentCity = useSelector((state) => state.weather.currentSearch); | ||
|
|
||
| return ( | ||
| <> | ||
| <hr /> | ||
| <Row className="text-center"> | ||
| <Col>City</Col> | ||
| <Col>Temperature (F)</Col> | ||
| <Col>Pressure (hPa)</Col> | ||
| <Col>Humidity (%)</Col> | ||
| </Row> | ||
| <hr /> | ||
| {currentCity !== '' ? ( | ||
| <WeatherTableList /> | ||
| ) : ( | ||
| <h4 className="text-center"> | ||
| Search for a city to see weather data displayed here | ||
| </h4> | ||
| )} | ||
| </> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally you don't check .env into your repo cause it exposes things that shouldn't be public like keys. you would want to put this in your .gitignore