-
Notifications
You must be signed in to change notification settings - Fork 5
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
Implementation of return book functionality #30
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { showErrorNotification, showSuccessNotification } from './notifications'; | ||
import { | ||
RETURN_BOOKS_FAIL, | ||
RETURN_BOOKS_SUCCESS | ||
} from './actiontype'; | ||
import api from './api'; | ||
|
||
export const ReturnBookSuccess = returnedbooks => ({ type: RETURN_BOOKS_SUCCESS, returnedbooks }); | ||
export const ReturnBookRejected = error => ({ type: RETURN_BOOKS_FAIL, error }); | ||
|
||
/** | ||
* async helper function: Return book | ||
* @function ReturnBooks | ||
* @returns {function} asynchronous action | ||
*/ | ||
export const returnbook = data => dispatch => api | ||
.book | ||
.returnbook(data) | ||
.then((response)=>{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 2 spaces but found 0 indent |
||
const message = response.message; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 4 spaces but found 2 indent |
||
dispatch(showSuccessNotification({message})) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 4 spaces but found 2 indent |
||
dispatch(ReturnBookSuccess(response)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 4 spaces but found 2 indent |
||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 2 spaces but found 0 indent |
||
.catch((error)=>{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 2 spaces but found 0 indent |
||
dispatch(showErrorNotification({error})) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 4 spaces but found 2 indent |
||
dispatch(ReturnBookRejected(error)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 4 spaces but found 2 indent |
||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected indentation of 2 spaces but found 0 indent |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too many blank lines at the end of file. Max of 1 allowed no-multiple-empty-lines |
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
$font-stack: 'Coiny', sans-serif; | ||
$font-stack2: 'Purple Purse', sans-serif; | ||
$base-orange: #f2751c; | ||
$base-white: white; | ||
$base-white: #ffffff; | ||
$base-background: rgb(204, 204, 204); | ||
$secondary-color: #0089ec; | ||
|
||
|
@@ -43,7 +43,7 @@ body { | |
font-family: $font-stack2; | ||
background-color: rgb(204, 204, 204); | ||
display: flex; | ||
min-height: 100vh; | ||
// min-height: 100vh; | ||
flex-direction: column; | ||
} | ||
|
||
|
@@ -76,7 +76,7 @@ form p { | |
.root-wrapper { | ||
min-height: 100%; | ||
display: flex; | ||
min-height: 100vh; | ||
min-height: 95vh; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line should be indented with spaces, not tabs |
||
flex-direction: column; | ||
} | ||
|
||
|
@@ -174,7 +174,7 @@ form p { | |
} | ||
} | ||
|
||
/** | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
* Footer css | ||
*/ | ||
.footer-copyright { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ import { | |
FETCH_BOOKS_BY_USER_ID, | ||
FETCH_BOOKS_FULFILLED_BY_USER_ID, | ||
BORROW_BOOKS_FAIL, | ||
BORROW_BOOKS_SUCCESS | ||
BORROW_BOOKS_SUCCESS, | ||
RETURN_BOOKS_FAIL, | ||
RETURN_BOOKS_SUCCESS | ||
} from '../actions/actiontype'; | ||
|
||
/** | ||
|
@@ -24,8 +26,7 @@ export default function bookReducer(state = { | |
books: { books: [] }, | ||
borrowedbooks: { books: [] }, | ||
fetching: false, | ||
fetched: false, | ||
error: null | ||
fetched: false | ||
}, action) { | ||
switch (action.type) { | ||
case FETCH_BOOKS: | ||
|
@@ -77,6 +78,21 @@ export default function bookReducer(state = { | |
error: action | ||
} | ||
} | ||
case RETURN_BOOKS_SUCCESS: | ||
{ | ||
return { | ||
...state, | ||
returnedbooks: action | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon semi |
||
} | ||
case RETURN_BOOKS_FAIL: | ||
{ | ||
return { | ||
...state, | ||
returnedbooks:{}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space before value for key 'returnedbooks' key-spacing |
||
error: action | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon semi |
||
} | ||
default: | ||
return state; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
// import nodemailer from 'nodemailer'; | ||
|
||
|
||
// export function sendResetPasswordEmail(user) { | ||
// const tranport = setup(); | ||
// const email = { | ||
// from, | ||
// to: user.email, | ||
// subject: 'Reset Password', | ||
// text: ` | ||
// To reset password follow this link | ||
// ${user.generateResetPasswordLink()} | ||
// ` | ||
// }; | ||
|
||
// tranport.sendMail(email); | ||
// } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected indentation of 2 spaces but found 0 indent