Skip to content

Commit

Permalink
bug-fix (materialize modal bug): Installed react 16 to eliminate reac…
Browse files Browse the repository at this point in the history
…t materialize modal bug

- Refactored code by implementingmore Jsdocs
  • Loading branch information
Benny Ogidan authored and Benny Ogidan committed Dec 18, 2017
1 parent 9689cf9 commit 9d79b93
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 50 deletions.
5 changes: 1 addition & 4 deletions client/src/app/actions/admin/getAdminNotifications.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
showErrorNotification,
showSuccessNotification
} from '../notifications';

import {
GET_NOTIFICATIONS_SUCCESS,
GET_NOTIFICATIONS_FAILURE
Expand Down
18 changes: 15 additions & 3 deletions client/src/app/components/container/booklist/DisplayAllBooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ import AddBookModal from '../../presentation/common/modal/AddBookModal.jsx';

/**
* @description Component for Display Books on the Landing page for all users
*
* @class DisplayLandingBooks
*
* @extends {Component}
*/
class DisplayAllBooks extends React.Component {
/**
* @description dispatch actions that help
*
* populate the dashboard with all the books
*
* @method componentDidMount
*
* @memberof DisplayAllBooks
*
* @returns {component} Loader
*/
componentWillMount() {
Expand All @@ -39,6 +45,7 @@ class DisplayAllBooks extends React.Component {
/**
*
* @returns {function} openModal
*
* @memberof DisplayAllBooks
*
*/
Expand All @@ -48,8 +55,11 @@ class DisplayAllBooks extends React.Component {

/**
* render Display All Books page component
*
* @method render
*
* @member DisplayAllBooks
*
* @returns {component} component
*/
render() {
Expand Down Expand Up @@ -108,7 +118,10 @@ class DisplayAllBooks extends React.Component {
numberOfRecords={this.props.limit}
/>
{this.props.isAdmin && this.props.allBooksList ?
<div><EditBookModal /> <AddBookModal /> </div> : null
<div>
<EditBookModal />
<AddBookModal />
</div> : null
}
</div>
);
Expand Down Expand Up @@ -142,8 +155,7 @@ DisplayAllBooks.defaultProps = {
};

const mapStateToProps = state => ({
allBooksList: (state.bookReducer.allBooksList)
? state.bookReducer.allBooksList : {},
allBooksList: state.bookReducer.allBooksList,
isAdmin: (state.userReducer.user) ? state.userReducer.user.isAdmin : false,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,35 @@ import MessageforNoBooks from

/**
* @description Component for Display Books on the Landing page for all users
*
* @class DisplayLandingBooks
*
* @extends {Component}
*/
class DisplayAllBorrowedBooks extends React.Component {
/**
* @description dispatch actions that help populate the dashboard with books
* fetch books for the current user
*
* @method componentDidMount
*
* @memberof LandingPage
*
* @returns {void}
*/
componentDidMount() {
return (<Loader
records={this.props.borrowedBooks}
callback=
{this.props.fetchAllBorrowedBooks(this.props.offset, this.props.limit)}
callback={this.props.fetchAllBorrowedBooks(this.props.offset, this.props.limit)}
/>);
}
/**
* render Landing page component
*
* @method render
*
* @member LandingPage
*
* @returns {object} component
*/
render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DisplayRecentBooks extends React.Component {
}

/**
*
* @method componentDidMount
*
* @memberof DisplayRecentBooks
*
Expand All @@ -49,8 +49,11 @@ class DisplayRecentBooks extends React.Component {
}
/**
* render Display Recent component
*
* @method render
*
* @member DisplayRecentBooks
*
* @returns {object} component
*/
render() {
Expand Down
4 changes: 3 additions & 1 deletion client/src/app/components/container/booklist/Loader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import PropTypes from 'prop-types';
import { Preloader } from 'react-materialize';

const Loader = ({ records, callback }) => {
if (!records) { return <Preloader size="big" />; }
if (!records) {
return (<Preloader size="big" />);
}
callback();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ const getCategoriesWrapper = (WrappedComponent) => {
GetCategories.propTypes = {
categoryList: PropTypes
.arrayOf(PropTypes.shape({ key: PropTypes.number }))
.isRequired,
,
fetchBooksForCategories: PropTypes.func,
onChange: PropTypes.func
};

GetCategories.defaultProps = {
fetchBooksForCategories: null,
onChange: null
onChange: null,
categoryList: []
};

const mapStateToProps = ({
categoryReducer
}) => ({
categoryList: (categoryReducer.categoryList)
? categoryReducer.categoryList : {}
categoryList: categoryReducer.categoryList
});

return connect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { Preloader } from 'react-materialize';
import PropTypes from 'prop-types';
import { getAdminNotificationAction }
from '../../../actions/admin/getAdminNotifications';
import { getAdminNotificationAction } from '../../../actions/admin/getAdminNotifications';
import PaginationWrapper from '../common/Pagination.jsx';
import NotificationTable from './NotificationTable.jsx';

Expand Down Expand Up @@ -81,8 +80,7 @@ NotificationTab.defaultProps = {
};

const mapStateToProps = state => ({
notifications: (state.notifierReducer.notifications) ?
state.notifierReducer.notifications : {}
notifications: state.notifierReducer.notifications
});

export default
Expand Down
15 changes: 14 additions & 1 deletion client/src/app/components/container/password/ChangePassword.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ class ChangePassword extends Component {
this.onClick = this.onClick.bind(this);
}

/**
* @method componentDidMount
*
* @memberof DisplayRecentBooks
*
* @returns {object} void
*
* @memberOf DisplayRecentBooks
* */
componentWillMount() {
$('body').css('background-color', 'rgb(204, 204, 204)');
}
/**
* Handle onChange events for Change Password
*
Expand Down Expand Up @@ -89,6 +101,7 @@ class ChangePassword extends Component {
return isValid;
}
}

/**
*
*
Expand All @@ -104,7 +117,7 @@ class ChangePassword extends Component {
<div className="signup center-align">
<div className="signup-wrapper" id="change-password">
<Row>

<div className="signup-header">
Change Password
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getUserListAction } from '../../../../actions/admin/getUserList';
import PaginationWrapper from '../../common/Pagination.jsx';
import UserListTable from '../UserListTable.jsx';


/**
* handles the state of the User List table
*
Expand Down Expand Up @@ -86,7 +85,7 @@ UserListTab.propTypes = {
};

const mapStateToProps = state => ({
userList: (state.userReducer.userList) ? state.userReducer.userList : {}
userList: state.userReducer.userList
});

export default connect(mapStateToProps, { getUserListAction })(UserListTab);
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/components/presentation/LandingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Row } from 'react-materialize';
import PropTypes from 'prop-types';
import WelcomeMessage from './messages/WelcomeMessage.jsx';
import Bottom from '../presentation/common/Footer.jsx';
import DisplayBookModal from '../presentation/common/book/DisplayBookModal.jsx';
import DisplayRecentBooks from '../container/booklist/DisplayRecentBooks.jsx';

/**
Expand Down Expand Up @@ -33,6 +34,7 @@ const LandingPage = ({ isAuthenticated }) => (
</div>
</div>
</Row>
{/* <DisplayBookModal /> */}
<Bottom />
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/components/presentation/UserDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DisplayAllBooks from '../container/booklist/DisplayAllBooks.jsx';
import LoanHistoryTable from '../container/loanhistory/LoanHistory.jsx';
import DisplayOverdueBooks from '../container/booklist/DisplayOverdueBooks.jsx';
import getDashboardWrapper from '../container/Dashboard.jsx';
import DisplayBookModal from '../../components/presentation/common/book/DisplayBookModal.jsx';


/**
Expand Down Expand Up @@ -60,6 +61,7 @@ class UserDashboard extends React.PureComponent {
<hr />
</div>
</div>
{/* <DisplayBookModal /> */}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ class SignInPage extends Component {

/**
* Handle onChange events on form inputs
*
* @method onChange
*
* @memberof SignIn
*
* @param {object} e
*
* @returns {function} a function that handles change event on inputs
*/
onChange = (e) => {
Expand Down Expand Up @@ -72,13 +76,12 @@ class SignInPage extends Component {
this
.props
.login(this.state)
.then((response) => {
if (response.success && response.isAdmin) {
return this.props.history.push('/admin');
.then((response) => {
if (response.success && response.isAdmin) {
return (this.props.history.push('/admin'));
}

this
.props
this.props
.history
.push('/dashboard');
})
Expand All @@ -89,7 +92,9 @@ class SignInPage extends Component {

/**
* @returns {*} void
*
* @param {any} response
*
* @memberof Login
*/
handleGoogleLogin(response) {
Expand All @@ -98,17 +103,19 @@ class SignInPage extends Component {
.login(response.profileObj)
.then((res) => {
if (res) {
this
.props
this.props
.history
.push('/dashboard');
}
});
}
/**
* render login component
*
* @method render
*
* @member SignIn
*
* @returns {object} component
*/
render() {
Expand Down Expand Up @@ -162,19 +169,18 @@ class SignInPage extends Component {
<a className="btn btn-social btn-google">
<span className="fa fa-google" />
<GoogleLogin
className="google-btn"
clientId={GOOGLE_CLIENT_ID}
onSuccess={this.handleGoogleLogin}
onFailure={this.handleGoogleLogin}
>

Sign in with Google
</GoogleLogin>
</a>
</Col>
</div>
</form>
</Row>

</div>
</div>
<Bottom />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class SignUpPage extends Component {
e.preventDefault();
if (this.isValid()) {
this.setState({ errors: {} });
this
.props
this.props
.submit(this.state);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { Modal, Row, Col } from 'react-materialize';
import PropTypes from 'prop-types';

/**
*
*
* @class BookModal
*
* @extends {React.Component}
*/
class BookModal extends React.PureComponent {
/**
*
*
* @returns {Component} Component
*
Expand Down
Loading

0 comments on commit 9d79b93

Please sign in to comment.