Skip to content

Commit

Permalink
chore(materialize): clean up materialize references
Browse files Browse the repository at this point in the history
  • Loading branch information
segunolalive committed Oct 1, 2017
1 parent b5817c4 commit cb54ac9
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 18 deletions.
4 changes: 3 additions & 1 deletion client/actions/adminActions.js
Expand Up @@ -2,6 +2,8 @@ import axios from 'axios';
import actionTypes from '../actions/actionTypes';
import API from './api';

const Materialize = window.Materialize;


/**
* @param {Object} book - book
Expand Down Expand Up @@ -71,7 +73,7 @@ export const addBookCategory = category => dispatch => (
Materialize.toast(response.data.message, 2500, 'teal darken-4');
})
.catch(() => {
Materialize.toast(`Something went wrong. Ensure you\'re not adding
Materialize.toast(`Something went wrong. Ensure you're not adding
an existing category`, 2500, 'red darken-4'
);
})
Expand Down
2 changes: 2 additions & 0 deletions client/actions/borrowedBooks.js
Expand Up @@ -2,6 +2,8 @@ import axios from 'axios';
import actionTypes from '../actions/actionTypes';
import API from './api';

const Materialize = window.Materialize;


/**
* @param {Array} borrowedBooks - array of books borrowed by user
Expand Down
2 changes: 2 additions & 0 deletions client/actions/library.js
Expand Up @@ -3,6 +3,8 @@ import axios from 'axios';
import actionTypes from '../actions/actionTypes';
import API from './api';

const Materialize = window.Materialize;


/**
* action creator for getting books
Expand Down
1 change: 1 addition & 0 deletions client/actions/viewBook.js
Expand Up @@ -2,6 +2,7 @@ import axios from 'axios';
import actionTypes from '../actions/actionTypes';
import API from './api';

const Materialize = window.Materialize;

/**
* @param {Object} book - book
Expand Down
37 changes: 35 additions & 2 deletions client/components/auth/Login.js
Expand Up @@ -3,11 +3,16 @@ import PropTypes from 'prop-types';
import { Link, Redirect } from 'react-router-dom';
import { connect } from 'react-redux';
import { Row } from 'react-materialize';
import GoogleLogin from 'react-google-login';
import FaGoogle from 'react-icons/lib/fa/google';

import Header from '../header/Header';
import { login } from '../../actions/login';
import Loading from '../Loading';


const Materialize = window.Materialize;

/*
eslint-disable
*/
Expand All @@ -20,6 +25,12 @@ class Login extends Component {
};
this.handleLogin = this.handleLogin.bind(this);
this.handleChange = this.handleChange.bind(this);
this.responseGoogle = this.responseGoogle.bind(this);
}

responseGoogle(response) {
// const loginProfile = response.getBasicProfile();
console.log(response);
}

