From 7f7104c4584fb0f45dcf323257a6852b1074ca2a Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Thu, 25 Mar 2021 23:10:10 +0530 Subject: [PATCH 01/32] Add reactstrap --- package-lock.json | 92 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 94 insertions(+) diff --git a/package-lock.json b/package-lock.json index 81c618c..d201505 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1227,6 +1227,15 @@ "@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", @@ -3646,6 +3655,11 @@ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" }, + "bootstrap": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.0.tgz", + "integrity": "sha512-Io55IuQY3kydzHtbGvQya3H+KorS/M9rSNyfCGCg9WZ4pyT/lCxIlpJgG1GXW/PswzC84Tr2fBYi+7+jFVQQBw==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -4035,6 +4049,11 @@ } } }, + "classnames": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz", + "integrity": "sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==" + }, "clean-css": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", @@ -5083,6 +5102,14 @@ "utila": "~0.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" + } + }, "dom-serializer": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", @@ -6954,6 +6981,11 @@ "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", @@ -10967,6 +10999,11 @@ "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", @@ -12408,6 +12445,25 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "react-lifecycles-compat": { + "version": "3.0.4", + "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", @@ -12479,6 +12535,29 @@ "workbox-webpack-plugin": "5.1.4" } }, + "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" + } + }, + "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" + } + }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -14673,6 +14752,11 @@ "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", @@ -15019,6 +15103,14 @@ "makeerror": "1.0.x" } }, + "warning": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz", + "integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==", + "requires": { + "loose-envify": "^1.0.0" + } + }, "watchpack": { "version": "1.7.5", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.5.tgz", diff --git a/package.json b/package.json index 1c8b277..898ac92 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,11 @@ "@testing-library/jest-dom": "^5.11.10", "@testing-library/react": "^11.2.5", "@testing-library/user-event": "^12.8.3", + "bootstrap": "^4.6.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", + "reactstrap": "^8.9.0", "web-vitals": "^1.1.1" }, "scripts": { From bb83d94fa02e1900087942257d7f2543881bb2bc Mon Sep 17 00:00:00 2001 From: thebinarybot Date: Thu, 25 Mar 2021 23:18:25 +0530 Subject: [PATCH 02/32] add login page --- src/components/loginPage.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/components/loginPage.js diff --git a/src/components/loginPage.js b/src/components/loginPage.js new file mode 100644 index 0000000..e69de29 From e92b19dc3d616faf97286c3741f79fbc555d9c0d Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 01:36:54 +0530 Subject: [PATCH 03/32] Create static layout of attendance page --- src/App.js | 28 +++++++++++------------ src/components/AttendanceCard.js | 36 ++++++++++++++++++++++++++++++ src/components/NavBar.js | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 src/components/AttendanceCard.js create mode 100644 src/components/NavBar.js diff --git a/src/App.js b/src/App.js index 3784575..7b49529 100644 --- a/src/App.js +++ b/src/App.js @@ -1,23 +1,23 @@ import logo from './logo.svg'; import './App.css'; +import NavBar from './components/NavBar.js'; +import AttendanceCard from './components/AttendanceCard.js'; +import { Row, Col } from 'reactstrap'; function App() { return (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+ + + + + + + + +
); } diff --git a/src/components/AttendanceCard.js b/src/components/AttendanceCard.js new file mode 100644 index 0000000..1e8a40b --- /dev/null +++ b/src/components/AttendanceCard.js @@ -0,0 +1,36 @@ +import React from 'react'; +import { + Card, CardImg, CardText, CardBody, + CardTitle, CardSubtitle, Button, Progress, + Row, Col +} from 'reactstrap'; + +const AttendanceCard = (props) => { + return ( +
+ + + {props.courseName} + {props.courseCode} + Attended {props.classesAttended} out of {props.totalClasses} classes + + + + + + + + + + + + + + + +
+ ); +}; + +export default AttendanceCard; diff --git a/src/components/NavBar.js b/src/components/NavBar.js new file mode 100644 index 0000000..4e53ada --- /dev/null +++ b/src/components/NavBar.js @@ -0,0 +1,38 @@ +import React, { useState } from 'react'; +import 'bootstrap/dist/css/bootstrap.css'; +import { + Collapse, + Navbar, + NavbarToggler, + NavbarBrand, + Nav, + NavItem, + NavLink, + UncontrolledDropdown, + DropdownToggle, + DropdownMenu, + DropdownItem, + NavbarText +} from 'reactstrap'; + +const NavBar = (props) => { + const [isOpen, setIsOpen] = useState(false); + + const toggle = () => setIsOpen(!isOpen); + + return ( +
+ + bunkalog + + + +
+ ); +} + +export default NavBar; From ceef7ae77979a1db0ba1045b2fd2ce56f14cbdeb Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 01:43:49 +0530 Subject: [PATCH 04/32] Add axios to the project --- package-lock.json | 13 +++++++++++++ package.json | 3 +++ 2 files changed, 16 insertions(+) diff --git a/package-lock.json b/package-lock.json index d201505..19fd6b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3029,6 +3029,14 @@ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.1.3.tgz", "integrity": "sha512-vwPpH4Aj4122EW38mxO/fxhGKtwWTMLDIJfZ1He0Edbtjcfna/R3YB67yVhezUMzqc3Jr3+Ii50KRntlENL4xQ==" }, + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", @@ -12319,6 +12327,11 @@ "whatwg-fetch": "^3.4.1" } }, + "react-axios": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/react-axios/-/react-axios-2.0.5.tgz", + "integrity": "sha512-NGbOeflZm3Ry3ObiWcK7/ynBFmX0ThjnonTg0KA1AmAYgybERrF0inL5eNJdtyHjmbLXd2y27tf4r0FyHez+QA==" + }, "react-dev-utils": { "version": "11.0.4", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-11.0.4.tgz", diff --git a/package.json b/package.json index 898ac92..c334d36 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,11 @@ "@testing-library/jest-dom": "^5.11.10", "@testing-library/react": "^11.2.5", "@testing-library/user-event": "^12.8.3", + "axios": "^0.21.1", "bootstrap": "^4.6.0", + "prop-types": "^15.7.2", "react": "^17.0.2", + "react-axios": "^2.0.5", "react-dom": "^17.0.2", "react-scripts": "4.0.3", "reactstrap": "^8.9.0", From 6bd42d9dc23968c5c3bff41061c51ae38d69a8af Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 03:17:38 +0530 Subject: [PATCH 05/32] Add fetch data from API server --- src/App.js | 55 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/src/App.js b/src/App.js index 7b49529..9ef460d 100644 --- a/src/App.js +++ b/src/App.js @@ -1,25 +1,60 @@ +import React from 'react'; import logo from './logo.svg'; import './App.css'; import NavBar from './components/NavBar.js'; import AttendanceCard from './components/AttendanceCard.js'; import { Row, Col } from 'reactstrap'; +import axios from 'axios'; + +class App extends React.Component { + constructor(props) { + super(props); + this.state = { + data: {"data": [{ + "courseName": "Loading", + "courseCode": "Loading", + "classesAttended": "Loading", + "totalClasses": "Loading" + }] + }, + }; + this.loadData(); + } + + loadData() { + axios.get("http://192.168.86.129:5000/") + .then( (response) => { + this.setState({data: response}); + }) + .catch( (error) => { + console.log(error); + }) + } + + render() + { + var renderData = this.state.data["data"] + var cards = renderData.map(function(course, index) { + return ( + + + + ); + }) -function App() { return (
- - - - - - - + + {cards} +

{this.state.data["data"]["courseName"]}

); + } } export default App; From 4bcfcef1979458b78fb1358437cef2345f469fe9 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 12:20:12 +0530 Subject: [PATCH 06/32] Add create new course form --- src/components/AddClassForm.js | 25 +++++++++++++++++++++++++ src/components/NavBar.js | 11 ++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/components/AddClassForm.js diff --git a/src/components/AddClassForm.js b/src/components/AddClassForm.js new file mode 100644 index 0000000..4ce6603 --- /dev/null +++ b/src/components/AddClassForm.js @@ -0,0 +1,25 @@ +import React from 'react'; +import { Button, Form, FormGroup, Label, Input, FormText } from 'reactstrap'; + +const AddClass = (props) => { + return ( +
+ + + + + + + + + + + + +
+ ); +} + +export default AddClass; diff --git a/src/components/NavBar.js b/src/components/NavBar.js index 4e53ada..0318704 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -1,5 +1,7 @@ import React, { useState } from 'react'; import 'bootstrap/dist/css/bootstrap.css'; +import AddClassForm from './AddClassForm.js' + import { Collapse, Navbar, @@ -27,7 +29,14 @@ const NavBar = (props) => { From c4255fca6543bffa96fef579c03fa09535dd9e29 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 13:52:16 +0530 Subject: [PATCH 07/32] Add attendance update functionality --- src/App.js | 43 ++++++++++++----------- src/components/AttendanceCard.js | 60 +++++++++++++++++++++++++++----- 2 files changed, 73 insertions(+), 30 deletions(-) diff --git a/src/App.js b/src/App.js index 9ef460d..d11b1c6 100644 --- a/src/App.js +++ b/src/App.js @@ -7,7 +7,7 @@ import { Row, Col } from 'reactstrap'; import axios from 'axios'; class App extends React.Component { - constructor(props) { + constructor(props) { super(props); this.state = { data: {"data": [{ @@ -31,30 +31,31 @@ class App extends React.Component { }) } - render() - { - var renderData = this.state.data["data"] - var cards = renderData.map(function(course, index) { - return ( - - - + render() + { + var renderData = this.state.data["data"] + var cards = renderData.map(function(course, index) { + return ( + + this.loadData()} /> + ); - }) + }); - return ( -
- - + return ( +
+ + {cards} - -

{this.state.data["data"]["courseName"]}

-
+
+

{this.state.data["data"]["courseName"]}

+
); - } + } } export default App; diff --git a/src/components/AttendanceCard.js b/src/components/AttendanceCard.js index 1e8a40b..845fea5 100644 --- a/src/components/AttendanceCard.js +++ b/src/components/AttendanceCard.js @@ -4,33 +4,75 @@ import { CardTitle, CardSubtitle, Button, Progress, Row, Col } from 'reactstrap'; +import axios from 'axios'; -const AttendanceCard = (props) => { +class AttendanceCard extends React.Component { + constructor(props) { + super(props); + this.state = { + name: props.courseCode, + loadData: props.reloadData, + }; + } + + attendClass() { + var url = "http://192.168.86.129:5000/attend-class?courseCode=" + this.state.name; + axios.get(url) + .then( (response) => { + this.state.loadData(); + }) + .catch( (error) => { + console.log(error); + }) + } + + bunkClass() { + var url = "http://192.168.86.129:5000/bunk-class?courseCode=" + this.state.name; + axios.get(url) + .then( (response) => { + this.state.loadData(); + }) + .catch( (error) => { + console.log(error); + }) + } + + render(props) { + this.state.name = this.props.courseCode; return (
- {props.courseName} - {props.courseCode} - Attended {props.classesAttended} out of {props.totalClasses} classes + {this.props.courseName} + {this.props.courseCode} + Attended {this.props.classesAttended} out of {this.props.totalClasses} classes - - + + - - + + + + + +
); + } }; export default AttendanceCard; From 879e78326f63bf95ac5affe82d60bd252b11f497 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:46:18 +0530 Subject: [PATCH 08/32] Add bunk and attend button functionality --- src/components/AddClassForm.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/AddClassForm.js b/src/components/AddClassForm.js index 4ce6603..4d17f09 100644 --- a/src/components/AddClassForm.js +++ b/src/components/AddClassForm.js @@ -1,7 +1,8 @@ import React from 'react'; import { Button, Form, FormGroup, Label, Input, FormText } from 'reactstrap'; -const AddClass = (props) => { +class AddClass extends React.Component { + render() { return (
@@ -14,12 +15,23 @@ const AddClass = (props) => { - -
); + } } export default AddClass; From 4f73f37cdb157141cc56e623a45c4773ab735285 Mon Sep 17 00:00:00 2001 From: thebinarybot Date: Fri, 26 Mar 2021 15:33:06 +0530 Subject: [PATCH 09/32] Add google-sign-in --- public/index.html | 1 + src/App.css | 5 +++ src/App.js | 103 +++++++++++++++++++++++++++++++++++++--------- 3 files changed, 90 insertions(+), 19 deletions(-) diff --git a/public/index.html b/public/index.html index aa069f2..0ccdf7b 100644 --- a/public/index.html +++ b/public/index.html @@ -3,6 +3,7 @@ + -
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
- - ); +class App extends Component { + constructor(props) { + super(props); + + this.state = { + isSignedIn: false, + } + + } + + componentDidMount() { + + const successCallback = this.onSuccess.bind(this); + + window.gapi.load('auth2', () => { + this.auth2 = gapi.auth2.init({ + client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com', + }) + + // this.auth2.attachClickHandler(document.querySelector('#loginButton'), {}, this.onLoginSuccessful.bind(this)) + + this.auth2.then(() => { + console.log('on init'); + this.setState({ + isSignedIn: this.auth2.isSignedIn.get(), + }); + }); + }); + + window.gapi.load('signin2', function() { + // Method 3: render a sign in button + // using this method will show Signed In if the user is already signed in + var opts = { + width: 200, + height: 50, + client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com', + onsuccess: successCallback + } + gapi.signin2.render('loginButton', opts) + }) + } + + onSuccess() { + console.log('on success') + this.setState({ + isSignedIn: true, + err: null + }) + } + + onLoginFailed(err) { + this.setState({ + isSignedIn: false, + error: err, + }) + } + + getContent() { + if (this.state.isSignedIn) { + return

hello user, you're signed in

+ } else { + return ( +
+

You are not signed in. Click here to sign in.

+ +
+ ) + } + + } + + render() { + return ( +
+
+ logo +

Sample App.

+ + {this.getContent()} +
+
+ ); + } } export default App; From 5438c560af150e205965bb6bf2e7cc4fcc44a912 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 16:11:15 +0530 Subject: [PATCH 10/32] Fix GAPI issue --- package-lock.json | 5 +++++ package.json | 1 + src/App.js | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 81c618c..58d7a98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6835,6 +6835,11 @@ "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" }, + "gapi-script": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/gapi-script/-/gapi-script-1.1.0.tgz", + "integrity": "sha512-zpPzI+Ze8OADLLz0w76FOgGUE5WYpANuAJGsI3zB51SzByPmR7gKa8xMSsqhinaFpDQ7lRqvQRstSD2cFwI4Yg==" + }, "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", diff --git a/package.json b/package.json index 1c8b277..d30cc84 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@testing-library/jest-dom": "^5.11.10", "@testing-library/react": "^11.2.5", "@testing-library/user-event": "^12.8.3", + "gapi-script": "^1.1.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", diff --git a/src/App.js b/src/App.js index 526b6b5..bdab474 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,7 @@ import logo from './logo.svg'; import React, {Component} from 'react'; import './App.css'; +import { gapi } from 'gapi-script'; class App extends Component { constructor(props) { @@ -18,7 +19,7 @@ class App extends Component { window.gapi.load('auth2', () => { this.auth2 = gapi.auth2.init({ - client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com', + client_id: '724928841047-2a73bpb9m7hat1v4rhdrkefrtaedmp26.apps.googleusercontent.com', }) // this.auth2.attachClickHandler(document.querySelector('#loginButton'), {}, this.onLoginSuccessful.bind(this)) From 513bd26529b45fe0a8055dcf1eae6914491967b6 Mon Sep 17 00:00:00 2001 From: thebinarybot Date: Fri, 26 Mar 2021 16:21:48 +0530 Subject: [PATCH 11/32] Modify mainpage --- src/App.css | 6 ++++-- src/App.js | 4 ++-- src/BunkaLog.png | Bin 0 -> 2741 bytes 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 src/BunkaLog.png diff --git a/src/App.css b/src/App.css index d98c1dd..c2aede1 100644 --- a/src/App.css +++ b/src/App.css @@ -12,11 +12,12 @@ body { pointer-events: none; } +/* @media (prefers-reduced-motion: no-preference) { .App-logo { animation: App-logo-spin infinite 20s linear; } -} +}*/ .App-header { background-color: #282c34; @@ -33,6 +34,7 @@ body { color: #61dafb; } +/* @keyframes App-logo-spin { from { transform: rotate(0deg); @@ -40,4 +42,4 @@ body { to { transform: rotate(360deg); } -} +} */ diff --git a/src/App.js b/src/App.js index 526b6b5..ea4eaea 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import logo from './logo.svg'; +import logo from './BunkaLog.png'; import React, {Component} from 'react'; import './App.css'; @@ -78,7 +78,7 @@ class App extends Component {
logo -

Sample App.

+

Welcome to BunkaLog.

{this.getContent()}
diff --git a/src/BunkaLog.png b/src/BunkaLog.png new file mode 100644 index 0000000000000000000000000000000000000000..aa0ded8be2ca57077dce4ccc07563ac14227baef GIT binary patch literal 2741 zcmb_ei8mYQ7RQrLQ5CASHN_MyMJb}SHXXGGwUwy7wSvmoc6Mk>sWCy+2{@Ilp_)J>NOM@4NT@?m6ExI~y}$L1{rA9v)!} za}#@R9QuLNr?|e}rQtO<@J861-Qj5rag6rZrU|7#Z~_hPsU4n{6YPF_UbID@F}F?Cf7B5{s(W!Ds$it) zBMJqI@BQ{W#w4*U0QlQgj1SqoOfJ(jNWfM|3;~2_U?h3n@_<0Q+ozS2uPSfsqF26X z&~`|qv5?rp1Y@E=1j&%0`6s6|jzsNzsBhGk5@Yu3mPwm8uOSkD973}Iad z;b=Y)G6ER;HL!)Q#XWQf<`66sJ~N-uw*vhFzJ-*k(HS^@I2G6vlv68{Hc~9dZB({+#-Eyw|v@&`;RUrh&@zd*^uHO+#!Q?A;FivjxKlJ=Z?=i z;#}WOvoy&4CQea3_ zmlQg(JWxwsQlA6%;Y{1@A}a%Hug#$*qJ*-ftq@w-rOlJ>rfm{upmu`Pb@gklT4sNO z&c%bE*C;a^mQ zW+wG0XC7pPr{%1&oxALVtoz8neRAfCn!NLUyDF0DtMcE)8~dr_x{BIKssf`xsl6j0 zI{GjvOq9phcq(^=?O>V5**g>AB`qY#fpJUBKEIQt9W`HES@Q0-A?=d9M$`N3zMY5= zD24^;veZS0tWfT`RfnG(tSg$`~v zAX|LpT@r}hkggP~JUO$+>|Xt`+$13yR`qIg@Cg|gc$rT4T67cnzGo=|8sVp&?1I9k zeip^)RprzgN4K>spU0&_G~6(fYMupTX)E8yB!j7QCjPZDjv47rXD~D8mixA~sj<}s zvPp9fMvt`27oFiZW9{pFfRR=}=3Oy0eZ>(Lfqrds($8NEK)qMQzYEfXdY}8AjUxgV zTo*UNBIa@QT(a*@15;zUajq zM{ge!+v!A_-hd5DY3Rvr)O)kOz_``*r;ATOON(^EY*?7v{(SwO@Im_n3Mb6DEffAK z#p%Ho1~O&|j6bH;e(Y*@nxHd7JK9%dUr>9lpk(b?0RTp(c%H3djIVca$hTMy-ctlO z#odeo0FH0XLns`v+ZfAYX*bG>Z?wnVP#Z8Kq>ftx5uAxogCu6+ai`~F=9?t?(wpYc zGdl@t#$fD`NJ_$@=r|j!HrFtNttsWlp@k4jXSb2hTcTdBh|9LJR0JlSFF-q$P%=$Z zEoi)Fg~+e0Vu44Q$WW}W#Fh5ii75049g7q44q zT>#7^&63b6cUfvUWjo3N-6^~dr8K1T%C;I`Wv47xnofT6$4cgX)@K*tEeXdzcD`8{ z8Hp8R62wd>ohB5Qnu1pr;Omz-k8lkM?1>s?E2|dq)DWux_6A1E_~6&haU>7g^_`z4 zoHO~fPjEpvl(BkSK-g`5DO!-v==4KEC+MK2L4HDOR2cWBxJBZ1*!0o9VSeIUe5@!I z(kL)~k=-urTK~Gg5*&9}ow2#Dx_=%2!J~1UX)Le0Rp$Gouc4<;Sg& zh;`+6V;yITpC#}GUT|Ym{Jn1N=+f-e`B%S`XqbI%^W5HaV%NVJd3(G|h9L>f(5&nv z^;X}h;pfQ#YAvPoG0mtelq{R;6cKshQTOFDH=<)LvMd)-twxi&;E_DJebphbJ|uhu zEuKgZG@|vn4L3UWT!UqrzHhdcykJz!@A@G!j(Owf;Q>^0yloVSpsq2?gd2XCB`L&m zf(T*DY&*qa-0a{y!sER2$AvXTh zQB|0~_=OhQ+Mt_;P3t8?Xw5o`KPEud)8Q7yWAi4mbvqFNYNDbi#eR0i+bqQ&GsgCg zzL67N&oNwG=c0oiq(jCnvnpU5J4NIcMWx7~hwxezTXyse#Sb)hJ_E)bpME7oiWp3#*j?o1bxfjlvAdl7tjVPoi9QL zxCKq@`Y`_x@z+JTF}plirSB8dm}d#HR=@-I$)h>Fv<$>Mkms6AHwYVfVr z&h?F7rQTt7m<=9eyY$NmCM+ z)Y}>C1zY()-`xlfv#GPuv9<7#kQRCV*o#uWI8pUD|Bw>t2~WSkes1|14F%=!Qqn`w zu$=L2Yr@#-!nn7v?`# Date: Fri, 26 Mar 2021 16:24:28 +0530 Subject: [PATCH 12/32] Merge develop and addLoginPage --- package-lock.json | 5 +++ package.json | 1 + public/index.html | 1 + src/App.css | 5 +++ src/App.js | 70 +++++++++++++++++++++++++++++++++++++ src/components/loginPage.js | 0 6 files changed, 82 insertions(+) create mode 100644 src/components/loginPage.js diff --git a/package-lock.json b/package-lock.json index 19fd6b2..a731773 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6870,6 +6870,11 @@ "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" }, + "gapi-script": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/gapi-script/-/gapi-script-1.1.0.tgz", + "integrity": "sha512-zpPzI+Ze8OADLLz0w76FOgGUE5WYpANuAJGsI3zB51SzByPmR7gKa8xMSsqhinaFpDQ7lRqvQRstSD2cFwI4Yg==" + }, "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", diff --git a/package.json b/package.json index c334d36..155edb7 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "axios": "^0.21.1", "bootstrap": "^4.6.0", "prop-types": "^15.7.2", + "gapi-script": "^1.1.0", "react": "^17.0.2", "react-axios": "^2.0.5", "react-dom": "^17.0.2", diff --git a/public/index.html b/public/index.html index aa069f2..0ccdf7b 100644 --- a/public/index.html +++ b/public/index.html @@ -3,6 +3,7 @@ + { + this.auth2 = gapi.auth2.init({ + client_id: '724928841047-2a73bpb9m7hat1v4rhdrkefrtaedmp26.apps.googleusercontent.com', + }) + + // this.auth2.attachClickHandler(document.querySelector('#loginButton'), {}, this.onLoginSuccessful.bind(this)) + + this.auth2.then(() => { + console.log('on init'); + this.setState({ + isSignedIn: this.auth2.isSignedIn.get(), + }); + }); + }); + + window.gapi.load('signin2', function() { + // Method 3: render a sign in button + // using this method will show Signed In if the user is already signed in + var opts = { + width: 200, + height: 50, + client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com', + onsuccess: successCallback + } + gapi.signin2.render('loginButton', opts) + }) + } + + onSuccess() { + console.log('on success') + this.setState({ + isSignedIn: true, + err: null + }) + } + + onLoginFailed(err) { + this.setState({ + isSignedIn: false, + error: err, + }) + } + + getContent() { + if (this.state.isSignedIn) { + return

hello user, you're signed in

+ } else { + return ( +
+

You are not signed in. Click here to sign in.

+ +
+ ) + } + + } + + render() { var renderData = this.state.data["data"] @@ -52,6 +121,7 @@ class App extends React.Component { {cards} + {this.getContent()}

{this.state.data["data"]["courseName"]}

); diff --git a/src/components/loginPage.js b/src/components/loginPage.js new file mode 100644 index 0000000..e69de29 From 12eed66babe92d6b86283379e62b5b563eba92cb Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 16:38:27 +0530 Subject: [PATCH 13/32] Fix warnings --- src/App.js | 2 -- src/components/AddClassForm.js | 2 +- src/components/AttendanceCard.js | 2 +- src/components/NavBar.js | 4 ---- src/logo.svg | 1 - 5 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 src/logo.svg diff --git a/src/App.js b/src/App.js index 36dac78..6d33ea6 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,4 @@ import React from 'react'; -import logo from './logo.svg'; -import {Component} from 'react'; import './App.css'; import { gapi } from 'gapi-script'; import NavBar from './components/NavBar.js'; diff --git a/src/components/AddClassForm.js b/src/components/AddClassForm.js index 4d17f09..eb0f782 100644 --- a/src/components/AddClassForm.js +++ b/src/components/AddClassForm.js @@ -1,5 +1,5 @@ import React from 'react'; -import { Button, Form, FormGroup, Label, Input, FormText } from 'reactstrap'; +import { Button, Form, FormGroup, Label, Input } from 'reactstrap'; class AddClass extends React.Component { render() { diff --git a/src/components/AttendanceCard.js b/src/components/AttendanceCard.js index 845fea5..5ba8623 100644 --- a/src/components/AttendanceCard.js +++ b/src/components/AttendanceCard.js @@ -1,6 +1,6 @@ import React from 'react'; import { - Card, CardImg, CardText, CardBody, + Card, CardText, CardBody, CardTitle, CardSubtitle, Button, Progress, Row, Col } from 'reactstrap'; diff --git a/src/components/NavBar.js b/src/components/NavBar.js index 0318704..441e6c5 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -3,18 +3,14 @@ import 'bootstrap/dist/css/bootstrap.css'; import AddClassForm from './AddClassForm.js' import { - Collapse, Navbar, NavbarToggler, NavbarBrand, Nav, NavItem, - NavLink, UncontrolledDropdown, DropdownToggle, DropdownMenu, - DropdownItem, - NavbarText } from 'reactstrap'; const NavBar = (props) => { diff --git a/src/logo.svg b/src/logo.svg deleted file mode 100644 index 9dfc1c0..0000000 --- a/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 5f468cfcc93ee1e53a5013951dc4311a3c46babf Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 17:01:45 +0530 Subject: [PATCH 14/32] Move Google sign in to NavBar --- src/App.js | 69 --------------------------------- src/components/NavBar.js | 84 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 74 deletions(-) diff --git a/src/App.js b/src/App.js index 6d33ea6..523e8f3 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,5 @@ import React from 'react'; import './App.css'; -import { gapi } from 'gapi-script'; import NavBar from './components/NavBar.js'; import AttendanceCard from './components/AttendanceCard.js'; import { Row, Col } from 'reactstrap'; @@ -10,10 +9,6 @@ class App extends React.Component { constructor(props) { super(props); this.state = { - isSignedIn: false, - } - this.state = { - isSignedIn: false, data: {"data": [{ "courseName": "Loading", "courseCode": "Loading", @@ -35,68 +30,6 @@ class App extends React.Component { }) } - - componentDidMount() { - - const successCallback = this.onSuccess.bind(this); - - window.gapi.load('auth2', () => { - this.auth2 = gapi.auth2.init({ - client_id: '724928841047-2a73bpb9m7hat1v4rhdrkefrtaedmp26.apps.googleusercontent.com', - }) - - // this.auth2.attachClickHandler(document.querySelector('#loginButton'), {}, this.onLoginSuccessful.bind(this)) - - this.auth2.then(() => { - console.log('on init'); - this.setState({ - isSignedIn: this.auth2.isSignedIn.get(), - }); - }); - }); - - window.gapi.load('signin2', function() { - // Method 3: render a sign in button - // using this method will show Signed In if the user is already signed in - var opts = { - width: 200, - height: 50, - client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com', - onsuccess: successCallback - } - gapi.signin2.render('loginButton', opts) - }) - } - - onSuccess() { - console.log('on success') - this.setState({ - isSignedIn: true, - err: null - }) - } - - onLoginFailed(err) { - this.setState({ - isSignedIn: false, - error: err, - }) - } - - getContent() { - if (this.state.isSignedIn) { - return

hello user, you're signed in

- } else { - return ( -
-

You are not signed in. Click here to sign in.

- -
- ) - } - - } - render() { var renderData = this.state.data["data"] @@ -118,8 +51,6 @@ class App extends React.Component { {cards} - {this.getContent()} -

{this.state.data["data"]["courseName"]}

); } diff --git a/src/components/NavBar.js b/src/components/NavBar.js index 441e6c5..7653667 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -1,6 +1,7 @@ -import React, { useState } from 'react'; +import React from 'react'; import 'bootstrap/dist/css/bootstrap.css'; import AddClassForm from './AddClassForm.js' +import { gapi } from 'gapi-script'; import { Navbar, @@ -13,16 +14,85 @@ import { DropdownMenu, } from 'reactstrap'; -const NavBar = (props) => { - const [isOpen, setIsOpen] = useState(false); +class NavBar extends React.Component { + constructor(props) { + super(props); + this.state = { + isOpen: false, + isSignedIn: false, + } + } - const toggle = () => setIsOpen(!isOpen); + componentDidMount() { + const successCallback = this.onSuccess.bind(this); + + window.gapi.load('auth2', () => { + this.auth2 = gapi.auth2.init({ + client_id: '724928841047-2a73bpb9m7hat1v4rhdrkefrtaedmp26.apps.googleusercontent.com', + }) + + // this.auth2.attachClickHandler(document.querySelector('#loginButton'), {}, this.onLoginSuccessful.bind(this)) + + this.auth2.then(() => { + console.log('on init'); + this.setState({ + isSignedIn: this.auth2.isSignedIn.get(), + }); + }); + }); + + window.gapi.load('signin2', function() { + // Method 3: render a sign in button + // using this method will show Signed In if the user is already signed in + var opts = { + width: 200, + height: 50, + client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com', + onsuccess: successCallback + } + gapi.signin2.render('loginButton', opts) + }) + } + + onSuccess() { + console.log('on success') + this.setState({ + isSignedIn: true, + err: null + }) + } + + onLoginFailed(err) { + this.setState({ + isSignedIn: false, + error: err, + }) + } + + getContent() { + if (this.state.isSignedIn) { + return

hello user, you're signed in

+ } else { + return ( +
+

You are not signed in. Click here to sign in.

+ +
+ ) + } + } + + toggle() { + this.setState({isOpen: !this.state.isOpen}); + } + + render() { return (
bunkalog - +
); + } } export default NavBar; From 459fd943ee6003b48daff7457451a423fef4bf8e Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 26 Mar 2021 17:08:18 +0530 Subject: [PATCH 15/32] Add deploy to github-pages --- package-lock.json | 179 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 8 ++- 2 files changed, 186 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index a731773..44d0c86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5295,6 +5295,12 @@ } } }, + "email-addresses": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-3.1.0.tgz", + "integrity": "sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg==", + "dev": true + }, "emittery": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.7.2.tgz", @@ -6490,6 +6496,33 @@ } } }, + "filename-reserved-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz", + "integrity": "sha1-5hz4BfDeHJhFZ9A4bcXfUO5a9+Q=", + "dev": true + }, + "filenamify": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-1.2.1.tgz", + "integrity": "sha1-qfL/0RxQO+0wABUCknI3jx8TZaU=", + "dev": true, + "requires": { + "filename-reserved-regex": "^1.0.0", + "strip-outer": "^1.0.0", + "trim-repeated": "^1.0.0" + } + }, + "filenamify-url": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/filenamify-url/-/filenamify-url-1.0.0.tgz", + "integrity": "sha1-syvYExnvWGO3MHi+1Q9GpPeXX1A=", + "dev": true, + "requires": { + "filenamify": "^1.0.0", + "humanize-url": "^1.0.0" + } + }, "filesize": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz", @@ -6926,6 +6959,118 @@ "assert-plus": "^1.0.0" } }, + "gh-pages": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-3.1.0.tgz", + "integrity": "sha512-3b1rly9kuf3/dXsT8+ZxP0UhNLOo1CItj+3e31yUVcaph/yDsJ9RzD7JOw5o5zpBTJVQLlJAASNkUfepi9fe2w==", + "dev": true, + "requires": { + "async": "^2.6.1", + "commander": "^2.18.0", + "email-addresses": "^3.0.1", + "filenamify-url": "^1.0.0", + "find-cache-dir": "^3.3.1", + "fs-extra": "^8.1.0", + "globby": "^6.1.0" + }, + "dependencies": { + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "^1.0.1" + } + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "find-cache-dir": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", + "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + } + }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, + "requires": { + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + } + } + }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -7472,6 +7617,16 @@ "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==" }, + "humanize-url": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/humanize-url/-/humanize-url-1.0.1.tgz", + "integrity": "sha1-9KuZ4NKIF0yk4eUEB8VfuuRk7/8=", + "dev": true, + "requires": { + "normalize-url": "^1.0.0", + "strip-url-auth": "^1.0.0" + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -14229,6 +14384,21 @@ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" }, + "strip-outer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", + "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, + "strip-url-auth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-url-auth/-/strip-url-auth-1.0.1.tgz", + "integrity": "sha1-IrD6OkE4WzO+PzMVUbu4N/oM164=", + "dev": true + }, "style-loader": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-1.3.0.tgz", @@ -14676,6 +14846,15 @@ "punycode": "^2.1.1" } }, + "trim-repeated": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", + "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, "tryer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", diff --git a/package.json b/package.json index 155edb7..ccf90fd 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "homepage": "https://thebinarybot.github.io/bunkalog/", "name": "bunkalog", "version": "0.1.0", "private": true, @@ -8,8 +9,8 @@ "@testing-library/user-event": "^12.8.3", "axios": "^0.21.1", "bootstrap": "^4.6.0", - "prop-types": "^15.7.2", "gapi-script": "^1.1.0", + "prop-types": "^15.7.2", "react": "^17.0.2", "react-axios": "^2.0.5", "react-dom": "^17.0.2", @@ -18,6 +19,8 @@ "web-vitals": "^1.1.1" }, "scripts": { + "predeploy": "npm run build", + "deploy": "gh-pages -d build", "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", @@ -40,5 +43,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "gh-pages": "^3.1.0" } } From a9d329c912f8a8d4bdf9c4ce28e57c167dc50c07 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Thu, 9 Sep 2021 17:07:55 +0530 Subject: [PATCH 16/32] Exclude vim temporary files from tracking --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 4d29575..f025bfb 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# Temporary files used by vim +*.swp From 5105e2599c824a1d4d0d2dbe8bfae7b19b628e29 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Thu, 9 Sep 2021 23:01:04 +0530 Subject: [PATCH 17/32] Remove hardcoded URLs and use env file instead --- .gitignore | 1 + package.json | 1 + src/App.js | 3 ++- src/components/AddClassForm.js | 4 +++- src/components/AttendanceCard.js | 5 +++-- src/config.js | 5 +++++ 6 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 src/config.js diff --git a/.gitignore b/.gitignore index f025bfb..669beac 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # misc .DS_Store +.env .env.local .env.development.local .env.test.local diff --git a/package.json b/package.json index ccf90fd..0577321 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "@testing-library/user-event": "^12.8.3", "axios": "^0.21.1", "bootstrap": "^4.6.0", + "dotenv": "^10.0.0", "gapi-script": "^1.1.0", "prop-types": "^15.7.2", "react": "^17.0.2", diff --git a/src/App.js b/src/App.js index 523e8f3..0680c4d 100644 --- a/src/App.js +++ b/src/App.js @@ -4,6 +4,7 @@ import NavBar from './components/NavBar.js'; import AttendanceCard from './components/AttendanceCard.js'; import { Row, Col } from 'reactstrap'; import axios from 'axios'; +import config from './config.js'; class App extends React.Component { constructor(props) { @@ -21,7 +22,7 @@ class App extends React.Component { } loadData() { - axios.get("http://192.168.86.129:5000/") + axios.get(config.PROXY_URL + '/') .then( (response) => { this.setState({data: response}); }) diff --git a/src/components/AddClassForm.js b/src/components/AddClassForm.js index eb0f782..f2eadc9 100644 --- a/src/components/AddClassForm.js +++ b/src/components/AddClassForm.js @@ -1,10 +1,12 @@ import React from 'react'; +import config from '../config.js'; import { Button, Form, FormGroup, Label, Input } from 'reactstrap'; class AddClass extends React.Component { render() { + var formUrl = config.PROXY_URL + '/add-class'; return ( -
+ diff --git a/src/components/AttendanceCard.js b/src/components/AttendanceCard.js index 5ba8623..924376d 100644 --- a/src/components/AttendanceCard.js +++ b/src/components/AttendanceCard.js @@ -5,6 +5,7 @@ import { Row, Col } from 'reactstrap'; import axios from 'axios'; +import config from '../config.js'; class AttendanceCard extends React.Component { constructor(props) { @@ -16,7 +17,7 @@ class AttendanceCard extends React.Component { } attendClass() { - var url = "http://192.168.86.129:5000/attend-class?courseCode=" + this.state.name; + var url = config.PROXY_URL + "/attend-class?courseCode=" + this.state.name; axios.get(url) .then( (response) => { this.state.loadData(); @@ -27,7 +28,7 @@ class AttendanceCard extends React.Component { } bunkClass() { - var url = "http://192.168.86.129:5000/bunk-class?courseCode=" + this.state.name; + var url = config.PROXY_URL + "/bunk-class?courseCode=" + this.state.name; axios.get(url) .then( (response) => { this.state.loadData(); diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..e27063a --- /dev/null +++ b/src/config.js @@ -0,0 +1,5 @@ +let config = { + PROXY_URL: process.env.REACT_APP_PROXY_URL, +} + +export default config; From de1321a6bf3f086404f927883ab88324c6672666 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 10 Sep 2021 15:44:49 +0530 Subject: [PATCH 18/32] Move login from navbar to its own page --- package.json | 2 +- src/App.js | 20 +++++++++- src/components/NavBar.js | 73 ------------------------------------- src/components/loginPage.js | 36 ++++++++++++++++++ 4 files changed, 55 insertions(+), 76 deletions(-) diff --git a/package.json b/package.json index 0577321..b92ae2e 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ "axios": "^0.21.1", "bootstrap": "^4.6.0", "dotenv": "^10.0.0", - "gapi-script": "^1.1.0", "prop-types": "^15.7.2", "react": "^17.0.2", "react-axios": "^2.0.5", "react-dom": "^17.0.2", + "react-google-login": "^5.2.2", "react-scripts": "4.0.3", "reactstrap": "^8.9.0", "web-vitals": "^1.1.1" diff --git a/src/App.js b/src/App.js index 0680c4d..f2b992d 100644 --- a/src/App.js +++ b/src/App.js @@ -2,6 +2,7 @@ import React from 'react'; import './App.css'; import NavBar from './components/NavBar.js'; import AttendanceCard from './components/AttendanceCard.js'; +import LoginPage from './components/loginPage.js'; import { Row, Col } from 'reactstrap'; import axios from 'axios'; import config from './config.js'; @@ -17,6 +18,7 @@ class App extends React.Component { "totalClasses": "Loading" }] }, + isUserLoggedIn: false, }; this.loadData(); } @@ -31,6 +33,11 @@ class App extends React.Component { }) } + loginSucceed() + { + this.setState({isUserLoggedIn: true}); + } + render() { var renderData = this.state.data["data"] @@ -46,14 +53,23 @@ class App extends React.Component { ); }); - return ( + if (this.state.isUserLoggedIn) { + return (
{cards}
- ); + ); + } + else { + return ( +
+ this.loginSucceed()} /> +
+ ); + } } } diff --git a/src/components/NavBar.js b/src/components/NavBar.js index 7653667..f477237 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -1,7 +1,6 @@ import React from 'react'; import 'bootstrap/dist/css/bootstrap.css'; import AddClassForm from './AddClassForm.js' -import { gapi } from 'gapi-script'; import { Navbar, @@ -17,74 +16,6 @@ import { class NavBar extends React.Component { constructor(props) { super(props); - this.state = { - isOpen: false, - isSignedIn: false, - } - } - - componentDidMount() { - - const successCallback = this.onSuccess.bind(this); - - window.gapi.load('auth2', () => { - this.auth2 = gapi.auth2.init({ - client_id: '724928841047-2a73bpb9m7hat1v4rhdrkefrtaedmp26.apps.googleusercontent.com', - }) - - // this.auth2.attachClickHandler(document.querySelector('#loginButton'), {}, this.onLoginSuccessful.bind(this)) - - this.auth2.then(() => { - console.log('on init'); - this.setState({ - isSignedIn: this.auth2.isSignedIn.get(), - }); - }); - }); - - window.gapi.load('signin2', function() { - // Method 3: render a sign in button - // using this method will show Signed In if the user is already signed in - var opts = { - width: 200, - height: 50, - client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com', - onsuccess: successCallback - } - gapi.signin2.render('loginButton', opts) - }) - } - - onSuccess() { - console.log('on success') - this.setState({ - isSignedIn: true, - err: null - }) - } - - onLoginFailed(err) { - this.setState({ - isSignedIn: false, - error: err, - }) - } - - getContent() { - if (this.state.isSignedIn) { - return

hello user, you're signed in

- } else { - return ( -
-

You are not signed in. Click here to sign in.

- -
- ) - } - } - - toggle() { - this.setState({isOpen: !this.state.isOpen}); } render() { @@ -92,7 +23,6 @@ class NavBar extends React.Component {
bunkalog -
diff --git a/src/components/loginPage.js b/src/components/loginPage.js index e69de29..4f02693 100644 --- a/src/components/loginPage.js +++ b/src/components/loginPage.js @@ -0,0 +1,36 @@ +import React from 'react'; +import 'bootstrap/dist/css/bootstrap.css'; +import { GoogleLogin } from 'react-google-login'; + +import { + Navbar, + NavbarBrand, +} from 'reactstrap'; + +class LoginPage extends React.Component { + constructor(props) { + super(props); + this.state = { + isSignedIn: false, + onLoginSuccess: props.onLoginSuccess, + } + } + + render() { + return ( +
+ + bunkalog + + + {this.state.onLoginSuccess(response)}} + /> +
+ ); + } +} + +export default LoginPage; From d163755e1e8ebf804701f4004e7c138ad550834f Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 10 Sep 2021 16:00:05 +0530 Subject: [PATCH 19/32] Persist logged in state across refresh --- src/App.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index f2b992d..a473004 100644 --- a/src/App.js +++ b/src/App.js @@ -18,7 +18,7 @@ class App extends React.Component { "totalClasses": "Loading" }] }, - isUserLoggedIn: false, + isUserLoggedIn: localStorage.getItem('isUserLoggedIn') || false, }; this.loadData(); } @@ -36,6 +36,7 @@ class App extends React.Component { loginSucceed() { this.setState({isUserLoggedIn: true}); + localStorage.setItem('isUserLoggedIn', true); } render() From 5500eff6bce3d9569bfde6bf6cc4ed31bf86ed47 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Fri, 10 Sep 2021 23:12:46 +0530 Subject: [PATCH 20/32] Add logout functionality --- src/App.js | 26 +++++++++++++++++++++----- src/components/NavBar.js | 14 ++++++++++++++ src/components/loginPage.js | 1 - 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index a473004..e2dbf17 100644 --- a/src/App.js +++ b/src/App.js @@ -39,8 +39,13 @@ class App extends React.Component { localStorage.setItem('isUserLoggedIn', true); } - render() + logoutSucceed() { + this.setState({isUserLoggedIn: false}); + localStorage.setItem('isUserLoggedIn', false); + } + + onLoggedIn() { var renderData = this.state.data["data"] var cards = renderData.map(function(course, index) { return ( @@ -54,22 +59,33 @@ class App extends React.Component { ); }); - if (this.state.isUserLoggedIn) { return (
- + this.logoutSucceed()} /> {cards}
); - } - else { + } + + onLoggedOut() { return (
this.loginSucceed()} />
); + } + + render() + { + const isUserLoggedIn = this.state.isUserLoggedIn; + console.log(isUserLoggedIn); + if (isUserLoggedIn) { + return this.onLoggedIn(); + } + else { + return this.onLoggedOut(); } } } diff --git a/src/components/NavBar.js b/src/components/NavBar.js index f477237..1082b81 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -1,6 +1,7 @@ import React from 'react'; import 'bootstrap/dist/css/bootstrap.css'; import AddClassForm from './AddClassForm.js' +import { GoogleLogout } from 'react-google-login'; import { Navbar, @@ -16,6 +17,12 @@ import { class NavBar extends React.Component { constructor(props) { super(props); + this.state = { + onLogout: false, + } + if (props.onLogout) { + this.state.onLogout = props.onLogout; + } } render() { @@ -34,6 +41,13 @@ class NavBar extends React.Component { + + this.state.onLogout()} + /> + diff --git a/src/components/loginPage.js b/src/components/loginPage.js index 4f02693..40f57e5 100644 --- a/src/components/loginPage.js +++ b/src/components/loginPage.js @@ -11,7 +11,6 @@ class LoginPage extends React.Component { constructor(props) { super(props); this.state = { - isSignedIn: false, onLoginSuccess: props.onLoginSuccess, } } From 37e1117cae739f74c8afa8868120d3cb58da2f54 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Sun, 12 Sep 2021 22:00:51 +0530 Subject: [PATCH 21/32] Fix isUserLoggedIn bug and refactor code * Fix app always loading post-login page (parse isUserLoggedIn to boolean) * Change homepage in package.json * Remove unused NavBarToggler import in NavBar.js * Replace data loading code in App.js with componentDidMount --- package.json | 2 +- src/App.js | 5 ++--- src/components/NavBar.js | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b92ae2e..aeab1b4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "homepage": "https://thebinarybot.github.io/bunkalog/", + "homepage": "https://sujairamprasathc.github.io/bunkalog/", "name": "bunkalog", "version": "0.1.0", "private": true, diff --git a/src/App.js b/src/App.js index e2dbf17..3dbbb8d 100644 --- a/src/App.js +++ b/src/App.js @@ -18,12 +18,11 @@ class App extends React.Component { "totalClasses": "Loading" }] }, - isUserLoggedIn: localStorage.getItem('isUserLoggedIn') || false, + isUserLoggedIn: JSON.parse(localStorage.getItem('isUserLoggedIn')) || false, }; - this.loadData(); } - loadData() { + componentDidMount() { axios.get(config.PROXY_URL + '/') .then( (response) => { this.setState({data: response}); diff --git a/src/components/NavBar.js b/src/components/NavBar.js index 1082b81..cf97d96 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -5,7 +5,6 @@ import { GoogleLogout } from 'react-google-login'; import { Navbar, - NavbarToggler, NavbarBrand, Nav, NavItem, From a136ec5fbec519f333d516e23f9abb0607d6686f Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Tue, 14 Sep 2021 20:02:23 +0530 Subject: [PATCH 22/32] Add session tracking to front-end --- package.json | 1 + src/App.js | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index aeab1b4..956a0c6 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "axios": "^0.21.1", "bootstrap": "^4.6.0", "dotenv": "^10.0.0", + "js-cookie": "^3.0.1", "prop-types": "^15.7.2", "react": "^17.0.2", "react-axios": "^2.0.5", diff --git a/src/App.js b/src/App.js index 3dbbb8d..4fd43f3 100644 --- a/src/App.js +++ b/src/App.js @@ -6,6 +6,7 @@ import LoginPage from './components/loginPage.js'; import { Row, Col } from 'reactstrap'; import axios from 'axios'; import config from './config.js'; +import Cookies from 'js-cookie'; class App extends React.Component { constructor(props) { @@ -23,7 +24,8 @@ class App extends React.Component { } componentDidMount() { - axios.get(config.PROXY_URL + '/') + //console.log(Cookies.get('bunkalog_session_id')); + axios.get(config.PROXY_URL + '/user', {params: {'session_id': Cookies.get('bunkalog_session_id')}}) .then( (response) => { this.setState({data: response}); }) @@ -32,8 +34,32 @@ class App extends React.Component { }) } - loginSucceed() + loginSucceed(response) { + console.log(response); + + const requestOption = { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + url: config.PROXY_URL + '/login', + data: {response} + } + + axios(requestOption) + .then(function (response) { + //console.log(response.data); + const session_id = response.data; + console.log(session_id); + //console.log('response' + response); + Cookies.set('bunkalog_session_id', session_id); + }) +/* .then(data => { + console.log('data ' + data); + })*/ + .catch(function (error) { + console.log(error); + }); + this.setState({isUserLoggedIn: true}); localStorage.setItem('isUserLoggedIn', true); } @@ -71,7 +97,7 @@ class App extends React.Component { onLoggedOut() { return (
- this.loginSucceed()} /> + this.loginSucceed(response)} />
); } @@ -79,7 +105,6 @@ class App extends React.Component { render() { const isUserLoggedIn = this.state.isUserLoggedIn; - console.log(isUserLoggedIn); if (isUserLoggedIn) { return this.onLoggedIn(); } From e3ec415d6b6a223f36d2a0b01cb459d1462ec630 Mon Sep 17 00:00:00 2001 From: Sujai Ram Prasath C <20027296+sujairamprasathc@users.noreply.github.com> Date: Tue, 14 Sep 2021 20:03:03 +0530 Subject: [PATCH 23/32] Refactor AddClassForm to prevent redirect on submit --- src/components/AddClassForm.js | 63 ++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/src/components/AddClassForm.js b/src/components/AddClassForm.js index f2eadc9..652e86e 100644 --- a/src/components/AddClassForm.js +++ b/src/components/AddClassForm.js @@ -1,31 +1,82 @@ import React from 'react'; import config from '../config.js'; +import axios from 'axios'; +import Cookies from 'js-cookie'; import { Button, Form, FormGroup, Label, Input } from 'reactstrap'; -class AddClass extends React.Component { +class AddClass extends React.Component +{ + constructor(props) + { + super(props); + this.state = { + courseName: '', + courseCode: '', + classesAttended: 0, + totalClasses: 0, + } + + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } + + handleChange(event) + { + const name = event.target.name; + const value = event.target.value; + + this.setState({ + [name]: value + }); + } + + handleSubmit(event) + { + const requestOptions = { + method: 'POST', + headers: {'bunkalog_session_id': Cookies.get('bunkalog_session_id')}, + url: config.PROXY_URL + '/add-class', + data: this.state, + } + + axios(requestOptions) + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }); + + event.preventDefault(); + } + render() { var formUrl = config.PROXY_URL + '/add-class'; return ( - + - + - + - + - + - - - + + + - - - - - - - ); + + + + + + + + ); } }; +AttendanceCard.propTypes = { + courseName: PropTypes.string, + courseCode: PropTypes.string.isRequired, + classesAttended: PropTypes.any, + totalClasses: PropTypes.any, +}; + export default AttendanceCard; diff --git a/src/components/NavBar.js b/src/components/NavBar.js index 6a6d7cb..cb21b92 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -1,6 +1,7 @@ import React from 'react'; +import PropTypes from 'prop-types'; import 'bootstrap/dist/css/bootstrap.css'; -import { GoogleLogout } from 'react-google-login'; +import {GoogleLogout} from 'react-google-login'; import config from '../config.js'; import { @@ -8,13 +9,20 @@ import { NavbarBrand, Nav, NavItem, - NavLink + NavLink, } from 'reactstrap'; -function NavBar(props) -{ + +/** + * Defines the navbar component used in the app + * @param {Props} props Used to know if user is logged in or not. Info is used + * to render a logout button when logged in + * @return {string} NavBar's HTML + */ +function NavBar(props) { console.log('Function Call: NavBar.js: render()'); - console.log('Variable Value Check: NavBar.js: props.isUserLoggedIn ' + props.isUserLoggedIn); + console.log('Variable Value Check: NavBar.js: props.isUserLoggedIn ' + + props.isUserLoggedIn); return (
@@ -23,10 +31,13 @@ function NavBar(props) { (props.isUserLoggedIn) &&