Skip to content

Commit

Permalink
fixed some search bugs -- search button appearance still problematic"
Browse files Browse the repository at this point in the history
  • Loading branch information
bpiv400 committed Dec 12, 2017
1 parent 9e0bcb9 commit e1992b4
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
4 changes: 2 additions & 2 deletions public/javascripts/search.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions search/debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
[1209/131846.312:ERROR:crash_report_database_win.cc(427)] unexpected header
[1210/152025.139:ERROR:crash_report_database_win.cc(427)] unexpected header
[1210/173310.454:ERROR:crash_report_database_win.cc(427)] unexpected header
[1212/015808.681:ERROR:crash_report_database_win.cc(427)] unexpected header
[1212/024125.601:ERROR:crash_report_database_win.cc(427)] unexpected header
2 changes: 1 addition & 1 deletion search/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const type = (value) => {
const order = (choice) => {
var value;
if (!choice) {
value = 1;
value = -1;
} else {
value = choice.value;
}
Expand Down
36 changes: 22 additions & 14 deletions search/src/components/ResultsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export default class ResultsContainer extends React.Component {
var ascendingLabel = 'Low to High';
var descendingLabel = 'High to Low';
if (this.state.sort === 'date') {
ascendingLabel = 'Most Recent First';
descendingLabel = 'Oldest First';
ascendingLabel = 'Oldest First';
descendingLabel = 'Most Recent First';
}
out.push({value : 1 , label : ascendingLabel});
out.push({value : -1, label : descendingLabel});
Expand Down Expand Up @@ -168,6 +168,24 @@ export default class ResultsContainer extends React.Component {
var sortOptions = this.getSortOptions();
var orderOptions = this.getOrderOptions();
var limitOptions = this.getLimitOptions();
var prevButton = null;
if (this.state.page !== 1) {
prevButton = (
<div className = 'col-xs-2'>
<button className = 'btn'
onClick = {this.onPrevPage}>
{'Prev'}
</button>
</div>
);
}
var nextButton = (
<div className = 'col-xs-2'>
<button className = 'btn'
onClick = {this.onNextPage}>
{'Next'}
</button>
</div>);
var termArray = initialState.possTerms.map( function(currTerm) {
return (
<label>
Expand Down Expand Up @@ -281,21 +299,11 @@ export default class ResultsContainer extends React.Component {
onChange = {this.onLimit}
/> </label>
</div>
<div className = 'col-xs-2'>
<button className = 'btn'
onClick = {this.onPrevPage}>
{'Prev'}
</button>
</div>
{prevButton}
<div className = 'col-xs-2'>
<p> {'Page: ' + this.state.page} </p>
</div>
<div className = 'col-xs-2'>
<button className = 'btn'
onClick = {this.onNextPage}>
{'Next'}
</button>
</div>
{nextButton}
</div>
</div>
</div>
Expand Down
23 changes: 18 additions & 5 deletions search/src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,33 @@ const mainReducer = (state, action) => {
apartments: newApartments});
}
case 'ORDER': {
return _.assign({}, state, {ord : action.value});
return _.assign({}, state, {
ord : action.value,
page : 1
});
}

case 'FURNISH': {
return _.assign({}, state, {furnished : action.value});
return _.assign({}, state, {
furnished : action.value,
page: 1
});
}
case 'PAGE': {
return _.assign({}, state, {page : action.value});
}
case 'TERM': {
console.log(action.value);
return _.assign({}, state, {term : action.value});
return _.assign({}, state, {
term : action.value,
page : 1
});
}
case 'OCCUPANCY': {
return _.assign({}, state, {occupancy : action.value});
return _.assign({}, state, {
occupancy : action.value,
page : 1
});
}
case 'LIMIT': {
return _.assign({}, state, {
Expand All @@ -44,7 +56,8 @@ const mainReducer = (state, action) => {
case 'PRICE': {
return _.assign({}, state, {
minPrice: action.min,
maxPrice: action.max
maxPrice: action.max,
page: 1
});
}
default : {
Expand Down

0 comments on commit e1992b4

Please sign in to comment.