-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore (Implement changes to API docs):
- 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
Showing
8 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
client/src/app/components/presentation/loanhistory/LoanHistoryTable.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters