@@ -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 }
0 commit comments