Skip to content

Commit dde0412

Browse files
committed
better error messages with no location results
1 parent 43c7991 commit dde0412

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

src/components/contractors/Contractors.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ class Contractors extends Component {
124124
this.state.contractor_response.location.pretty
125125
)
126126

127+
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+
)
134+
// location error can be 'rate_limited' pr 'no_results'
135+
if (location_error === 'rate_limited') {
136+
error_message = this.props.root.get_text('no_tutors_found_rate_limited')
137+
} else if (location_error === 'no_results') {
138+
error_message = this.props.root.get_text('no_tutors_found_no_loc', {location: this.state.location_str})
139+
} else if (location_pretty) {
140+
error_message = this.props.root.get_text('no_tutors_found_loc', {location: location_pretty})
141+
} else {
142+
error_message = this.props.root.get_text('no_tutors_found')
143+
}
144+
}
127145
let description = ''
128146
if (con_count) {
129147
const description_prefix = []
@@ -164,11 +182,9 @@ class Contractors extends Component {
164182
<DisplayComponent
165183
contractors={this.state.contractor_response ? this.state.contractor_response.results : []}
166184
root={this.props.root}/>
167-
<If v={this.state.contractor_response && this.state.contractor_response.count === 0}>
185+
<If v={error_message}>
168186
<div className="tcs-no-contractors">
169-
{this.props.root.get_text(
170-
this.state.location_str === null ? 'no_tutors_found' : 'no_tutors_found_loc', {location_pretty}
171-
)}
187+
{error_message}
172188
</div>
173189
</If>
174190

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ const STRINGS = {
4242
review_hours: '({hours} hours)',
4343
previous: 'Previous',
4444
next: 'Next',
45-
no_tutors_found: 'No more tutors found',
46-
no_tutors_found_loc: 'No more tutors found near "{location_pretty}"',
45+
no_tutors_found: 'No tutors found.',
46+
no_tutors_found_loc: 'No more tutors found near "{location}".',
47+
no_tutors_found_no_loc: 'No more tutors, unable to locate "{location}".',
48+
no_tutors_found_rate_limited: 'Too many location lookups, no results.',
4749
distance_away: '{distance}km away',
4850
}
4951

src/tests/utils.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ export const STRINGS = {
118118
grecaptcha_missing: 'This captcha is required',
119119
required: ' (Required)',
120120
subject_filter_placeholder: 'Select a subject...',
121-
subject_filter_summary_single: '{subject}: showing 1 result',
122-
subject_filter_summary_plural: '{subject}: showing {count} results',
121+
filter_summary_single: '{prefix}: showing 1 result',
122+
filter_summary_plural: '{prefix}: showing {count} results',
123123
location_input_placeholder: 'Enter your address or zip/postal code...',
124124
view_profile: 'View Profile',
125125
review_hours: '({hours} hours)',
126126
previous: 'Previous',
127127
next: 'Next',
128-
no_tutors_found: 'No more tutors found',
129-
no_tutors_found_loc: 'No more tutors found near this location',
128+
no_tutors_found: 'No tutors found.',
129+
no_tutors_found_loc: 'No more tutors found near "{location}".',
130+
no_tutors_found_no_loc: 'No more tutors, unable to locate "{location}".',
131+
no_tutors_found_rate_limited: 'Too many location lookups, no results.',
130132
distance_away: '{distance}km away',
131133
}

0 commit comments

Comments
 (0)