-
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
feature(search): Implement search feature app #37
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,29 @@ | ||
import { showErrorNotification } from './notifications'; | ||
import { | ||
SEARCH_BOOKS_SUCCESS, | ||
SEARCH_BOOKS_FAILURE | ||
} from './actiontype'; | ||
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. Unable to resolve path to module './actiontype' import/no-unresolved |
||
import api from './api'; | ||
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. Unable to resolve path to module './api' import/no-unresolved |
||
|
||
export const SearchBookSuccess = books => ({ type: SEARCH_BOOKS_SUCCESS, books }); | ||
export const SearchBookFailure = error => ({ type: SEARCH_BOOKS_FAILURE, error }); | ||
|
||
|
||
/** | ||
* async helper function: search Books | ||
* @function SearchBooks | ||
* @param {object} value | ||
* @returns {function} asynchronous action | ||
*/ | ||
export const searchAllBooks = value => dispatch => api | ||
.book | ||
.searchBooks(value) | ||
.then((response) => { | ||
dispatch(SearchBookSuccess(response.booksFound)); | ||
return (response); | ||
}) | ||
.catch((error) => { | ||
dispatch(showErrorNotification({ error })); | ||
dispatch(SearchBookFailure({ error })); | ||
return error; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { Row, Preloader, Col } from 'react-materialize'; | |
import Book from '../../presentation/common/book/DisplayBook.jsx'; | ||
import { fetchAllBooks } from '../../../actions/fetchbooks'; | ||
import PaginationWrapper from '../common/Pagination.jsx'; | ||
import SearchBooks from '../../presentation/common/book/SearchBooks.jsx'; | ||
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. Unable to resolve path to module '../../presentation/common/book/SearchBooks.jsx' import/no-unresolved |
||
|
||
/** | ||
* @description Component for Display Books on the Landing page for all users | ||
|
@@ -65,6 +66,9 @@ this.props.allBooksList.books.map(book => ( | |
}; | ||
return ( | ||
<div> | ||
<Row> | ||
<SearchBooks /> | ||
</Row> | ||
<Row> | ||
<Col l={12}> | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
import React from 'react'; | ||
import { Row } from 'react-materialize'; | ||
import { Row, Icon, Col } from 'react-materialize'; | ||
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. 'Icon' is defined but never used no-unused-vars |
||
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; | ||
import PropTypes from 'prop-types'; | ||
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. Unable to resolve path to module 'prop-types' import/no-unresolved |
||
import SideNav from '../presentation/common/SideNav/index.jsx'; | ||
import DisplayAllBorrowedBooks from '../container/booklist/DisplayBorrowedBooks.jsx'; | ||
import DisplayAllBooks from '../container/booklist/DisplayAllBooks.jsx'; | ||
import LoanHistoryTable from '../container/loanhistory/LoanHistory.jsx'; | ||
import DisplayOverdueBooks from '../container/booklist/DisplayOverdueBooks.jsx'; | ||
|
||
|
||
/** | ||
* @description Show User Dashboard | ||
* @class DashboardView | ||
* @param {object} props | ||
*/ | ||
const Dashoard = props => | ||
const Dashboard = props => | ||
( | ||
<div> | ||
<div className="main-wrapper"> | ||
|
@@ -24,12 +26,19 @@ const Dashoard = props => | |
/> | ||
<div className="main-text"> | ||
<Tabs> | ||
<TabList> | ||
<Tab>DASHBOARD</Tab> | ||
<Tab>ALL BOOKS</Tab> | ||
<Tab>BOOKS OVERDUE</Tab> | ||
<Tab>LOAN HISTORY</Tab> | ||
</TabList> | ||
<Row> | ||
|
||
<TabList> | ||
<Tab>DASHBOARD</Tab> | ||
<Tab>ALL BOOKS</Tab> | ||
<Tab>BOOKS OVERDUE</Tab> | ||
<Tab>LOAN HISTORY</Tab> | ||
</TabList> | ||
|
||
|
||
{/* <Icon tiny>search | ||
</Icon> */} | ||
</Row> | ||
<Row> | ||
<TabPanel> | ||
<DisplayAllBorrowedBooks /> | ||
|
@@ -51,4 +60,12 @@ const Dashoard = props => | |
</div> | ||
); | ||
|
||
export default Dashoard; | ||
Dashboard.propTypes = { | ||
firstname: PropTypes.string.isRequired, | ||
username: PropTypes.string.isRequired, | ||
email: PropTypes.string.isRequired, | ||
profilePic: PropTypes.string.isRequired, | ||
}; | ||
|
||
|
||
export default Dashboard; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ class DisplayBookModal extends React.Component { | |
} | ||
} | ||
|
||
handleChange = date => this.setState({ returndate: date }); | ||
handleChange = date => this.setState({ returnDate: date }); | ||
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. Parsing error: Unexpected token = |
||
|
||
handleReturnClick = (event) =>{ | ||
this. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import { Col, Icon,Autocomplete } from 'react-materialize'; | ||
import { searchAllBooks } from '../../../../actions/searchbooks'; | ||
import { fetchAllBooks } from '../../../../actions/fetchbooks'; | ||
|
||
|
||
/** | ||
* | ||
* | ||
* @class SearchBooks | ||
* @extends {React.Component} | ||
*/ | ||
class SearchBooks extends React.Component { | ||
/** | ||
* Creates an instance of SearchBooks. | ||
* @param {any} props | ||
* | ||
* @memberOf SearchBooks | ||
*/ | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
searchTerm:'', | ||
offset: 0, | ||
limit:8, | ||
dataSource: {} | ||
}; | ||
this.onChange = this.onChange.bind(this) | ||
} | ||
|
||
onChange = (event, value ) => { | ||
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. Parsing error: Unexpected token = |
||
event.preventDefault(); | ||
this.setState({ | ||
searchTerm: value | ||
}); | ||
if(value.length> 1){ | ||
this.props.searchAllBooks(value) | ||
} | ||
else{ | ||
this.props.fetchAllBooks(this.state.offset, this.state.limit); | ||
} | ||
|
||
}; | ||
|
||
render() { | ||
return ( | ||
<Col s={12} m={3} l={3}> | ||
<div className='autocomplete'> | ||
<Col s={2}> | ||
<div className='autocomplete-icon'> | ||
<Icon medium>search | ||
</Icon> | ||
</div> | ||
</Col> | ||
<Col s={10}> | ||
<Autocomplete | ||
placeholder='Search.....' | ||
data ={this.state.dataSource} | ||
onChange= {this.onChange} | ||
/> | ||
</Col> | ||
|
||
</div> | ||
</Col> | ||
|
||
); | ||
} | ||
} | ||
|
||
|
||
export default connect(null, { fetchAllBooks, searchAllBooks })(SearchBooks); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,20 @@ footer { | |
color: $base-white; | ||
} | ||
|
||
.autocomplete{ | ||
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. Opening curly brace |
||
height: 2.4rem !important; | ||
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 |
||
} | ||
|
||
i.medium{ | ||
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. Avoid qualifying class selectors with an element. |
||
font-size: 2.5rem ; | ||
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 |
||
padding-top: 14px ; | ||
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 |
||
// margin-left: -6px; | ||
} | ||
|
||
.react-autosuggest__container{ | ||
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. Selector |
||
padding-top: 5.5px; | ||
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 |
||
} | ||
|
||
.btn { | ||
background-color: black; | ||
font-family: $font-stack2; | ||
|
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.
Unable to resolve path to module './notifications' import/no-unresolved
Missing file extension for "./notifications" import/extensions