diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..4d29575 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..9c40dcd --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,68 @@ +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). + +## Available Scripts + +In the project directory, you can run: + +### `yarn start` + +Runs the app in the development mode.
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.
+You will also see any lint errors in the console. + +### `yarn test` + +Launches the test runner in the interactive watch mode.
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `yarn build` + +Builds the app for production to the `build` folder.
+It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.
+Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `yarn eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). + +### Code Splitting + +This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting + +### Analyzing the Bundle Size + +This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size + +### Making a Progressive Web App + +This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app + +### Advanced Configuration + +This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration + +### Deployment + +This section has moved here: https://facebook.github.io/create-react-app/docs/deployment + +### `yarn build` fails to minify + +This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..8f5eb2c --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,37 @@ +{ + "name": "frontend", + "version": "0.1.0", + "private": true, + "dependencies": { + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.3.2", + "@testing-library/user-event": "^7.1.2", + "axios": "^0.19.2", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-icons": "^3.9.0", + "react-router-dom": "^5.1.2", + "react-scripts": "3.4.1" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": "react-app" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico new file mode 100644 index 0000000..bcd5dfd Binary files /dev/null and b/frontend/public/favicon.ico differ diff --git a/frontend/public/index.html b/frontend/public/index.html new file mode 100644 index 0000000..7e3c8c1 --- /dev/null +++ b/frontend/public/index.html @@ -0,0 +1,15 @@ + + + + + + + + + Be The Hero + + + +
+ + diff --git a/frontend/src/App.js b/frontend/src/App.js new file mode 100644 index 0000000..be4eb88 --- /dev/null +++ b/frontend/src/App.js @@ -0,0 +1,13 @@ +import React from 'react'; + +import './global.css'; + +import Routes from './routes'; + +function App() { + return ( + + ); +} + +export default App; diff --git a/frontend/src/assets/heroes.png b/frontend/src/assets/heroes.png new file mode 100644 index 0000000..c3e7f47 Binary files /dev/null and b/frontend/src/assets/heroes.png differ diff --git a/frontend/src/assets/logo.svg b/frontend/src/assets/logo.svg new file mode 100644 index 0000000..a586316 --- /dev/null +++ b/frontend/src/assets/logo.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/frontend/src/global.css b/frontend/src/global.css new file mode 100644 index 0000000..48506a9 --- /dev/null +++ b/frontend/src/global.css @@ -0,0 +1,83 @@ +@import url('https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap'); + +* { + margin: 0; + padding: 0; + outline: 0; + box-sizing: border-box; +} + +body { + font: 400 14px Roboto, sans-serif; + background: #f0f0f5; + -webkit-font-smoothing: antialiased; +} + +input, buttons, textarea { + font: 400 18px Roboto, sans-serif; +} + +button { + cursor: pointer; +} + +form input { + width: 100%; + height: 60px; + color: #333; + border: 1px solid #dcdce6; + border-radius: 8px; + padding: 0 24px; +} + +form textarea { + width: 100%; + resize: vertical; + min-height: 140px; + color: #333; + border: 1px solid #dcdce6; + border-radius: 8px; + padding: 16px 24px; + line-height: 24px; +} + +.button { + width: 100%; + height: 60px; + background: #e02041; + border: 0; + border-radius: 8px; + color: #fff; + font-weight: 700; + margin-top: 16px; + display: inline-block; + text-align: center; + text-decoration: none; + font-size: 18px; + line-height: 60px; + transition: filter 0.2s; +} + +.button:hover { + filter: brightness(90%); +} + + +.back-link { + display: flex; + align-items: center; + margin-top: 40px; + color: #41414d; + font-size: 18px; + text-decoration: none; + font-weight: 500; + transition: opacity 0.2s; +} + +.back-link svg { + margin-right: 8px; +} + +.back-link:hover { + opacity: 0.8; +} \ No newline at end of file diff --git a/frontend/src/index.js b/frontend/src/index.js new file mode 100644 index 0000000..dbe51b5 --- /dev/null +++ b/frontend/src/index.js @@ -0,0 +1,5 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +ReactDOM.render(, document.getElementById('root')); \ No newline at end of file diff --git a/frontend/src/pages/Login/index.js b/frontend/src/pages/Login/index.js new file mode 100644 index 0000000..40af31a --- /dev/null +++ b/frontend/src/pages/Login/index.js @@ -0,0 +1,57 @@ +import React, { useState } from 'react'; +import { Link, useHistory } from 'react-router-dom'; +import { FiLogIn } from 'react-icons/fi'; + +import api from '../../services/api'; +import './styles.css'; + +import logoImage from '../../assets/logo.svg'; +import heroesImage from '../../assets/heroes.png'; + +function Login() { + const [id, setID] = useState(''); + const history = useHistory(); + + async function handleLogin(e) { + e.preventDefault(); + + try { + const response = await api.post('sessions', { id }); + + localStorage.setItem('userID', id); + localStorage.setItem('userName', response.data.name); + + history.push('/profile') + } catch { + alert('Login error, try again later.') + } + } + + return ( +
+
+ Be The Hero + +
+

Login Now

+ + setID(e.target.value) } + /> + + + + + Don't have an account + + +
+ + heroes +
+ ); +} + +export default Login; \ No newline at end of file diff --git a/frontend/src/pages/Login/styles.css b/frontend/src/pages/Login/styles.css new file mode 100644 index 0000000..36c3e11 --- /dev/null +++ b/frontend/src/pages/Login/styles.css @@ -0,0 +1,26 @@ +.login-container { + width: 100%; + max-width: 1120px; + height: 100vh; + margin: 0 auto; + + display: flex; + align-items: center; + justify-content: space-between; +} + +.login-container section.form { + width: 100%; + max-width: 350px; + margin-right: 30px; +} + +.login-container section.form form { + margin-top: 100px; + +} + +.login-container section.form form h1 { + font-size: 32px; + margin-bottom: 32px; +} \ No newline at end of file diff --git a/frontend/src/pages/NewRequest/index.js b/frontend/src/pages/NewRequest/index.js new file mode 100644 index 0000000..3be89d7 --- /dev/null +++ b/frontend/src/pages/NewRequest/index.js @@ -0,0 +1,68 @@ +import React, { useState } from 'react'; +import { Link, useHistory } from 'react-router-dom'; +import { FiArrowLeft } from 'react-icons/fi'; + +import api from '../../services/api'; + +import './styles.css' +import logoImage from '../../assets/logo.svg'; + +export default function NewRequest() { + const [title, setTitle] = useState(''); + const [body, setBody] = useState(''); + const userID = localStorage.getItem('userID'); + const history = useHistory(); + + async function handleNewRequest(e) { + e.preventDefault(); + + const data = { + title, + body + } + + try { + await api.post('help-requests', data, { + headers: { + Authorization: userID + } + }); + + history.push('/profile'); + } catch { + alert('Error submitting your request, try again later.'); + } + } + + return ( +
+
+
+ Be The Hero + +

Request help

+

Describe your request in close details in order to find a hero willing to help.

+ + + + Back to profile + +
+ +
+ setTitle(e.target.value)} + /> +