Skip to content

Commit

Permalink
Merge pull request #51 from acmutd/dev
Browse files Browse the repository at this point in the history
Refined release
  • Loading branch information
sivampatel authored May 21, 2020
2 parents bf98f53 + f6e820f commit d02d849
Show file tree
Hide file tree
Showing 21 changed files with 1,056 additions and 581 deletions.
659 changes: 367 additions & 292 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"bootstrap": "^4.4.1",
"draft-js": "^0.11.5",
"draftjs-to-html": "^0.9.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"file-saver": "^2.0.2",
"firebase": "^7.13.2",
"react": "^16.13.0",
"react-bootstrap": "^1.0.0-beta.17",
"react-datepicker": "^2.14.1",
"react-dom": "^16.13.0",
"react-draft-wysiwyg": "^1.14.5",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0",
"serve": "^11.3.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"react-test-renderer": "^16.13.1"
"react-test-renderer": "^16.13.1",
"serve": "^11.3.0"
},
"scripts": {
"start": "serve -s build",
Expand Down
20 changes: 4 additions & 16 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,15 @@ import User from "./Components/User/User";
import Pricing from "./Components/Pages/Pricing";
import Error404 from "./Components/Pages/Error404";
import { Route, Switch } from "react-router-dom";
import firebase from "firebase";

const firebaseConfig = {
apiKey: "AIzaSyC10N5kRDieKncmUESxswqkYQ_359f9Qes",
authDomain: "trackit-271619.firebaseapp.com",
databaseURL: "https://trackit-271619.firebaseio.com",
projectId: "trackit-271619",
storageBucket: "trackit-271619.appspot.com",
messagingSenderId: "972365141905",
appId: "1:972365141905:web:fbda064275f635298cec30",
measurementId: "G-HRLPFBGB1E",
};

let app = firebase.initializeApp(firebaseConfig);
import app from "./Components/Firebase/firebase";
import LandingPage from "./Components/Pages/LandingPage";

function App() {
return (
<div>
{/* replace this with <User /> when wanting to test out the user side, we can decide at a later point when the admin side should appear and when the user side should apper */}
<Switch>
<Route path="/" render = {(props) => <User database = {app} />} exact />
<Route path="/" component={LandingPage} exact/>
<Route path="/user" render = {(props) => <User database = {app} />} exact />
<Route path="/admin" render = {(props) => <Admin database = {app} />} exact />
<Route path="/pricing" component={Pricing} exact />
<Route path="*" component={Error404} exact />
Expand Down
62 changes: 59 additions & 3 deletions src/Components/Admin/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class Admin extends React.Component {
workshop_data: null,
student_data: null,
dataLoaded: false,

alert: false,
alertText: "Unknown error occured",
};

/**
Expand All @@ -41,7 +44,6 @@ class Admin extends React.Component {
.then((doc) => {
// if the user has admin acess then set loggedIn to true
if (doc.data().isAdmin === true) {
console.log("logging user in");
this.setState({
loggedIn: true,
});
Expand All @@ -62,6 +64,10 @@ class Admin extends React.Component {
}
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in login process",
});
console.log(error + " error occurred in login process");
});
}
Expand Down Expand Up @@ -168,6 +174,10 @@ class Admin extends React.Component {
console.log("workshop level successfully updated");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in updating workshop level",
});
console.log(error + " error occurred in updating workshop level");
});
};
Expand All @@ -190,6 +200,10 @@ class Admin extends React.Component {
console.log("workshop status successfully updated");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in updating workshop status",
});
console.log(error + " error occurred in updating workshop status");
});
};
Expand All @@ -211,6 +225,10 @@ class Admin extends React.Component {
console.log("All student progress successfully cleared");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in erasing student progress",
});
console.log(error + " error occured in erasing student progress");
});
};
Expand All @@ -237,6 +255,10 @@ class Admin extends React.Component {
console.log("updating workshop successful");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in updating workshop",
});
console.log(error + " error occurred in updating workshop");
});

Expand All @@ -252,6 +274,10 @@ class Admin extends React.Component {
console.log("workshop level successfully reset to 1");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in reseting workshop level to 1",
});
console.log(error + " error occurred in reseting workshop level to 1");
});
};
Expand Down Expand Up @@ -279,6 +305,10 @@ class Admin extends React.Component {
console.log("empty students at workshop entry created");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in adding empty students at workshop object",
});
console.log(
error + " error occured in adding empty sudents at workshop object"
);
Expand All @@ -294,6 +324,10 @@ class Admin extends React.Component {
console.log("new workshop created");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in creating new workshop",
});
console.log(error + " error occurred in creating new workshop");
});
};
Expand All @@ -312,6 +346,10 @@ class Admin extends React.Component {
console.log("successfully deleted students at workshop");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in deleting students at workshop",
});
console.log(error + " error occurred in deleting students at workshop");
});

Expand All @@ -324,6 +362,10 @@ class Admin extends React.Component {
console.log("successfully deleted workshop");
})
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in deleting workshop",
});
console.log(error + " error occurred in deleting workshop");
});
};
Expand All @@ -345,11 +387,22 @@ class Admin extends React.Component {
dataLoaded: false,
});
})
.catch((err) => {
console.log("error signing user out");
.catch((error) => {
this.setState({
alert: true,
alertText: error + " Error occurred in signing out the user",
});
console.log(error + " error signing user out");
});
};

resetAlertStatus = () => {
this.setState({
alert: false,
alertText: "Unknown error occurred",
})
}

/**
* renders the page
*/
Expand All @@ -374,6 +427,9 @@ class Admin extends React.Component {
workshopListener={this.workshopListener}
signOut={this.signOutUser}
dataLoaded={this.state.workshop_data && this.state.student_data}
alert={this.state.alert}
alertText={this.state.alertText}
resetAlertStatus={this.resetAlertStatus}
/>
) : (
<AdminAuth
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Admin/AdminAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AdminAuth extends React.Component {
<div>
<NavBar />
<Container fluid>
<div className="m-5 p-5 floating-icon">
<div className="m-1 mt-3 m-lg-5 mt-lg-5 p-5 floating-icon">
{this.state.loginError ? (
<Alert
variant="danger"
Expand Down
Loading

0 comments on commit d02d849

Please sign in to comment.