Skip to content

Commit

Permalink
chore (Implement changes to API docs):
Browse files Browse the repository at this point in the history
- Correct routes inputted into API docs
- Loan History component constructed

[Finishes #152996650]
  • Loading branch information
Benny Ogidan authored and Benny Ogidan committed Nov 20, 2017
1 parent ea42d72 commit 0f8dc3f
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 5 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file removed apiDocs/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions apiDocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ <h2 id='loan-a-book'>Loan a Book</h2>
<span class="p">}</span>
</code></pre><h3 id='request-6'>Request</h3>
<ul>
<li>Endpoint: POST: <code>/users/:userId/books</code></li>
<li>Endpoint: POST: <code>/users/loanbook</code></li>
<li>Requires: Authorization</li>
</ul>
<h3 id='response-6'>Response</h3>
Expand Down Expand Up @@ -557,7 +557,7 @@ <h2 id='get-list-of-borrowed-books'>Get list of borrowed books</h2>
<span class="p">}</span>
</code></pre><h3 id='request-7'>Request</h3>
<ul>
<li>Endpoint: GET: <code>/api/v1/users/:userid/books?returned=false</code></li>
<li>Endpoint: GET: <code>/api/v1/users/borrowedbooks?returned=false</code></li>
<li>Requires: Authorization</li>
</ul>
<h3 id='response-7'>Response</h3>
Expand Down Expand Up @@ -610,7 +610,7 @@ <h2 id='return-book-from-loan'>Return book from loan</h2>
<span class="p">}</span>
</code></pre><h3 id='request-8'>Request</h3>
<ul>
<li>Endpoint: PUT: <code>/users/:userId/books</code></li>
<li>Endpoint: PUT: <code>/users/returnbook</code></li>
<li>Requires: Authorization</li>
</ul>
<h3 id='response-8'>Response</h3>
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const SideNav = ({
/>

<li><div className="divider" /></li>
<li><a className="waves-effect" href="www.andela.com">Third Link With Waves</a></li>
<li><a className="waves-effect" href="www.andela.com">Categories</a></li>
</ul>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';


/**
* Table of Loan history
* @param {Object} props props object containing books
* @returns {JSX} JSX representation of Books table
*/
const BorrowHistoryTable = (props) => {
const rows = props.books && props.books.length ? props.books.map((book) => {
const returned = book.BorrowedBook.returned;
return (
<tr key={book.book.id}>
<td>{book.book.title || 'N/A'}</td>
<td>{book.book.author || 'N/A'}</td>
<td>{moment(book.book.createdAt).format('LLLL') || 'N/A'}</td>
<td>{moment(book.book.returndate).format('LLLL') || 'N/A'}</td>
<td>{moment(book.book.userReturndate).format('LLLL') || 'N/A'}</td>
<td>{book.book.returnstatus ? 'Returned' : 'Unreturned'}</td>
</tr>
);
}) : null;
return (rows ?
<div className="row">
<div className="center" style={{ width: '95%', margin: 'auto' }}>
<table className="centered bordered history-table">
<thead>
<tr>
<th>Title</th>
<th>Authors</th>
<th>Date Borrowed</th>
<th>Date To Be Returned</th>
<th>User Return Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{rows}
</tbody>
</table>
</div>
</div> :
<div className="row">
<div className="container">
<h3 className="center bold-text" style={{ color: '#aaa' }}>
You have no borrowing history. Head over to the library to get started
</h3>
</div>
</div>
);
};

BorrowHistoryTable.propTypes = {
books: PropTypes.array.isRequired,
};


export default BorrowHistoryTable;
3 changes: 2 additions & 1 deletion client/src/app/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ form p {
*/
.footer-copyright {
background-color: $base-orange !important;
min-height:60px !important;
}
footer {
height: 3rem;
Expand Down Expand Up @@ -271,7 +272,7 @@ footer {
position: relative;
display: inline-block;
color: #543a27 !important;
max-width: 40%;
max-width: 35%;
background-color: #ffdec7 !important;
}

Expand Down
1 change: 1 addition & 0 deletions server/src/controllers/userbooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default {
});
},


/**
* Route: GET: /users/getborrowedBooklist
* @description Get list of borrowed books
Expand Down

0 comments on commit 0f8dc3f

Please sign in to comment.