Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(book detail): reimplement book detail logic #36

Merged
merged 1 commit into from
Oct 1, 2017

Conversation

segunolalive
Copy link
Owner

@segunolalive segunolalive commented Oct 1, 2017

####What does this PR do?
Changes the implementation of login for viewing book details on the client-side

Any background context you want to provide?

The previous implementation relied on setting the book id in the redux store, then reading it that value before sending the required api. The new implementation takes advantage of react-router's match prop and so fetches the book information based on the url parameter, making it more expressive.

@@ -6,6 +6,7 @@ import { Redirect } from 'react-router-dom';

import Header from '../header/Header';
import { borrowBook, deleteBook } from '../../actions/library';
import { viewBookDetails } from '../../actions/viewBook';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module '../../actions/viewBook' import/no-unresolved

@@ -11,6 +12,9 @@ import Library from './library/Library';
import BookDetail from './library/BookDetail';
import Dashboard from './dashboard/Dashboard';
import Logout from './auth/Logout';
import ForgotPassword from './forgotPassword';

import UpdateProfile from './dashboard/UpdateProfile';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './dashboard/UpdateProfile' import/no-unresolved

@@ -11,6 +12,9 @@ import Library from './library/Library';
import BookDetail from './library/BookDetail';
import Dashboard from './dashboard/Dashboard';
import Logout from './auth/Logout';
import ForgotPassword from './forgotPassword';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './forgotPassword' import/no-unresolved

@@ -3,6 +3,7 @@ import { BrowserRouter, Route, Switch } from 'react-router-dom';


import Home from './Home';
import History from './history/History';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module './history/History' import/no-unresolved

* @param {Integer} id book Id
* @return {any} dispatches an action to the redux store
*/
export const viewBookDetails = id => dispatch => (
axios.get(`${API}/books/${id}`)
.then((response) => {
dispatch(getBook(response.data.data));
}, (error) => {
Materialize.toast(error.response.data.message, 2500, 'red darken-4');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Materialize' is not defined no-undef

@coveralls
Copy link

Coverage Status

Coverage remained the same at 76.19% when pulling 491a255 on feature/view-book into 5098dd2 on development.

@segunolalive segunolalive merged commit b5817c4 into development Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants