Skip to content
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

Declan casey #803

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions myfriends/.eslintcache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\index.js":"1","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\App.js":"2","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\reportWebVitals.js":"3","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\Header.js":"4","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\Login.js":"5","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\utils\\axiosWithAuth.js":"6","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\PrivateRoute.js":"7","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\FriendList.js":"8","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\Friend.js":"9"},{"size":564,"mtime":1611699976283,"results":"10","hashOfConfig":"11"},{"size":611,"mtime":1611728111217,"results":"12","hashOfConfig":"11"},{"size":362,"mtime":499162500000,"results":"13","hashOfConfig":"11"},{"size":734,"mtime":1611731469986,"results":"14","hashOfConfig":"11"},{"size":1332,"mtime":1611720997692,"results":"15","hashOfConfig":"11"},{"size":273,"mtime":1611724046293,"results":"16","hashOfConfig":"11"},{"size":451,"mtime":1611724296026,"results":"17","hashOfConfig":"11"},{"size":2087,"mtime":1611728702496,"results":"18","hashOfConfig":"11"},{"size":277,"mtime":1611728784622,"results":"19","hashOfConfig":"11"},{"filePath":"20","messages":"21","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"22","usedDeprecatedRules":"23"},"53fcux",{"filePath":"24","messages":"25","errorCount":0,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":"26","usedDeprecatedRules":"23"},{"filePath":"27","messages":"28","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"23"},{"filePath":"29","messages":"30","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"31","usedDeprecatedRules":"23"},{"filePath":"32","messages":"33","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"23"},{"filePath":"34","messages":"35","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"36"},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"23"},{"filePath":"39","messages":"40","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"41","usedDeprecatedRules":"23"},{"filePath":"42","messages":"43","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"23"},"C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\index.js",["44","45","46"],"import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport reportWebVitals from './reportWebVitals';\nimport { BrowserRouter as Router, Route, Link, Switch } from 'react-router-dom';\n\nReactDOM.render(\n <Router>\n <App />\n </Router>\n ,\n document.getElementById('root')\n);\n\n// If you want to start measuring performance in your app, pass a function\n// to log results (for example: reportWebVitals(console.log))\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\nreportWebVitals();\n",["47","48"],"C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\App.js",["49","50","51","52","53"],"import logo from './logo.svg';\nimport './App.css';\nimport { BrowserRouter as Router, Route, Link, Switch } from 'react-router-dom';\nimport Header from \"./components/Header\"\nimport Login from \"./components/Login\"\nimport axios from 'axios';\nimport PrivateRoute from \"./components/PrivateRoute\"\nimport FriendList from \"./components/FriendList\"\nconsole.log(localStorage.getItem('token'))\nfunction App() {\n\n return (\n <div className=\"App\">\n <Header/>\n <Route path = \"/login\" component = {Login}/>\n <PrivateRoute path= \"/protected\" component = {FriendList}/>\n </div>\n );\n}\n\nexport default App;\n","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\reportWebVitals.js",[],"C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\Header.js",["54","55","56"],"import React from 'react'\r\nimport { BrowserRouter as Router, Route, Link, Switch } from 'react-router-dom';\r\nimport {axiosWithAuth} from \"../utils/axiosWithAuth\"\r\n\r\nfunction Header() {\r\n const logout = () => {\r\n axiosWithAuth()\r\n .post('/login')\r\n .then(res=>{\r\n localStorage.removeItem('token');\r\n window.location.href = '/login';\r\n })\r\n .catch(err=>{\r\n console.log(err);\r\n })\r\n };\r\n return (\r\n <div>\r\n <Link to = \"/login\">Login</Link><br></br>\r\n <Link onClick = {logout}>Logout</Link><br></br>\r\n <Link to = \"/protected\">List of Friends</Link>\r\n </div>\r\n )\r\n}\r\n\r\nexport default Header\r\n","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\Login.js",[],"C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\utils\\axiosWithAuth.js",[],["57","58"],"C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\PrivateRoute.js",[],"C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\FriendList.js",["59","60","61"],"import axios from \"axios\"\r\nimport { axiosWithAuth } from \"./../utils/axiosWithAuth\";\r\nimport React, { useState, useEffect } from \"react\";\r\nimport Friend from \"./Friend\"\r\n\r\n\r\nconst initialFormValues = {\r\n name: \"\",\r\n age: null,\r\n email: \"\",\r\n };\r\n const initialState = [];\r\n\r\nfunction FriendList() {\r\n const [friendList, setFriendList] = useState(initialState);\r\n const [formValues, setFormValues] = useState(initialFormValues);\r\n \r\n const token = localStorage.getItem(\"token\");\r\n \r\n const handleChange = (e) => {\r\n setFormValues({\r\n ...formValues,\r\n [e.target.name]: e.target.value\r\n })\r\n }\r\n \r\n const onSubmit = (e) => {\r\n e.preventDefault(); \r\n axiosWithAuth()\r\n .post(\"http://localhost:5000/api/friends\", formValues)\r\n .then(res => {\r\n setFriendList(res.data);\r\n })\r\n \r\n }\r\n\r\n useEffect(async () => {\r\n try {\r\n const { data } = await axiosWithAuth().get(\r\n \"http://localhost:5000/api/friends\"\r\n );\r\n setFriendList(data);\r\n console.table(data);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }, []);\r\n\r\n return (\r\n <div>\r\n <form onSubmit = {onSubmit}>\r\n <input \r\n type = \"text\"\r\n name = \"name\" \r\n values = {formValues.name}\r\n onChange = {handleChange}\r\n ></input>\r\n <input\r\n type = \"email\"\r\n name = \"email\"\r\n values = {formValues.email}\r\n onChange = {handleChange}\r\n ></input>\r\n <input\r\n type = \"number\"\r\n name = \"age\"\r\n values = {formValues.age}\r\n onChange = {handleChange}\r\n ></input>\r\n <button>Add</button>\r\n </form>\r\n {friendList.map((friend) => {\r\n return <Friend friend={friend} />;\r\n })}\r\n </div>\r\n )\r\n}\r\n\r\nexport default FriendList\r\n","C:\\Users\\dpc99\\Documents\\lambdaprojects\\Auth-Friends\\myfriends\\src\\components\\Friend.js",[],{"ruleId":"62","severity":1,"message":"63","line":6,"column":35,"nodeType":"64","messageId":"65","endLine":6,"endColumn":40},{"ruleId":"62","severity":1,"message":"66","line":6,"column":42,"nodeType":"64","messageId":"65","endLine":6,"endColumn":46},{"ruleId":"62","severity":1,"message":"67","line":6,"column":48,"nodeType":"64","messageId":"65","endLine":6,"endColumn":54},{"ruleId":"68","replacedBy":"69"},{"ruleId":"70","replacedBy":"71"},{"ruleId":"62","severity":1,"message":"72","line":1,"column":8,"nodeType":"64","messageId":"65","endLine":1,"endColumn":12},{"ruleId":"62","severity":1,"message":"73","line":3,"column":27,"nodeType":"64","messageId":"65","endLine":3,"endColumn":33},{"ruleId":"62","severity":1,"message":"66","line":3,"column":42,"nodeType":"64","messageId":"65","endLine":3,"endColumn":46},{"ruleId":"62","severity":1,"message":"67","line":3,"column":48,"nodeType":"64","messageId":"65","endLine":3,"endColumn":54},{"ruleId":"62","severity":1,"message":"74","line":6,"column":8,"nodeType":"64","messageId":"65","endLine":6,"endColumn":13},{"ruleId":"62","severity":1,"message":"73","line":2,"column":27,"nodeType":"64","messageId":"65","endLine":2,"endColumn":33},{"ruleId":"62","severity":1,"message":"63","line":2,"column":35,"nodeType":"64","messageId":"65","endLine":2,"endColumn":40},{"ruleId":"62","severity":1,"message":"67","line":2,"column":48,"nodeType":"64","messageId":"65","endLine":2,"endColumn":54},{"ruleId":"68","replacedBy":"75"},{"ruleId":"70","replacedBy":"76"},{"ruleId":"62","severity":1,"message":"74","line":1,"column":8,"nodeType":"64","messageId":"65","endLine":1,"endColumn":13},{"ruleId":"62","severity":1,"message":"77","line":18,"column":11,"nodeType":"64","messageId":"65","endLine":18,"endColumn":16},{"ruleId":"78","severity":1,"message":"79","line":37,"column":15,"nodeType":"80","endLine":47,"endColumn":8},"no-unused-vars","'Route' is defined but never used.","Identifier","unusedVar","'Link' is defined but never used.","'Switch' is defined but never used.","no-native-reassign",["81"],"no-negated-in-lhs",["82"],"'logo' is defined but never used.","'Router' is defined but never used.","'axios' is defined but never used.",["81"],["82"],"'token' is assigned a value but never used.","react-hooks/exhaustive-deps","Effect callbacks are synchronous to prevent race conditions. Put the async function inside:\n\nuseEffect(() => {\n async function fetchData() {\n // You can await here\n const response = await MyAPI.getData(someId);\n // ...\n }\n fetchData();\n}, [someId]); // Or [] if effect doesn't need props or state\n\nLearn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching","ArrowFunctionExpression","no-global-assign","no-unsafe-negation"]
23 changes: 23 additions & 0 deletions myfriends/.gitignore
Original file line number Diff line number Diff line change
@@ -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*
70 changes: 70 additions & 0 deletions myfriends/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm 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.

### `npm 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.

### `npm run 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.

### `npm run 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](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](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](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](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](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
Loading