From 4594254f04df899b721cbdeab435ee4586241c06 Mon Sep 17 00:00:00 2001 From: Andre Emiliano Date: Mon, 5 Jul 2021 14:22:01 +0000 Subject: [PATCH] Final changes --- package-lock.json | 181 +----------------------- package.json | 1 - src/App.test.js | 13 +- src/components/account.js | 14 +- src/components/application.js | 7 +- src/components/applicationcardAdmins.js | 5 +- src/components/applicationcardUsers.js | 10 +- src/components/applicationsForUsers.js | 7 +- src/components/contact.js | 3 +- src/components/newApplication.js | 6 +- src/components/register.js | 6 +- src/components/usercard.js | 5 +- src/components/usersgrid.js | 4 +- src/components/usersinfo.js | 2 +- 14 files changed, 33 insertions(+), 231 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6bf0189..437d391 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "React-JS-FrontEnd", "version": "0.1.0", "dependencies": { "@ant-design/icons": "^4.2.2", @@ -21,7 +22,6 @@ "react-router-dom": "^5.2.0", "react-scripts": "4.0.0", "react-select": "^4.3.1", - "reactstrap": "^8.9.0", "save": "^2.4.0", "web-vitals": "^0.2.4" }, @@ -1503,19 +1503,6 @@ "@hapi/hoek": "^8.3.0" } }, - "node_modules/@hypnosphi/create-react-context": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@hypnosphi/create-react-context/-/create-react-context-0.3.1.tgz", - "integrity": "sha512-V1klUed202XahrWJLLOT3EXNeCpFHCcJntdFGI15ntCwau+jfT386w7OFTMaCqOgXUH1fa0w/I1oZs+i/Rfr0A==", - "dependencies": { - "gud": "^1.0.0", - "warning": "^4.0.3" - }, - "peerDependencies": { - "prop-types": "^15.0.0", - "react": ">=0.14.0" - } - }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -8128,11 +8115,6 @@ "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", "optional": true }, - "node_modules/gud": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz", - "integrity": "sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw==" - }, "node_modules/gzip-size": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.1.1.tgz", @@ -12649,16 +12631,6 @@ "node": ">=6" } }, - "node_modules/popper.js": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz", - "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==", - "deprecated": "You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/popperjs" - } - }, "node_modules/portfinder": { "version": "1.0.28", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.28.tgz", @@ -14880,23 +14852,6 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, - "node_modules/react-popper": { - "version": "1.3.11", - "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-1.3.11.tgz", - "integrity": "sha512-VSA/bS+pSndSF2fiasHK/PTEEAyOpX60+H5EPAjoArr8JGm+oihu4UbrqcEBpQibJxBVCpYyjAX7abJ+7DoYVg==", - "dependencies": { - "@babel/runtime": "^7.1.2", - "@hypnosphi/create-react-context": "^0.3.1", - "deep-equal": "^1.1.1", - "popper.js": "^1.14.4", - "prop-types": "^15.6.1", - "typed-styles": "^0.0.7", - "warning": "^4.0.2" - }, - "peerDependencies": { - "react": "0.14.x || ^15.0.0 || ^16.0.0 || ^17.0.0" - } - }, "node_modules/react-refresh": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz", @@ -15043,56 +14998,6 @@ "react-dom": ">=16.6.0" } }, - "node_modules/reactstrap": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/reactstrap/-/reactstrap-8.9.0.tgz", - "integrity": "sha512-pmf33YjpNZk1IfrjqpWCUMq9hk6GzSnMWBAofTBNIRJQB1zQ0Au2kzv3lPUAFsBYgWEuI9iYa/xKXHaboSiMkQ==", - "dependencies": { - "@babel/runtime": "^7.12.5", - "classnames": "^2.2.3", - "prop-types": "^15.5.8", - "react-popper": "^1.3.6", - "react-transition-group": "^2.3.1" - }, - "peerDependencies": { - "react": ">=16.3.0", - "react-dom": ">=16.3.0" - } - }, - "node_modules/reactstrap/node_modules/@babel/runtime": { - "version": "7.14.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.6.tgz", - "integrity": "sha512-/PCB2uJ7oM44tz8YhC4Z/6PeOKXp4K588f+5M3clr1M4zbqztlo0XEfJ2LEzj/FgwfgGcIdl8n7YYjTCI0BYwg==", - "dependencies": { - "regenerator-runtime": "^0.13.4" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/reactstrap/node_modules/dom-helpers": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz", - "integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==", - "dependencies": { - "@babel/runtime": "^7.1.2" - } - }, - "node_modules/reactstrap/node_modules/react-transition-group": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.9.0.tgz", - "integrity": "sha512-+HzNTCHpeQyl4MJ/bdE0u6XRMe9+XG/+aL4mCxVN4DnPBQ0/5bfHWPDuOZUzYdMj94daZaZdCCc1Dzt9R/xSSg==", - "dependencies": { - "dom-helpers": "^3.4.0", - "loose-envify": "^1.4.0", - "prop-types": "^15.6.2", - "react-lifecycles-compat": "^3.0.4" - }, - "peerDependencies": { - "react": ">=15.0.0", - "react-dom": ">=15.0.0" - } - }, "node_modules/read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -18153,11 +18058,6 @@ "node": ">= 0.6" } }, - "node_modules/typed-styles": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/typed-styles/-/typed-styles-0.0.7.tgz", - "integrity": "sha512-pzP0PWoZUhsECYjABgCGQlRGL1n7tOHsgwYv3oIiEpJwGhFTuty/YNeduxQYzXXa3Ge5BdT6sHYIQYpl4uJ+5Q==" - }, "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -21785,15 +21685,6 @@ "@hapi/hoek": "^8.3.0" } }, - "@hypnosphi/create-react-context": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@hypnosphi/create-react-context/-/create-react-context-0.3.1.tgz", - "integrity": "sha512-V1klUed202XahrWJLLOT3EXNeCpFHCcJntdFGI15ntCwau+jfT386w7OFTMaCqOgXUH1fa0w/I1oZs+i/Rfr0A==", - "requires": { - "gud": "^1.0.0", - "warning": "^4.0.3" - } - }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -27365,11 +27256,6 @@ "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", "optional": true }, - "gud": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz", - "integrity": "sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw==" - }, "gzip-size": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.1.1.tgz", @@ -31066,11 +30952,6 @@ "ts-pnp": "^1.1.6" } }, - "popper.js": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz", - "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==" - }, "portfinder": { "version": "1.0.28", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.28.tgz", @@ -32959,20 +32840,6 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, - "react-popper": { - "version": "1.3.11", - "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-1.3.11.tgz", - "integrity": "sha512-VSA/bS+pSndSF2fiasHK/PTEEAyOpX60+H5EPAjoArr8JGm+oihu4UbrqcEBpQibJxBVCpYyjAX7abJ+7DoYVg==", - "requires": { - "@babel/runtime": "^7.1.2", - "@hypnosphi/create-react-context": "^0.3.1", - "deep-equal": "^1.1.1", - "popper.js": "^1.14.4", - "prop-types": "^15.6.1", - "typed-styles": "^0.0.7", - "warning": "^4.0.2" - } - }, "react-refresh": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz", @@ -33099,47 +32966,6 @@ "prop-types": "^15.6.2" } }, - "reactstrap": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/reactstrap/-/reactstrap-8.9.0.tgz", - "integrity": "sha512-pmf33YjpNZk1IfrjqpWCUMq9hk6GzSnMWBAofTBNIRJQB1zQ0Au2kzv3lPUAFsBYgWEuI9iYa/xKXHaboSiMkQ==", - "requires": { - "@babel/runtime": "^7.12.5", - "classnames": "^2.2.3", - "prop-types": "^15.5.8", - "react-popper": "^1.3.6", - "react-transition-group": "^2.3.1" - }, - "dependencies": { - "@babel/runtime": { - "version": "7.14.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.6.tgz", - "integrity": "sha512-/PCB2uJ7oM44tz8YhC4Z/6PeOKXp4K588f+5M3clr1M4zbqztlo0XEfJ2LEzj/FgwfgGcIdl8n7YYjTCI0BYwg==", - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, - "dom-helpers": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz", - "integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==", - "requires": { - "@babel/runtime": "^7.1.2" - } - }, - "react-transition-group": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.9.0.tgz", - "integrity": "sha512-+HzNTCHpeQyl4MJ/bdE0u6XRMe9+XG/+aL4mCxVN4DnPBQ0/5bfHWPDuOZUzYdMj94daZaZdCCc1Dzt9R/xSSg==", - "requires": { - "dom-helpers": "^3.4.0", - "loose-envify": "^1.4.0", - "prop-types": "^15.6.2", - "react-lifecycles-compat": "^3.0.4" - } - } - } - }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -35708,11 +35534,6 @@ "mime-types": "~2.1.24" } }, - "typed-styles": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/typed-styles/-/typed-styles-0.0.7.tgz", - "integrity": "sha512-pzP0PWoZUhsECYjABgCGQlRGL1n7tOHsgwYv3oIiEpJwGhFTuty/YNeduxQYzXXa3Ge5BdT6sHYIQYpl4uJ+5Q==" - }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", diff --git a/package.json b/package.json index ce0987e..6693c28 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "react-router-dom": "^5.2.0", "react-scripts": "4.0.0", "react-select": "^4.3.1", - "reactstrap": "^8.9.0", "save": "^2.4.0", "web-vitals": "^0.2.4" }, diff --git a/src/App.test.js b/src/App.test.js index 3e29d7a..48883b7 100644 --- a/src/App.test.js +++ b/src/App.test.js @@ -1,4 +1,5 @@ import { render, screen, fireEvent } from '@testing-library/react'; +import React from 'react'; import App from './App'; @@ -9,16 +10,4 @@ describe('App', () => { expect(screen.getByRole('menu')).toBeInTheDocument(); }); - test('allows search', () => { - render(); - - screen.debug(); - - fireEvent.change(screen.getByRole('textbox'), { - target: { value: 'JavaScript' }, - }); - - screen.debug(); - }); - }); diff --git a/src/components/account.js b/src/components/account.js index ca74036..9e1773e 100644 --- a/src/components/account.js +++ b/src/components/account.js @@ -2,7 +2,6 @@ import React from 'react'; import { withRouter } from 'react-router'; import { Image, Row, Col, Typography, Button, Form, Input } from 'antd'; import { status, json } from '../utilities/requestHandlers'; -import { Link } from "react-router-dom"; import UserContext from '../contexts/user'; @@ -70,6 +69,11 @@ class Account extends React.Component { .then(data => { console.log(data); alert("User Updated!") + if (this.context.user.role === "admin" ){ + this.props.history.push('/adminSpace') + }else{ + this.props.history.push('/') + } }) .catch(errorResponse => { console.log(errorResponse) @@ -92,7 +96,7 @@ render() {
- + {user.firstName} {user.lastName} @@ -108,9 +112,6 @@ render() { - - - @@ -118,9 +119,6 @@ render() { - - - diff --git a/src/components/application.js b/src/components/application.js index 60b6565..3325218 100644 --- a/src/components/application.js +++ b/src/components/application.js @@ -2,7 +2,6 @@ import React from 'react'; import { withRouter } from 'react-router'; import { Image, Row, Col, Typography, Space, Button, Form, Select } from 'antd'; import { status, json } from '../utilities/requestHandlers'; -import { Link } from "react-router-dom"; import UserContext from '../contexts/user'; @@ -73,6 +72,7 @@ class Application extends React.Component { .then(data => { console.log(data); alert("Application Updated!") + this.props.history.push('/adminSpace') }) .catch(errorResponse => { console.log(errorResponse) @@ -133,7 +133,7 @@ render() {
- + {application.companyName} @@ -154,9 +154,6 @@ render() { - - - diff --git a/src/components/applicationcardAdmins.js b/src/components/applicationcardAdmins.js index 2ab2c16..41f7def 100644 --- a/src/components/applicationcardAdmins.js +++ b/src/components/applicationcardAdmins.js @@ -9,12 +9,11 @@ class ApplicationCard extends React.Component { /** Renders all the structure with the data using the application ID */ render() { - const applicationID = this.props.ID; return ( - + } + cover={} hoverable={true}> diff --git a/src/components/applicationcardUsers.js b/src/components/applicationcardUsers.js index 7917fb0..2882052 100644 --- a/src/components/applicationcardUsers.js +++ b/src/components/applicationcardUsers.js @@ -5,15 +5,15 @@ import NavImage from './navimage'; const { Meta } = Card; -class ApplicationItem extends React.Component { +class ApplicationCard extends React.Component { -/** Renders the page using Application Card and filters the search query */ +/** Renders all the structure with the data using the application ID */ render() { return( - + } + cover={} hoverable={true}> @@ -22,4 +22,4 @@ class ApplicationItem extends React.Component { } } -export default ApplicationItem; \ No newline at end of file +export default ApplicationCard; \ No newline at end of file diff --git a/src/components/applicationsForUsers.js b/src/components/applicationsForUsers.js index a270ded..e4d5b5e 100644 --- a/src/components/applicationsForUsers.js +++ b/src/components/applicationsForUsers.js @@ -26,10 +26,9 @@ class ApplicationForUsers extends React.Component { * @returns {object} The data about the application that is associated to the user */ componentDidMount() { - const id = this.props.match.params.id; // available using withRouter() + const id = this.props.match.params.id; const username = this.context.user.username const password = this.context.user.password - const userid = this.context.user.ID fetch(`https://animal-hello-3000.codio-box.uk/api/v1/applications/myapplications/${id}`, { method: 'GET', headers: { @@ -42,7 +41,7 @@ class ApplicationForUsers extends React.Component { this.setState({application:application}) }) .catch(err => { - console.log(`Fetch error for application ${userid}`) + console.log('Fetch error for application') }); }; @@ -67,7 +66,7 @@ render() {
- + {application.companyName} diff --git a/src/components/contact.js b/src/components/contact.js index 30a011c..1b8232e 100644 --- a/src/components/contact.js +++ b/src/components/contact.js @@ -2,7 +2,7 @@ import React from 'react'; import UserContext from '../contexts/user'; import { Typography, Button, Input } from 'antd'; import { withRouter } from 'react-router'; -import emailjs from 'emailjs-com'; + const { Title } = Typography; const { TextArea } = Input; @@ -25,6 +25,7 @@ class ContactForm extends React.Component { */ sendEmail(e){ e.preventDefault(); + const emailjs = require("emailjs-com") emailjs.sendForm('gmail', 'template_tld', e.target, 'user_4pQL25dW7YNzoZmVCML9j') //Details to identify the emailjs account and template .then((result) => { diff --git a/src/components/newApplication.js b/src/components/newApplication.js index 28f9ee4..c8a9090 100644 --- a/src/components/newApplication.js +++ b/src/components/newApplication.js @@ -2,7 +2,7 @@ import React from 'react'; import { status, json } from '../utilities/requestHandlers'; import { Form, Input, Button, Typography, DatePicker } from 'antd'; import UserContext from '../contexts/user'; -import { Link } from "react-router-dom"; +import { withRouter } from 'react-router'; const { Title } = Typography; @@ -69,6 +69,7 @@ class NewApplication extends React.Component { .then(data => { console.log(data) alert("Application added!") + this.props.history.push('/') }) .catch(err => { console.log(err) @@ -124,7 +125,6 @@ class NewApplication extends React.Component { - @@ -133,4 +133,4 @@ class NewApplication extends React.Component { }; }; -export default NewApplication; \ No newline at end of file +export default withRouter(NewApplication); \ No newline at end of file diff --git a/src/components/register.js b/src/components/register.js index be52e9e..639d933 100644 --- a/src/components/register.js +++ b/src/components/register.js @@ -1,7 +1,7 @@ import React from 'react'; import { Form, Input, Button, Typography } from 'antd'; import { status, json } from '../utilities/requestHandlers'; -import { Link } from 'react-router-dom'; +import { withRouter } from 'react-router'; const { Title } = Typography; @@ -96,6 +96,7 @@ class RegistrationForm extends React.Component { .then(data => { console.log(data); alert("User added!") + this.props.history.push('/login') }) .catch(err => { alert("Error adding user!"); @@ -143,11 +144,10 @@ class RegistrationForm extends React.Component { - ); }; }; -export default RegistrationForm; +export default withRouter(RegistrationForm); diff --git a/src/components/usercard.js b/src/components/usercard.js index 9816239..3469719 100644 --- a/src/components/usercard.js +++ b/src/components/usercard.js @@ -9,12 +9,11 @@ class UserCard extends React.Component { /** Renders all the structure with the data using the user ID */ render() { - const userID = this.props.ID; return ( - + } + cover={} hoverable={true}> diff --git a/src/components/usersgrid.js b/src/components/usersgrid.js index 6e7bec6..e760fad 100644 --- a/src/components/usersgrid.js +++ b/src/components/usersgrid.js @@ -81,7 +81,7 @@ class UsersGrid extends React.Component { }); return (
-
- - + {user.firstName} {user.lastName}