Skip to content

Commit 35efeb2

Browse files
committed
fix pagination buttons and con list error messages
1 parent dde0412 commit 35efeb2

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

src/components/contractors/Contractors.js

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ class Contractors extends Component {
9494
const contractor_response = await this.props.root.requests.get('contractors', args)
9595
this.props.config.event_callback('updated_contractors', contractor_response)
9696
this.setState({contractor_response: {results: []}})
97+
const on_previous_pages = (page - 1) * this.props.config.pagination
9798
setTimeout(() => this.setState({
9899
contractor_response,
99-
more_pages: contractor_response.count > contractor_response.results.length,
100+
more_pages: contractor_response.count > contractor_response.results.length + on_previous_pages,
100101
}), 0)
101102
}
102103

@@ -125,12 +126,9 @@ class Contractors extends Component {
125126
)
126127

127128
let error_message = null
128-
if (this.state.contractor_response && this.state.contractor_response.count === 0) {
129-
const location_error = (
130-
this.state.contractor_response &&
131-
this.state.contractor_response.location &&
132-
this.state.contractor_response.location.error
133-
)
129+
let description = null
130+
if (con_count === 0) {
131+
const location_error = this.state.contractor_response.location && this.state.contractor_response.location.error
134132
// location error can be 'rate_limited' pr 'no_results'
135133
if (location_error === 'rate_limited') {
136134
error_message = this.props.root.get_text('no_tutors_found_rate_limited')
@@ -141,22 +139,12 @@ class Contractors extends Component {
141139
} else {
142140
error_message = this.props.root.get_text('no_tutors_found')
143141
}
144-
}
145-
let description = ''
146-
if (con_count) {
147-
const description_prefix = []
148-
if (location_pretty) {
149-
description_prefix.push(location_pretty)
150-
}
151-
if (this.state.selected_subject) {
152-
description_prefix.push(this.state.selected_subject.name)
153-
}
154-
if (description_prefix.length > 0) {
155-
description = this.props.root.get_text('filter_summary_' + (con_count === 1 ? 'single' : 'plural'), {
156-
count: con_count,
157-
prefix: description_prefix.join('; '),
158-
})
159-
}
142+
} else if (con_count > 0) {
143+
description = [
144+
location_pretty,
145+
this.state.selected_subject && this.state.selected_subject.name,
146+
this.props.root.get_text('filter_summary_' + (con_count === 1 ? 'single' : 'plural'), {count: con_count})
147+
].filter(Boolean).join(' • ')
160148
}
161149
const DisplayComponent = this.props.config.mode === 'grid' ? Grid : List
162150
return (
@@ -207,8 +195,8 @@ class Contractors extends Component {
207195
<Route path={this.props.root.url(':id(\\d+):_extra')} render={props => (
208196
<ConModal id={props.match.params.id}
209197
last_url={this.state.last_url}
210-
contractors={this.state.contractor_response.results}
211-
got_contractors={!!this.state.contractor_response}
198+
contractors={this.state.contractor_response && this.state.contractor_response.results}
199+
got_contractors={Boolean(this.state.contractor_response)}
212200
get_contractor_details={this.get_contractor_details}
213201
root={this.props.root}
214202
config={this.props.config}

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const STRINGS = {
3535
grecaptcha_missing: 'This captcha is required',
3636
required: ' (Required)',
3737
subject_filter_placeholder: 'Select a subject...',
38-
filter_summary_single: '{prefix}: showing 1 result',
39-
filter_summary_plural: '{prefix}: showing {count} results',
38+
filter_summary_single: 'showing 1 result',
39+
filter_summary_plural: 'showing {count} results',
4040
location_input_placeholder: 'Enter your address or zip/postal code...',
4141
view_profile: 'View Profile',
4242
review_hours: '({hours} hours)',

0 commit comments

Comments
 (0)