handleLogin(event) {
Expand All @@ -40,9 +51,8 @@ class Login extends Component {
}
)
.catch((err) => {
console.log(err);
Materialize.toast(
'Ouch! Something went awry. It\'s probably our fault',
`Ouch! Something went awry. It's probably our fault`,
2500,
'red darken-4'
);
Expand Down Expand Up @@ -113,13 +123,36 @@ class Login extends Component {
name="submit"
value="LOGIN"
className="btn waves-effect waves-light"
style={{ width: '100%' }}
/>
</div>
<div className="input-field">
<GoogleLogin
clientId={GOOGLE_CLIENT_ID}
onSuccess={this.responseGoogle}
onFailure={this.responseGoogle}
className="btn red darken-4"
style={{ width: '100%' }}
>
<FaGoogle
style={{
color: '#032442',
fontSize: '2rem',
}}
/>
<span> Login with Google</span>
</GoogleLogin>
</div>
<div>
<p className="center">Don&apos;t have an account?
<Link to="/signup"> Sign up</Link>
</p>
</div>
<div>
<p className="center">Forgot password? &nbsp; &nbsp;
<Link to="/forgot-password"> Click here</Link>
</p>
</div>
</div>
</div>
</form>
Expand Down
4 changes: 4 additions & 0 deletions client/components/auth/SignUp.js
Expand Up @@ -7,6 +7,9 @@ import Header from '../header/Header';
import { signUp } from '../../actions/signup';
import Loading from '../Loading';

const Materialize = window.Materialize;


/*
eslint-disable
*/
Expand Down Expand Up @@ -162,6 +165,7 @@ class SignUp extends Component {
name="submit"
value="Sign Up"
className="btn waves-effect waves-light"
style={{ width: '100%' }}
/>
</div>
<div className="">
Expand Down
10 changes: 7 additions & 3 deletions client/components/dashboard/Dashboard.js
Expand Up @@ -10,6 +10,8 @@ import SuggestedBooks from './SuggestedBooks';

import { fetchBorrowedBooks, returnBook } from '../../actions/borrowedBooks';

const Materialize = window.Materialize;

/*
eslint-disable
*/
Expand All @@ -23,7 +25,7 @@ class Dashboard extends Component {

componentDidMount () {
if (this.props.user) {
this.handleFetchBorrowedBooks();
this.handleFetchBorrowedBooks();
}
}

Expand All @@ -41,7 +43,7 @@ class Dashboard extends Component {
}

readBook (id) {

// TODO: implement readBook
}

render() {
Expand All @@ -59,7 +61,9 @@ class Dashboard extends Component {
<main>
<Row>
<Col s={12}>
<ProfileInfo name={fullname}/>
<ProfileInfo
name={fullname}
/>
<Borrowed
borrowedBooks={this.props.borrowedBooks}
readBook={this.readBook}
Expand Down
6 changes: 4 additions & 2 deletions client/components/library/BookDetail.js
Expand Up @@ -8,6 +8,8 @@ import Header from '../header/Header';
import { borrowBook, deleteBook } from '../../actions/library';
import { viewBookDetails } from '../../actions/viewBook';

const Materialize = window.Materialize;


/*
eslint-disable
Expand All @@ -20,9 +22,9 @@ class BookDetail extends React.Component {
this.handleEditClick = this.handleEditClick.bind(this);
this.handleDelete = this.handleDelete.bind(this);
}

componentDidMount() {
this.props.viewBookDetails(this.props.match.params.id)
.catch(err => Materialize.toast())
this.props.viewBookDetails(this.props.match.params.id);
}

handleBorrow() {
Expand Down
6 changes: 5 additions & 1 deletion client/static/index.scss
Expand Up @@ -16,7 +16,7 @@ html, body {
body {
background-color: $theme-blue;
color: $white;
font: sans-serif;
font: 1rem sans-serif;
}

#sidenav-overlay {
Expand Down Expand Up @@ -174,3 +174,7 @@ main {
.action-btn {
margin: 5px;
}

.borrowed-list {
font: small-caps 1.3rem sans-serif;
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -15,7 +15,7 @@
"coverage": "NODE_ENV=test nyc report --reporter=text-lcov | coveralls",
"seed:tables": "cross-env NODE_ENV=test babel-node server/seeders/user.js && babel-node server/seeders/bookCategory.js && babel-node server/seeders/book.js",
"seed:join": "cross-env NODE_ENV=test babel-node server/seeders/borrowedBook.js",
"build": "rm -rf dist && babel server -d dist/server && webpack --config ./webpack.prod.config.js --progress --colors",
"build": "rm -rf dist && babel server -d dist/server && webpack --config ./webpack.prod.config.js --progress --colors && cp client/sw.js dist/client",
"heroku-postbuild": "npm run build"
},
"nyc": {
Expand Down
2 changes: 1 addition & 1 deletion server/bin/www.js
Expand Up @@ -2,7 +2,7 @@ import http from 'http';

import app from '../app';

const port = parseInt(process.env.PORT, 10) || 3000;
const port = parseInt(process.env.PORT, 10) || 5000;

const server = http.createServer(app);

Expand Down
8 changes: 4 additions & 4 deletions server/controllers/users.js
Expand Up @@ -16,7 +16,7 @@ export default {
* @method
* @param {object} req - express http request object
* @param {object} res - express http response object
* @return {Undefined}
* @return {mixed} - sends an http response
*/

createUser(req, res) {
Expand Down Expand Up @@ -69,7 +69,7 @@ export default {
* @method
* @param {object} req - express http request object
* @param {object} res - express http response object
* @return {undefined}
* @return {mixed} - sends an http response
*/
updateUserInfo(req, res) {
User.findById(req.user.id)
Expand Down Expand Up @@ -100,7 +100,7 @@ export default {
* @method
* @param {object} req - express http request object
* @param {object} res - express http response object
* @return {undefined}
* @return {mixed} - sends an http response
*/

getUser(req, res) {
Expand Down Expand Up @@ -151,7 +151,7 @@ export default {
* @method
* @param {object} req - express http request object
* @param {object} res - express http response object
* @return {undefined}
* @return {mixed} - sends an http rresponse
*/
getBorrowedBooks(req, res) {
const id = req.params.id;
Expand Down
10 changes: 8 additions & 2 deletions webpack.dev.config.js
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');


const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: './client/index.html',
filename: 'index.html',
Expand All @@ -12,8 +13,6 @@ const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
module.exports = {
devtool: 'inline-source-map',
entry: [
// reload the page if hot module reloading fails.
// 'webpack-hot-middleware/client?reload=true',
path.resolve(__dirname, 'client/index.js')
],
output: {
Expand Down Expand Up @@ -65,5 +64,12 @@ module.exports = {
plugins: [
HtmlWebpackPluginConfig,
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development')
},
GOOGLE_CLIENT_SECRET: JSON.stringify('VenazYqo1V-41a8pAocf7a9H'),
GOOGLE_CLIENT_ID: JSON.stringify('701806023399-vgqondt26qh10vcuei77r7nsbcd8oa8k.apps.googleusercontent.com')
})
],
};
4 changes: 3 additions & 1 deletion webpack.prod.config.js
Expand Up @@ -66,7 +66,9 @@ module.exports = {
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
},
GOOGLE_CLIENT_SECRET: JSON.stringify('VenazYqo1V-41a8pAocf7a9H'),
GOOGLE_CLIENT_ID: JSON.stringify('701806023399-vgqondt26qh10vcuei77r7nsbcd8oa8k.apps.googleusercontent.com')
})
],
};

0 comments on commit cb54ac9

Please sign in to comment.