muba-posting 6.0.13 → 6.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Posting.js CHANGED
@@ -5,7 +5,6 @@ import { CommonActions } from '@react-navigation/native';
5
5
  import { loadLocaleData, currentLocale, strings } from 'muba-i18n';
6
6
  import { Views } from './utils/Views';
7
7
  import commonStyles from './commonStyles';
8
- import LoadingCursor from 'muba-loading-cursor';
9
8
  import PopupAdvice from 'muba-popup-advice';
10
9
  import OutputText from 'muba-output-text';
11
10
  import { addFontList } from 'muba-font';
@@ -35,6 +34,7 @@ const MAX_PICTURES = { method: 'GET', url: '/controller/posting/max-pictures' };
35
34
  const COUNTRY_PHONE = { method: 'GET', url: '/controller/countries/{countryCode}/phones' };
36
35
  const LOAD_PENDING_CREATED = { method: 'GET', url: '/controller/ads/pending-created/posting' };
37
36
  const PAYMENT_ONLINE_ACTIVE = { method: 'GET', url: '/controller/payments-online/{countryCode}/active' };
37
+ const LOAD_LOCATIONS = { method: 'GET', url: '/controller/countries/{countryCode}/locations' };
38
38
  const UPLOADED_FILES_KEY = 'uploadedFiles';
39
39
 
40
40
  export default class Posting extends React.Component {
@@ -57,7 +57,6 @@ export default class Posting extends React.Component {
57
57
  prevViews: [],
58
58
  currentScreen: 1,
59
59
  fontLoaded: false,
60
- isLoading: false,
61
60
  adId: this.props.adId,
62
61
  maxPictures: 0,
63
62
  countryPhone: '',
@@ -65,6 +64,7 @@ export default class Posting extends React.Component {
65
64
  realEstateDeveloper: this.props.realEstateDeveloper === true,
66
65
  picturesUploaded: 0,
67
66
  params: null,
67
+ locationList: [],
68
68
  postingAd: {
69
69
  transaction: null,
70
70
  adType: null,
@@ -189,8 +189,9 @@ export default class Posting extends React.Component {
189
189
  }
190
190
 
191
191
  loadData = async (canPublish) => {
192
+ this._showLoading()
192
193
  if (canPublish) {
193
- const resultJson = await this.props.request(this, COUNTRY_PHONE);
194
+ const resultJson = await this.props.request(this.props.context, COUNTRY_PHONE);
194
195
  if (resultJson.httpStatus === 200) {
195
196
  this.setState({ countryPhone: resultJson.list[0].formattedPhone });
196
197
  }
@@ -207,17 +208,15 @@ export default class Posting extends React.Component {
207
208
  this.props.changeView(this.state.originView)
208
209
  }
209
210
  } else {
210
- await this.setState({ isLoading: false });
211
211
  if (!hasListings) {
212
212
  this.popupNoListings.show();
213
213
  } else {
214
- const pendingAd = await this.props.request(this, LOAD_PENDING_CREATED, { businessId: this.state.businessId });
214
+ const pendingAd = await this.props.request(this.props.context, LOAD_PENDING_CREATED, { businessId: this.state.businessId });
215
215
  if (pendingAd.httpStatus === 200) {
216
216
  const languages = pendingAd?.languages.length > 0 ? pendingAd?.languages : this.state.postingAd.languages
217
217
  const languageId = languages[0].language;
218
218
  await this.setState({
219
- postingAd: { ...this.state.postingAd, ...pendingAd, languageId: languageId, languages: languages },
220
- isLoading: false
219
+ postingAd: { ...this.state.postingAd, ...pendingAd, languageId: languageId, languages: languages }
221
220
  });
222
221
  }
223
222
 
@@ -227,10 +226,15 @@ export default class Posting extends React.Component {
227
226
  }
228
227
  }
229
228
  }
229
+
230
+ this._hideLoading()
231
+ this.props.request(this.props.context, LOAD_LOCATIONS, { regions: true, cities: true, districts: true, towns: true }).then(data => {
232
+ this.setState({ locationList: data.list });
233
+ });
230
234
  BackHandler.addEventListener('hardwareBackPress', this.goBack);
231
235
  } else {
232
236
  this.goBack();
233
- await this.setState({ isLoading: false });
237
+ this._hideLoading()
234
238
  }
235
239
  }
236
240
 
@@ -253,12 +257,12 @@ export default class Posting extends React.Component {
253
257
  }
254
258
 
255
259
  async checkListings() {
256
- const responseJson = await this.props.request(this, BUSINESS_PRODUCTS, { key: 'LISTING' });
260
+ const responseJson = await this.props.request(this.props.context, BUSINESS_PRODUCTS, { key: 'LISTING' });
257
261
  return responseJson.value > 0;
258
262
  }
259
263
 
260
264
  async readBusinessId() {
261
- const responseJson = await this.props.request(this, BUSINESS_ID, { userId: this.props.userId });
265
+ const responseJson = await this.props.request(this.props.context, BUSINESS_ID, { userId: this.props.userId });
262
266
  if (responseJson.httpStatus === 200) {
263
267
  this.setState({
264
268
  businessId: responseJson.value,
@@ -268,7 +272,7 @@ export default class Posting extends React.Component {
268
272
  }
269
273
 
270
274
  async getMaxPictures() {
271
- const responseJson = await this.props.request(this, MAX_PICTURES);
275
+ const responseJson = await this.props.request(this.props.context, MAX_PICTURES);
272
276
  if (responseJson.httpStatus === 200) {
273
277
  this.setState({
274
278
  maxPictures: responseJson.value
@@ -283,15 +287,13 @@ export default class Posting extends React.Component {
283
287
  const languageId = languages[0].language;
284
288
  await this.setState({
285
289
  postingAd: { ...this.state.postingAd, ...bddAd, languageId: languageId, languages: languages },
286
- isLoading: false,
287
290
  adId: null,
288
291
  originView: Views.PUBLISH_1,
289
292
  fullPosting: true
290
293
  })
291
294
  } else {
292
295
  await this.setState({
293
- postingAd: { ...this.state.postingAd, ...bddAd },
294
- isLoading: false
296
+ postingAd: { ...this.state.postingAd, ...bddAd }
295
297
  });
296
298
  }
297
299
  }
@@ -306,7 +308,7 @@ export default class Posting extends React.Component {
306
308
  if (Views.PUBLISH_4 !== this.state.view) {
307
309
  delete ad.images;
308
310
  }
309
- const response = await this.props.request(this, CREATE_AD, ad);
311
+ const response = await this.props.request(this.props.context, CREATE_AD, ad);
310
312
  if (response.httpStatus === 200) {
311
313
  let images = this.state.postingAd.images;
312
314
  if (response[UPLOADED_FILES_KEY]) {
@@ -356,34 +358,35 @@ export default class Posting extends React.Component {
356
358
  this.scroll.scrollTop();
357
359
  this.setState({ view: view });
358
360
  if (this.props.changeView && Views.PAYMENT_ONLINE !== view) {
359
- this.props.changeView(view)
361
+ this.props.changeView(view);
362
+ }
363
+
364
+ if (Views.PAYMENT_ONLINE !== view) {
365
+ this.props.showTopBar();
366
+ } else {
367
+ this.props.hideTopBar();
360
368
  }
361
369
  }
362
370
 
363
371
  goBack = async () => {
364
- if (!this.state.showImageBrowser) {
365
- if (this.state.prevViews.length === 0 || this.state.view === Views.PREVIEW) {
366
- this.props.navigation.dispatch(state => {
367
- state.routes.splice(state.routes.length - 1, 1);
368
- const routes = state.routes.map(r => { return { name: r.name } });
369
-
370
- return CommonActions.reset({
371
- routes,
372
- index: routes.length - 1
373
- });
372
+ if (this.state.prevViews.length === 0 || this.state.view === Views.PREVIEW) {
373
+ this.props.navigation.dispatch(state => {
374
+ state.routes.splice(state.routes.length - 1, 1);
375
+ const routes = state.routes.map(r => { return { name: r.name } });
376
+
377
+ return CommonActions.reset({
378
+ routes,
379
+ index: routes.length - 1
374
380
  });
375
- } else {
376
- const prevViews = [...this.state.prevViews];
381
+ });
382
+ } else {
383
+ const prevViews = [...this.state.prevViews];
377
384
 
378
- prevViews.shift();
385
+ prevViews.shift();
379
386
 
380
- const view = this.state.prevViews[0];
381
- await this.setState({ prevViews: prevViews });
382
- this._updateCurrentScreen(view);
383
- }
384
- } else if (this.state.showImageBrowser) {
385
- await this.setState({ showImageBrowser: false })
386
- this.setState({ view: Views.PUBLISH_4 })
387
+ const view = this.state.prevViews[0];
388
+ await this.setState({ prevViews: prevViews });
389
+ this._updateCurrentScreen(view);
387
390
  }
388
391
  }
389
392
 
@@ -393,10 +396,9 @@ export default class Posting extends React.Component {
393
396
  if (this.state.originView === Views.EDIT_SELECTOR && Views.PUBLISH_4 !== this.state.view) {
394
397
  delete ad.images;
395
398
  }
396
- const response = await this.props.request(this, UPDATE_AD, ad);
399
+ const response = await this.props.request(this.props.context, UPDATE_AD, ad);
397
400
  if (this.props.adId) {
398
401
  if (this.state.originView === Views.EDIT_SELECTOR) {
399
- this.setState({ isLoading: true });
400
402
  await this.loadAd();
401
403
  this._goToPage(Views.EDIT_SELECTOR);
402
404
  } else {
@@ -406,7 +408,7 @@ export default class Posting extends React.Component {
406
408
  await this.setState({ postingAd: { ...this.state.postingAd, adId: response.id } });
407
409
  this._goToPage(Views.PREVIEW, null, response);
408
410
 
409
- const paymentOnlineActive = await this.props.request(this, PAYMENT_ONLINE_ACTIVE, { regionId: this.state.postingAd.region });
411
+ const paymentOnlineActive = await this.props.request(this.props.context, PAYMENT_ONLINE_ACTIVE, { regionId: this.state.postingAd.region });
410
412
  if (!this.state.businessId && paymentOnlineActive.value === 'true') {
411
413
  this._goToPage(Views.PAYMENT_ONLINE);
412
414
  }
@@ -419,12 +421,12 @@ export default class Posting extends React.Component {
419
421
  }
420
422
 
421
423
  async _showLoading() {
422
- this.setState({ isLoading: true });
424
+ this.props.showLoading();
423
425
  }
424
426
 
425
427
  async _hideLoading() {
426
- await this.sleep(500);
427
- this.setState({ isLoading: false });
428
+ await this.sleep(300);
429
+ this.props.hideLoading();
428
430
  }
429
431
 
430
432
  sleep = (ms) => {
@@ -432,7 +434,7 @@ export default class Posting extends React.Component {
432
434
  }
433
435
 
434
436
  getAd = async (id) => {
435
- const responseJson = await this.props.request(this, AD, {
437
+ const responseJson = await this.props.request(this.props.context, AD, {
436
438
  adId: id
437
439
  });
438
440
 
@@ -441,204 +443,197 @@ export default class Posting extends React.Component {
441
443
 
442
444
  render() {
443
445
  return (
444
- <View style={[commonStyles.flex1, commonStyles.containerBg]}>
445
- <LoadingCursor loading={this.state.isLoading} />
446
-
447
- <View style={commonStyles.flex1}>
448
- <View>
449
- {!this.state.showImageBrowser && this.state.view !== Views.PAYMENT_ONLINE ? this.props.topBar : null}
450
- </View>
451
-
452
- <PopupPermissions ref={(element) => this.popupPermissions = element} camera={true} mediaLibrary={true} sensor={true} message={strings('setup.permissionsMessage')} onClose={this.loadData} />
453
-
454
- {this.state.fontLoaded ?
455
- <View style={[this.props.containerStyle, this.state.showImageBrowser ? commonStyles.displayNone : '']}>
456
- <CustomScrollView ref={(element) => this.scroll = element}>
457
- {this.state.view !== Views.PREVIEW && this.state.view !== Views.PAYMENT_ONLINE ?
458
- <View>
459
- {
460
- this.state.adId == null ?
461
- <PublishProgressBar currentScreen={this.state.currentScreen} />
462
- :
463
- <EditHead postingAd={this.state.postingAd} />
464
- }
465
- </View>
466
- :
467
- null
468
- }
469
-
470
- {this.state.view === Views.PUBLISH_1 ?
471
- <Publish1 postingAd={this.state.postingAd}
472
- request={this.props.request}
473
- context={this.props.context}
474
- showLoading={() => this._showLoading()}
475
- hideLoading={() => this._hideLoading()}
476
- scroll={(ref) => this.scroll.scrollIntoView(ref)}
477
- fullPosting={this.state.fullPosting}
478
- goToPage={(view, editingStepOne) => this._goToPage(view, editingStepOne)}
479
- saveEditAd={() => this._saveEditAd()}
480
- realEstateDeveloper={this.state.realEstateDeveloper}
481
- businessId={this.state.businessId}
482
- showNoPromotions={() => this.popupNoPromotions.show()} />
483
- :
484
- null
485
- }
486
-
487
- {this.state.view === Views.PUBLISH_2 ?
488
- <Publish2 postingAd={this.state.postingAd}
489
- scroll={(ref) => this.scroll.scrollIntoView(ref)}
490
- saveEditAd={() => this._saveEditAd()}
491
- goToPage={(view) => this._goToPage(view)}
492
- replacePage={(view) => this._updateCurrentScreen(view)}
493
- baseUrl={this.props.baseUrl}
494
- request={this.props.request}
495
- context={this.props.context}
496
- showLoading={() => this._showLoading()}
497
- hideLoading={() => this._hideLoading()}
498
- hereApiKey={this.props.hereApiKey}
499
- fullPosting={this.state.fullPosting}
500
- businessId={this.state.businessId} />
501
- :
502
- null
503
- }
504
-
505
- {this.state.view === Views.PUBLISH_2_B ?
506
- <Publish2b postingAd={this.state.postingAd}
507
- scroll={(ref) => this.scroll.scrollIntoView(ref)}
508
- saveEditAd={() => this._saveEditAd()}
509
- goToPage={(view) => this._goToPage(view)}
510
- replacePage={(view) => this._updateCurrentScreen(view)}
511
- request={this.props.request}
512
- context={this.props.context}
513
- showLoading={() => this._showLoading()}
514
- hideLoading={() => this._hideLoading()}
515
- fullPosting={this.state.fullPosting}
516
- businessId={this.state.businessId} />
517
- :
518
- null
519
- }
520
-
521
- {this.state.view === Views.PUBLISH_3 ?
522
- <Publish3 postingAd={this.state.postingAd}
523
- editingStepOne={this.state.editingStepOne}
524
- scroll={(ref) => this.scroll.scrollIntoView(ref)}
525
- saveEditAd={() => this._saveEditAd()}
526
- goToPage={(view) => this._goToPage(view)}
527
- goBack={() => this.goBack()}
528
- request={this.props.request}
529
- context={this.props.context}
530
- showLoading={() => this._showLoading()}
531
- hideLoading={() => this._hideLoading()}
532
- fullPosting={this.state.fullPosting} />
533
- :
534
- null
535
- }
536
-
537
- {this.state.view === Views.PUBLISH_4 ?
538
- <Publish4 postingAd={this.state.postingAd}
539
- ref={publish4 => this.publish4 = publish4}
540
- saveEditAd={() => this._saveEditAd()}
541
- goToPage={(view) => this._goToPage(view)}
542
- request={this.props.request}
543
- context={this.props.context}
544
- showLoading={() => this._showLoading()}
545
- hideLoading={() => this._hideLoading()}
546
- fullPosting={this.state.fullPosting}
547
- maxPictures={this.state.maxPictures} />
548
- :
549
- null
550
- }
551
-
552
- {this.state.view === Views.PUBLISH_5 ?
553
- <Publish5 postingAd={this.state.postingAd}
554
- scroll={(ref) => this.scroll.scrollIntoView(ref)}
555
- saveEditAd={() => this._saveEditAd()}
556
- goToPage={(view) => this._goToPage(view)}
557
- businessId={this.state.businessId}
558
- request={this.props.request}
559
- context={this.props.context}
560
- showLoading={() => this._showLoading()}
561
- hideLoading={() => this._hideLoading()}
562
- fullPosting={this.state.fullPosting} />
563
- :
564
- null
565
- }
566
-
567
- {this.state.view === Views.PUBLISH_6 ?
568
- <Publish6 postingAd={this.state.postingAd}
569
- country={this.props.country}
570
- businessId={this.state.businessId}
571
- scroll={(ref) => this.scroll.scrollIntoView(ref)}
572
- saveEditAd={() => this._saveEditAd()}
573
- goToPage={(view, params) => this._goToPage(view, null, params)}
574
- request={this.props.request}
575
- context={this.props.context}
576
- showLoading={() => this._showLoading()}
577
- hideLoading={() => this._hideLoading()}
578
- fullPosting={this.state.fullPosting} />
579
- :
580
- null
581
- }
582
-
583
- {this.state.view === Views.PREVIEW ?
584
- <Preview postingAd={this.state.postingAd}
585
- country={this.props.country}
586
- goBack={() => this.goBack()}
587
- showLoading={() => this._showLoading()}
588
- hideLoading={() => this._hideLoading()}
589
- businessId={this.state.businessId}
590
- request={this.props.request}
591
- highlight={() => this._goToPage(Views.PAYMENT_ONLINE)}
592
- params={this.state.params} />
593
- :
594
- null
595
- }
596
-
597
- {this.state.view === Views.EDIT_SELECTOR ?
598
- <PostingEdit postingAd={this.state.postingAd}
599
- topBar={this.props.topBar}
600
- goToPage={(view) => this._goToPage(view)} />
601
- :
602
- null
603
- }
604
-
605
- {this.state.view === Views.PAYMENT_ONLINE ?
606
- <PaymentOnlinePopup
607
- context={this.props.context}
608
- request={this.props.request}
609
- topBar={this.props.topBar}
610
- adId={this.state.postingAd.id}
611
- country={this.props.country}
612
- goToPrivacy={this.props.goToPrivacy}
613
- changeView={this.props.changeView}
614
- close={this.goBack}
615
- goBack={() => this.setState({ view: Views.PREVIEW }, () => this.goBack())} />
616
- :
617
- null
618
- }
619
-
620
- </CustomScrollView>
621
- <PopupAdvice icon={<FontAwesomeIcon name='block' />} title={strings('setup.noPromoteTitle', { product: '' })} headerColor={commonStyles.red} ref={popupAdvice => this.popupNoListings = popupAdvice}
622
- onClose={async () => this.state.view !== Views.PREVIEW ? this.goBack() : null} hideButton={true}>
623
- <OutputText style={commonStyles.popupText}>{strings('setup.noPromoteSubtitle', { countryPhone: this.state.countryPhone })}</OutputText>
624
- <TouchableOpacity style={[commonStyles.okBtnBoxPopup, commonStyles.okBtnPopup]} onPress={() => this.popupNoListings.hide()} >
625
- <OutputText style={commonStyles.okBtnTextPopup}>{strings('setup.adviceOK')}</OutputText>
626
- </TouchableOpacity>
627
- </PopupAdvice>
628
-
629
- <PopupAdvice icon={<FontAwesomeIcon name='block' />} title={strings('setup.noPromotionTitle')} headerColor={commonStyles.red} ref={popupAdvice => this.popupNoPromotions = popupAdvice}
630
- onClose={() => this.goBack()} hideButton={true}>
631
- <OutputText style={commonStyles.popupText}>{strings('setup.noPromotionText')}</OutputText>
632
- <TouchableOpacity style={[commonStyles.okBtnBoxPopup, commonStyles.okBtnPopup]} onPress={() => this.goBack()} >
633
- <OutputText style={commonStyles.okBtnTextPopup}>{strings('setup.adviceOK')}</OutputText>
634
- </TouchableOpacity>
635
- </PopupAdvice>
636
- </View >
637
- :
638
- null
639
- }
640
- </View>
641
- </View >
446
+ <View style={commonStyles.flex1}>
447
+ <PopupPermissions ref={(element) => this.popupPermissions = element} camera={true} mediaLibrary={true} sensor={true} message={strings('setup.permissionsMessage')} onClose={this.loadData} />
448
+
449
+ {this.state.fontLoaded ?
450
+ <View style={[this.props.containerStyle, this.state.showImageBrowser ? commonStyles.displayNone : '']}>
451
+ <CustomScrollView ref={(element) => this.scroll = element}>
452
+ {this.state.view !== Views.PREVIEW && this.state.view !== Views.PAYMENT_ONLINE ?
453
+ <View>
454
+ {
455
+ this.state.adId == null ?
456
+ <PublishProgressBar currentScreen={this.state.currentScreen} />
457
+ :
458
+ <EditHead postingAd={this.state.postingAd} />
459
+ }
460
+ </View>
461
+ :
462
+ null
463
+ }
464
+
465
+ {this.state.view === Views.PUBLISH_1 ?
466
+ <Publish1 postingAd={this.state.postingAd}
467
+ request={this.props.request}
468
+ context={this.props.context}
469
+ showLoading={() => this._showLoading()}
470
+ hideLoading={() => this._hideLoading()}
471
+ scroll={(ref) => this.scroll.scrollIntoView(ref)}
472
+ fullPosting={this.state.fullPosting}
473
+ goToPage={(view, editingStepOne) => this._goToPage(view, editingStepOne)}
474
+ saveEditAd={() => this._saveEditAd()}
475
+ realEstateDeveloper={this.state.realEstateDeveloper}
476
+ businessId={this.state.businessId}
477
+ showNoPromotions={() => this.popupNoPromotions.show()} />
478
+ :
479
+ null
480
+ }
481
+
482
+ {this.state.view === Views.PUBLISH_2 ?
483
+ <Publish2 postingAd={this.state.postingAd}
484
+ scroll={(ref) => this.scroll.scrollIntoView(ref)}
485
+ saveEditAd={() => this._saveEditAd()}
486
+ goToPage={(view) => this._goToPage(view)}
487
+ replacePage={(view) => this._updateCurrentScreen(view)}
488
+ baseUrl={this.props.baseUrl}
489
+ request={this.props.request}
490
+ context={this.props.context}
491
+ showLoading={() => this._showLoading()}
492
+ hideLoading={() => this._hideLoading()}
493
+ hereApiKey={this.props.hereApiKey}
494
+ fullPosting={this.state.fullPosting}
495
+ businessId={this.state.businessId} />
496
+ :
497
+ null
498
+ }
499
+
500
+ {this.state.view === Views.PUBLISH_2_B ?
501
+ <Publish2b postingAd={this.state.postingAd}
502
+ scroll={(ref) => this.scroll.scrollIntoView(ref)}
503
+ saveEditAd={() => this._saveEditAd()}
504
+ goToPage={(view) => this._goToPage(view)}
505
+ replacePage={(view) => this._updateCurrentScreen(view)}
506
+ request={this.props.request}
507
+ context={this.props.context}
508
+ showLoading={() => this._showLoading()}
509
+ hideLoading={() => this._hideLoading()}
510
+ fullPosting={this.state.fullPosting}
511
+ businessId={this.state.businessId}
512
+ locationList={this.state.locationList} />
513
+ :
514
+ null
515
+ }
516
+
517
+ {this.state.view === Views.PUBLISH_3 ?
518
+ <Publish3 postingAd={this.state.postingAd}
519
+ editingStepOne={this.state.editingStepOne}
520
+ scroll={(ref) => this.scroll.scrollIntoView(ref)}
521
+ saveEditAd={() => this._saveEditAd()}
522
+ goToPage={(view) => this._goToPage(view)}
523
+ goBack={() => this.goBack()}
524
+ request={this.props.request}
525
+ context={this.props.context}
526
+ showLoading={() => this._showLoading()}
527
+ hideLoading={() => this._hideLoading()}
528
+ fullPosting={this.state.fullPosting} />
529
+ :
530
+ null
531
+ }
532
+
533
+ {this.state.view === Views.PUBLISH_4 ?
534
+ <Publish4 postingAd={this.state.postingAd}
535
+ ref={publish4 => this.publish4 = publish4}
536
+ saveEditAd={() => this._saveEditAd()}
537
+ goToPage={(view) => this._goToPage(view)}
538
+ request={this.props.request}
539
+ context={this.props.context}
540
+ showLoading={() => this._showLoading()}
541
+ hideLoading={() => this._hideLoading()}
542
+ fullPosting={this.state.fullPosting}
543
+ maxPictures={this.state.maxPictures} />
544
+ :
545
+ null
546
+ }
547
+
548
+ {this.state.view === Views.PUBLISH_5 ?
549
+ <Publish5 postingAd={this.state.postingAd}
550
+ scroll={(ref) => this.scroll.scrollIntoView(ref)}
551
+ saveEditAd={() => this._saveEditAd()}
552
+ goToPage={(view) => this._goToPage(view)}
553
+ businessId={this.state.businessId}
554
+ request={this.props.request}
555
+ context={this.props.context}
556
+ showLoading={() => this._showLoading()}
557
+ hideLoading={() => this._hideLoading()}
558
+ fullPosting={this.state.fullPosting} />
559
+ :
560
+ null
561
+ }
562
+
563
+ {this.state.view === Views.PUBLISH_6 ?
564
+ <Publish6 postingAd={this.state.postingAd}
565
+ country={this.props.country}
566
+ businessId={this.state.businessId}
567
+ scroll={(ref) => this.scroll.scrollIntoView(ref)}
568
+ saveEditAd={() => this._saveEditAd()}
569
+ goToPage={(view, params) => this._goToPage(view, null, params)}
570
+ request={this.props.request}
571
+ context={this.props.context}
572
+ showLoading={() => this._showLoading()}
573
+ hideLoading={() => this._hideLoading()}
574
+ fullPosting={this.state.fullPosting} />
575
+ :
576
+ null
577
+ }
578
+
579
+ {this.state.view === Views.PREVIEW ?
580
+ <Preview postingAd={this.state.postingAd}
581
+ country={this.props.country}
582
+ goBack={() => this.goBack()}
583
+ showLoading={() => this._showLoading()}
584
+ hideLoading={() => this._hideLoading()}
585
+ businessId={this.state.businessId}
586
+ request={this.props.request}
587
+ highlight={() => this._goToPage(Views.PAYMENT_ONLINE)}
588
+ params={this.state.params} />
589
+ :
590
+ null
591
+ }
592
+
593
+ {this.state.view === Views.EDIT_SELECTOR ?
594
+ <PostingEdit postingAd={this.state.postingAd}
595
+ goToPage={(view) => this._goToPage(view)} />
596
+ :
597
+ null
598
+ }
599
+
600
+ {this.state.view === Views.PAYMENT_ONLINE ?
601
+ <PaymentOnlinePopup
602
+ context={this.props.context}
603
+ request={this.props.request}
604
+ adId={this.state.postingAd.id}
605
+ country={this.props.country}
606
+ goToPrivacy={this.props.goToPrivacy}
607
+ changeView={this.props.changeView}
608
+ showTopBar={() => this.props.showTopBar()}
609
+ hideTopBar={() => this.props.hideTopBar()}
610
+ close={this.goBack}
611
+ goBack={() => this.setState({ view: Views.PREVIEW }, () => this.goBack())} />
612
+ :
613
+ null
614
+ }
615
+
616
+ </CustomScrollView>
617
+ <PopupAdvice icon={<FontAwesomeIcon name='block' />} title={strings('setup.noPromoteTitle', { product: '' })} headerColor={commonStyles.red} ref={popupAdvice => this.popupNoListings = popupAdvice}
618
+ onClose={async () => this.state.view !== Views.PREVIEW ? this.goBack() : null} hideButton={true}>
619
+ <OutputText style={commonStyles.popupText}>{strings('setup.noPromoteSubtitle', { countryPhone: this.state.countryPhone })}</OutputText>
620
+ <TouchableOpacity style={[commonStyles.okBtnBoxPopup, commonStyles.okBtnPopup]} onPress={() => this.popupNoListings.hide()} >
621
+ <OutputText style={commonStyles.okBtnTextPopup}>{strings('setup.adviceOK')}</OutputText>
622
+ </TouchableOpacity>
623
+ </PopupAdvice>
624
+
625
+ <PopupAdvice icon={<FontAwesomeIcon name='block' />} title={strings('setup.noPromotionTitle')} headerColor={commonStyles.red} ref={popupAdvice => this.popupNoPromotions = popupAdvice}
626
+ onClose={() => this.goBack()} hideButton={true}>
627
+ <OutputText style={commonStyles.popupText}>{strings('setup.noPromotionText')}</OutputText>
628
+ <TouchableOpacity style={[commonStyles.okBtnBoxPopup, commonStyles.okBtnPopup]} onPress={() => this.goBack()} >
629
+ <OutputText style={commonStyles.okBtnTextPopup}>{strings('setup.adviceOK')}</OutputText>
630
+ </TouchableOpacity>
631
+ </PopupAdvice>
632
+ </View >
633
+ :
634
+ null
635
+ }
636
+ </View>
642
637
  );
643
638
  }
644
639
  }
package/Preview.js CHANGED
@@ -61,144 +61,142 @@ export default class Preview extends React.Component {
61
61
 
62
62
  render() {
63
63
  return (
64
- <View>
65
- <View style={{ flex: 1 }}>
66
- <View style={commonStyles.formFieldset}>
67
- <View style={commonStyles.confirmNote}>
68
- <View style={commonStyles.row}>
69
- <FontAwesomeIcon style={commonStyles.confirmIcon} name="ok" />
70
- <Text style={commonStyles.confirmNoteText}>{this.props.businessId ? strings('setup.publishOK') : strings('setup.publishWait')}</Text>
71
- </View>
64
+ <View style={commonStyles.flex1}>
65
+ <View style={commonStyles.formFieldset}>
66
+ <View style={commonStyles.confirmNote}>
67
+ <View style={commonStyles.row}>
68
+ <FontAwesomeIcon style={commonStyles.confirmIcon} name="ok" />
69
+ <Text style={commonStyles.confirmNoteText}>{this.props.businessId ? strings('setup.publishOK') : strings('setup.publishWait')}</Text>
70
+ </View>
71
+ </View>
72
+
73
+ {this.state.mainPicture !== null ?
74
+ <View style={commonStyles.progressbarInputArea}>
75
+ <ImageBackground style={[commonStyles.previewBox, commonStyles.photoBoxImage]} source={{ uri: this.state.mainPicture }} resizeMode='cover' borderRadius={10}>
76
+ {this.props.postingAd.reference ?
77
+ <View style={commonStyles.previewReference}>
78
+ <Text style={commonStyles.previewTitleText}>{strings('setup.ref')} {this.props.postingAd.reference}</Text>
79
+ </View>
80
+ :
81
+ <View />
82
+ }
83
+
84
+ <ImageBackground style={[commonStyles.photoControls, commonStyles.previewControls]} source={require('./assets/images/bg-shadow.png')} resizeMode='stretch' borderRadius={1.5}>
85
+ <View style={commonStyles.previewTitle}>
86
+ <Text style={commonStyles.previewTitleText}>{this.props.postingAd.languages[0].title}</Text>
87
+ </View>
88
+ <Text style={[commonStyles.subNote, commonStyles.subNotePreview, commonStyles.previewText]}>{this.props.postingAd.languages[0].description != null && this.props.postingAd.languages[0].description.length > 114 ? this.props.postingAd.languages[0].description.substring(0, 114) + '...' : this.props.postingAd.languages[0].description}</Text>
89
+ </ImageBackground>
90
+ </ImageBackground>
72
91
  </View>
92
+ : null}
73
93
 
74
- {this.state.mainPicture !== null ?
75
- <View style={commonStyles.progressbarInputArea}>
76
- <ImageBackground style={[commonStyles.previewBox, commonStyles.photoBoxImage]} source={{ uri: this.state.mainPicture }} resizeMode='cover' borderRadius={10}>
77
- {this.props.postingAd.reference ?
78
- <View style={commonStyles.previewReference}>
79
- <Text style={commonStyles.previewTitleText}>{strings('setup.ref')} {this.props.postingAd.reference}</Text>
94
+ {this.props.businessId ?
95
+ <View style={commonStyles.promoBox}>
96
+ <View style={commonStyles.row}>
97
+ <View style={this.state.superPremiumActive ? [commonStyles.col, commonStyles.col6, commonStyles.promoColPremium, commonStyles.disabled] : [commonStyles.col, commonStyles.col6, commonStyles.promoColPremium]}>
98
+ <View style={[commonStyles.row, { marginBottom: 5 }]}>
99
+ <View style={[commonStyles.col, commonStyles.col30]}>
100
+ <Image style={commonStyles.imgPremium} source={require('./assets/images/premium.png')} resizeMode='contain' />
101
+ </View>
102
+ <View style={[commonStyles.col, commonStyles.col70]}>
103
+ <Text style={commonStyles.promoSub}>{strings('setup.makeIt')}</Text>
104
+ <Text style={[commonStyles.promoTitle, commonStyles.blueTitle]}>{strings('setup.premium').toUpperCase()}</Text>
105
+ </View>
106
+ </View>
107
+ <Text style={[commonStyles.legalNoteText, commonStyles.promoNote]}>{strings('setup.makePremium')}</Text>
108
+ {this.state.premiumActive ?
109
+ <View style={[commonStyles.row, commonStyles.superBtn, commonStyles.btnBlue2]} >
110
+ <Text style={commonStyles.superBtnText}>{strings('setup.active').toUpperCase()}</Text>
80
111
  </View>
81
112
  :
82
- <View />
113
+ <TouchableOpacity style={[commonStyles.superBtn, commonStyles.btnBlue1]} underlayColor="#104a7a" onPress={() => this.makePremium()} disabled={this.state.superPremiumActive}>
114
+ <Text style={commonStyles.superBtnText}>{strings('setup.useIt').toUpperCase()}</Text>
115
+ </TouchableOpacity>
83
116
  }
117
+ </View>
84
118
 
85
- <ImageBackground style={[commonStyles.photoControls, commonStyles.previewControls]} source={require('./assets/images/bg-shadow.png')} resizeMode='stretch' borderRadius={1.5}>
86
- <View style={commonStyles.previewTitle}>
87
- <Text style={commonStyles.previewTitleText}>{this.props.postingAd.languages[0].title}</Text>
119
+ <View style={this.state.premiumActive ? [commonStyles.col, commonStyles.col6, commonStyles.promoColSuper, commonStyles.disabled] : [commonStyles.col, commonStyles.col6, commonStyles.promoColSuper]}>
120
+ <View style={[commonStyles.row, { marginBottom: 5 }]}>
121
+ <View style={[commonStyles.col, commonStyles.col30]}>
122
+ <Image style={commonStyles.imgPremium} source={require('./assets/images/superpremium.png')} resizeMode='contain' />
88
123
  </View>
89
- <Text style={[commonStyles.subNote, commonStyles.subNotePreview, commonStyles.previewText]}>{this.props.postingAd.languages[0].description != null && this.props.postingAd.languages[0].description.length > 114 ? this.props.postingAd.languages[0].description.substring(0, 114) + '...' : this.props.postingAd.languages[0].description}</Text>
90
- </ImageBackground>
91
- </ImageBackground>
92
- </View>
93
- : null}
94
-
95
- {this.props.businessId ?
96
- <View style={commonStyles.promoBox}>
97
- <View style={commonStyles.row}>
98
- <View style={this.state.superPremiumActive ? [commonStyles.col, commonStyles.col6, commonStyles.promoColPremium, commonStyles.disabled] : [commonStyles.col, commonStyles.col6, commonStyles.promoColPremium]}>
99
- <View style={[commonStyles.row, { marginBottom: 5 }]}>
100
- <View style={[commonStyles.col, commonStyles.col30]}>
101
- <Image style={commonStyles.imgPremium} source={require('./assets/images/premium.png')} resizeMode='contain' />
102
- </View>
103
- <View style={[commonStyles.col, commonStyles.col70]}>
124
+ <View style={[commonStyles.col, commonStyles.col70]}>
125
+ <View style={[commonStyles.row, { justifyContent: 'center' }]}>
104
126
  <Text style={commonStyles.promoSub}>{strings('setup.makeIt')}</Text>
105
- <Text style={[commonStyles.promoTitle, commonStyles.blueTitle]}>{strings('setup.premium').toUpperCase()}</Text>
127
+ <Text style={[commonStyles.promoSubItalic, commonStyles.orangeTitle]}> {strings('setup.super').toUpperCase()}</Text>
106
128
  </View>
129
+ <Text style={[commonStyles.promoTitle, commonStyles.orangeTitle]}>{strings('setup.premium').toUpperCase()}</Text>
107
130
  </View>
108
- <Text style={[commonStyles.legalNoteText, commonStyles.promoNote]}>{strings('setup.makePremium')}</Text>
109
- {this.state.premiumActive ?
110
- <View style={[commonStyles.row, commonStyles.superBtn, commonStyles.btnBlue2]} >
111
- <Text style={commonStyles.superBtnText}>{strings('setup.active').toUpperCase()}</Text>
112
- </View>
113
- :
114
- <TouchableOpacity style={[commonStyles.superBtn, commonStyles.btnBlue1]} underlayColor="#104a7a" onPress={() => this.makePremium()} disabled={this.state.superPremiumActive}>
115
- <Text style={commonStyles.superBtnText}>{strings('setup.useIt').toUpperCase()}</Text>
116
- </TouchableOpacity>
117
- }
118
131
  </View>
119
-
120
- <View style={this.state.premiumActive ? [commonStyles.col, commonStyles.col6, commonStyles.promoColSuper, commonStyles.disabled] : [commonStyles.col, commonStyles.col6, commonStyles.promoColSuper]}>
121
- <View style={[commonStyles.row, { marginBottom: 5 }]}>
122
- <View style={[commonStyles.col, commonStyles.col30]}>
123
- <Image style={commonStyles.imgPremium} source={require('./assets/images/superpremium.png')} resizeMode='contain' />
124
- </View>
125
- <View style={[commonStyles.col, commonStyles.col70]}>
126
- <View style={[commonStyles.row, { justifyContent: 'center' }]}>
127
- <Text style={commonStyles.promoSub}>{strings('setup.makeIt')}</Text>
128
- <Text style={[commonStyles.promoSubItalic, commonStyles.orangeTitle]}> {strings('setup.super').toUpperCase()}</Text>
129
- </View>
130
- <Text style={[commonStyles.promoTitle, commonStyles.orangeTitle]}>{strings('setup.premium').toUpperCase()}</Text>
131
- </View>
132
+ <Text style={[commonStyles.legalNoteText, commonStyles.promoNote]}>{strings('setup.makeSuperpremium')}</Text>
133
+ {this.state.superPremiumActive ?
134
+ <View style={[commonStyles.row, commonStyles.superBtn, commonStyles.btnOrange2]} >
135
+ <Text style={commonStyles.superBtnText}>{strings('setup.active').toUpperCase()}</Text>
132
136
  </View>
133
- <Text style={[commonStyles.legalNoteText, commonStyles.promoNote]}>{strings('setup.makeSuperpremium')}</Text>
134
- {this.state.superPremiumActive ?
135
- <View style={[commonStyles.row, commonStyles.superBtn, commonStyles.btnOrange2]} >
136
- <Text style={commonStyles.superBtnText}>{strings('setup.active').toUpperCase()}</Text>
137
- </View>
138
- :
139
- <TouchableOpacity style={[commonStyles.superBtn, commonStyles.btnOrange1]} underlayColor="#ff5d00" onPress={() => this.makeSuperPremium()} disabled={this.state.premiumActive}>
140
- <Text style={commonStyles.superBtnText}>{strings('setup.useIt').toUpperCase()}</Text>
141
- </TouchableOpacity>
142
- }
143
- </View>
137
+ :
138
+ <TouchableOpacity style={[commonStyles.superBtn, commonStyles.btnOrange1]} underlayColor="#ff5d00" onPress={() => this.makeSuperPremium()} disabled={this.state.premiumActive}>
139
+ <Text style={commonStyles.superBtnText}>{strings('setup.useIt').toUpperCase()}</Text>
140
+ </TouchableOpacity>
141
+ }
144
142
  </View>
145
143
  </View>
146
- :
147
- <View style={commonStyles.infoPreview}>
148
- <View style={commonStyles.row}>
149
- <View style={commonStyles.col7}>
150
- <View style={commonStyles.row}>
151
- <FontAwesomeIcon style={[commonStyles.previewIcon, commonStyles.blue]} name="location" />
152
- <Text style={commonStyles.previewInfoText}>{this.state.location}</Text>
153
- </View>
154
- <View style={commonStyles.row}>
155
- <FontAwesomeIcon style={commonStyles.previewIcon} name="key" />
156
- <Text style={commonStyles.previewInfoText}>{this.state.transaction}</Text>
157
- </View>
158
- <View style={commonStyles.row}>
159
- <FontAwesomeIcon style={commonStyles.previewIcon} name="tags" />
160
- <Text style={commonStyles.previewInfoText}>{this.state.adType}</Text>
161
- </View>
144
+ </View>
145
+ :
146
+ <View style={commonStyles.infoPreview}>
147
+ <View style={commonStyles.row}>
148
+ <View style={commonStyles.col7}>
149
+ <View style={commonStyles.row}>
150
+ <FontAwesomeIcon style={[commonStyles.previewIcon, commonStyles.blue]} name="location" />
151
+ <Text style={commonStyles.previewInfoText}>{this.state.location}</Text>
162
152
  </View>
163
- <View style={commonStyles.col5}>
164
- <View style={commonStyles.row}>
165
- <FontAwesomeIcon style={[commonStyles.previewIcon, commonStyles.blue]} name="money" />
166
-
167
- {this.state.showPrice ?
168
- <View style={commonStyles.row}>
169
- < DisplayPrice style={commonStyles.previewInfoText} value={this.state.price} currency={this.state.currency} country={this.props.country} />
170
- </View>
171
- :
172
- <Text style={commonStyles.previewInfoText}>{strings('setup.contactOwner')}</Text>
173
- }
174
- </View>
175
- {this.state.surface !== undefined ?
153
+ <View style={commonStyles.row}>
154
+ <FontAwesomeIcon style={commonStyles.previewIcon} name="key" />
155
+ <Text style={commonStyles.previewInfoText}>{this.state.transaction}</Text>
156
+ </View>
157
+ <View style={commonStyles.row}>
158
+ <FontAwesomeIcon style={commonStyles.previewIcon} name="tags" />
159
+ <Text style={commonStyles.previewInfoText}>{this.state.adType}</Text>
160
+ </View>
161
+ </View>
162
+ <View style={commonStyles.col5}>
163
+ <View style={commonStyles.row}>
164
+ <FontAwesomeIcon style={[commonStyles.previewIcon, commonStyles.blue]} name="money" />
165
+
166
+ {this.state.showPrice ?
176
167
  <View style={commonStyles.row}>
177
- <FontAwesomeIcon style={commonStyles.previewIcon} name="users" />
178
- <Text style={commonStyles.previewInfoText}>{this.state.surface}</Text>
168
+ < DisplayPrice style={commonStyles.previewInfoText} value={this.state.price} currency={this.state.currency} country={this.props.country} />
179
169
  </View>
180
- : null}
170
+ :
171
+ <Text style={commonStyles.previewInfoText}>{strings('setup.contactOwner')}</Text>
172
+ }
181
173
  </View>
174
+ {this.state.surface !== undefined ?
175
+ <View style={commonStyles.row}>
176
+ <FontAwesomeIcon style={commonStyles.previewIcon} name="users" />
177
+ <Text style={commonStyles.previewInfoText}>{this.state.surface}</Text>
178
+ </View>
179
+ : null}
182
180
  </View>
183
181
  </View>
184
- }
185
- {!this.props.businessId && this.state.showPaymentOnline ?
186
- <View style={commonStyles.previewHighlightContainer}>
187
- <TouchableOpacity style={[commonStyles.previewHighlightButton, commonStyles.alignCenter]} activeOpacity={0.5} onPress={() => this.props.highlight()}>
188
- <Image style={commonStyles.previewHighlightImage} source={require('./assets/images/sparks.png')} />
189
- <Text style={commonStyles.previewHighlightText}>{strings('setup.highlight')}</Text>
190
- </TouchableOpacity>
191
- </View>
192
- :
193
- null
194
- }
195
- </View>
182
+ </View>
183
+ }
184
+ {!this.props.businessId && this.state.showPaymentOnline ?
185
+ <View style={commonStyles.previewHighlightContainer}>
186
+ <TouchableOpacity style={[commonStyles.previewHighlightButton, commonStyles.alignCenter]} activeOpacity={0.5} onPress={() => this.props.highlight()}>
187
+ <Image style={commonStyles.previewHighlightImage} source={require('./assets/images/sparks.png')} />
188
+ <Text style={commonStyles.previewHighlightText}>{strings('setup.highlight')}</Text>
189
+ </TouchableOpacity>
190
+ </View>
191
+ :
192
+ null
193
+ }
194
+ </View>
196
195
 
197
- <View style={commonStyles.previewBackButton}>
198
- <TouchableOpacity activeOpacity={0.5} onPress={() => this.props.goBack()}>
199
- <Text style={commonStyles.carteNote}>{strings('setup.returnHome')}</Text>
200
- </TouchableOpacity>
201
- </View>
196
+ <View style={commonStyles.previewBackButton}>
197
+ <TouchableOpacity activeOpacity={0.5} onPress={() => this.props.goBack()}>
198
+ <Text style={commonStyles.carteNote}>{strings('setup.returnHome')}</Text>
199
+ </TouchableOpacity>
202
200
  </View>
203
201
  <PopupSpendProduct adId={this.props.postingAd.id} ref={(popupShowAdvice) => { this.popupShowAdvice = popupShowAdvice }} businessId={this.props.businessId} request={this.props.request}
204
202
  showLoading={this.props.showLoading} hideLoading={this.props.hideLoading} />
package/Publish1.js CHANGED
@@ -40,7 +40,9 @@ export default class Publish1 extends React.Component {
40
40
  typeBienOptions: { elements: this.getAdTypes(this.props.postingAd.transaction), selectedItem: this.props.postingAd.adType }
41
41
  })
42
42
  }
43
- this.setPromotionData();
43
+ if (this.props.businessId != null) {
44
+ this.setPromotionData();
45
+ }
44
46
  this.props.hideLoading();
45
47
  }
46
48
 
package/Publish2b.js CHANGED
@@ -10,10 +10,6 @@ import { createIconSetFromFontello } from 'react-native-vector-icons';
10
10
  import fontelloConfig from './fonts/config.json';
11
11
  const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
12
12
 
13
- const GET_REGIONS = { method: 'GET', url: '/controller/countries/{countryCode}/regions' };
14
- const GET_CITIES_FROM_REGION = { method: 'GET', url: '/controller/regions/{regionId}/cities' };
15
- const GET_DISTRICTS_FROM_CITY = { method: 'GET', url: '/controller/cities/{cityId}/districts' };
16
- const GET_TOWNS_FROM_DISTRICT = { method: 'GET', url: '/controller/districts/{districtId}/towns' };
17
13
  const GET_CHECK_ZONE = { method: 'GET', url: '/controller/posting/check-zone' };
18
14
 
19
15
  export default class Publish2b extends React.Component {
@@ -21,6 +17,7 @@ export default class Publish2b extends React.Component {
21
17
  super(props);
22
18
 
23
19
  this.state = {
20
+ locationsList: this.props.locationList,
24
21
  regionOptions: {
25
22
  elements: [{ section: true, value: null, label: strings('setup.region') }],
26
23
  selectedItem: this.props.postingAd.region
@@ -46,167 +43,104 @@ export default class Publish2b extends React.Component {
46
43
  }
47
44
 
48
45
  loadData = async () => {
49
- this.props.showLoading();
50
-
51
46
  const region = this.props.postingAd.region;
52
47
  const city = this.props.postingAd.city;
53
48
  const district = this.props.postingAd.district;
54
49
  const town = this.props.postingAd.town;
55
50
 
56
51
  await this.loadRegions();
57
- await this.loadCities(region, false);
58
- await this.loadDistricts(city, false);
59
- await this.loadTowns(district, false);
52
+ await this.loadCities(region);
53
+ await this.loadDistricts(city);
54
+ await this.loadTowns(district);
60
55
 
61
56
  await this.setState({ townOptions: { ...this.state.townOptions, selectedItem: town } })
62
57
  this.props.postingAd.town = town
63
-
64
- this.props.hideLoading();
65
58
  }
66
59
 
67
60
  async loadRegions() {
68
61
  if (this.state.regionOptions.elements.length <= 1) {
69
- const responseJson = await this.props.request(this.props.context, GET_REGIONS, {});
70
-
71
- if (responseJson.httpStatus === 200) {
72
- const regionOptions = {
73
- elements: [this.state.regionOptions.elements[0]],
74
- selectedItem: this.props.postingAd.region
75
- };
76
-
77
- responseJson.list.map((item) => {
78
- regionOptions.elements.push(item);
79
- });
80
-
81
- this.setState({ regionOptions: regionOptions });
62
+ const regionOptions = {
63
+ elements: [this.state.regionOptions.elements[0], ...this.state.locationsList.map(({ subList, ...rest }) => ({ ...rest }))],
64
+ selectedItem: this.props.postingAd.region
82
65
  }
83
- }
84
- }
85
66
 
86
- async loadCities(value, showLoading) {
87
- if (showLoading) {
88
- this.props.showLoading();
67
+ this.setState({ regionOptions: regionOptions });
89
68
  }
69
+ }
90
70
 
71
+ async loadCities(value) {
91
72
  await this.setState({ regionOptions: { ...this.state.regionOptions, selectedItem: value } });
92
73
  this.props.postingAd.region = value;
93
74
 
94
75
  if (value !== null) {
95
- const responseJson = await this.props.request(this.props.context, GET_CITIES_FROM_REGION, {
96
- regionId: this.props.postingAd.region
97
- });
98
-
99
- if (responseJson.httpStatus === 200) {
100
- var cityOptions = {
101
- elements: [this.state.cityOptions.elements[0]],
102
- selectedItem: null
103
- };
104
-
105
- responseJson.list.map((item) => {
106
- cityOptions.elements.push(item);
107
- });
108
-
109
- await this.setState({
110
- cityOptions: cityOptions,
111
- districtOptions: { elements: [this.state.districtOptions.elements[0]], selectedItem: null },
112
- townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null }
113
- });
114
-
115
- this.props.postingAd.city = null;
116
- this.props.postingAd.district = null;
117
- this.props.postingAd.town = null;
76
+ const region = this.state.locationsList.filter(r => r.value === value)[0];
77
+ const cityOptions = {
78
+ elements: [this.state.cityOptions.elements[0], ...region.subList.map(({ subList, ...rest }) => ({ ...rest }))],
79
+ selectedItem: null
118
80
  }
119
- }
120
81
 
121
- if (showLoading) {
122
- this.props.hideLoading();
123
- }
124
- }
82
+ await this.setState({
83
+ cityOptions: cityOptions,
84
+ districtOptions: { elements: [this.state.districtOptions.elements[0]], selectedItem: null },
85
+ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null }
86
+ });
125
87
 
126
- async loadDistricts(value, showLoading) {
127
- if (showLoading) {
128
- this.props.showLoading();
88
+ this.props.postingAd.city = null;
89
+ this.props.postingAd.district = null;
90
+ this.props.postingAd.town = null;
129
91
  }
92
+ }
130
93
 
94
+ async loadDistricts(value) {
131
95
  await this.setState({ cityOptions: { ...this.state.cityOptions, selectedItem: value } });
132
96
  this.props.postingAd.city = value;
133
97
 
134
98
  if (value != null) {
135
- const responseJson = await this.props.request(this.props.context, GET_DISTRICTS_FROM_CITY, {
136
- cityId: this.props.postingAd.city
137
- });
138
-
139
- if (responseJson.httpStatus === 200) {
140
- let districtOptions = {
141
- elements: [this.state.districtOptions.elements[0]],
142
- selectedItem: null
143
- };
144
-
145
- responseJson.list.map((item) => {
146
- districtOptions.elements.push(item);
147
- });
99
+ const city = this.state.locationsList.filter(r => r.value === this.props.postingAd.region)[0].subList.filter(c => c.value === value)[0];
100
+ const districtOptions = {
101
+ elements: [this.state.districtOptions.elements[0], ...city.subList.map(({ subList, ...rest }) => ({ ...rest }))],
102
+ selectedItem: null
103
+ }
148
104
 
149
- if (responseJson.list.length == 1) {
150
- districtOptions.selectedItem = responseJson.list[0].value;
151
- }
105
+ if (city.subList.length == 1) {
106
+ districtOptions.selectedItem = city.subList[0].value;
107
+ }
152
108
 
153
- await this.setState({ districtOptions: districtOptions });
154
- this.props.postingAd.district = null;
155
- this.props.postingAd.town = null;
109
+ await this.setState({ districtOptions: districtOptions });
110
+ this.props.postingAd.district = null;
111
+ this.props.postingAd.town = null;
156
112
 
157
- if (responseJson.list.length == 1) {
158
- this.inputSelectDistrict?.onSubmitValidate();
159
- await this.loadTowns(districtOptions.selectedItem);
160
- } else {
161
- await this.setState({ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null } });
162
- }
113
+ if (city.subList.length == 1) {
114
+ this.inputSelectDistrict?.onSubmitValidate();
115
+ await this.loadTowns(districtOptions.selectedItem);
116
+ } else {
117
+ await this.setState({ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null } });
163
118
  }
164
119
  }
165
-
166
- if (showLoading) {
167
- this.props.hideLoading();
168
- }
169
120
  }
170
121
 
171
- async loadTowns(value, showLoading) {
172
- if (showLoading) {
173
- this.props.showLoading();
174
- }
175
-
122
+ async loadTowns(value) {
176
123
  await this.setState({ districtOptions: { ...this.state.districtOptions, selectedItem: value } })
177
124
  this.props.postingAd.district = value;
178
125
 
179
126
  if (value != null) {
180
- const responseJson = await this.props.request(this.props.context, GET_TOWNS_FROM_DISTRICT, {
181
- districtId: this.props.postingAd.district
182
- });
183
-
184
- if (responseJson.httpStatus === 200) {
185
- var townOptions = {
186
- elements: [this.state.townOptions.elements[0]],
187
- selectedItem: null
188
- };
189
-
190
- responseJson.list.map((item) => {
191
- townOptions.elements.push(item);
192
- });
127
+ const district = this.state.locationsList.filter(r => r.value === this.props.postingAd.region)[0].subList.filter(c => c.value === this.props.postingAd.city)[0].subList.filter(d => d.value === value)[0];
128
+ const townOptions = {
129
+ elements: [this.state.townOptions.elements[0], ...district.subList],
130
+ selectedItem: null
131
+ }
193
132
 
194
- if (responseJson.list.length == 1) {
195
- townOptions.selectedItem = responseJson.list[0].value;
196
- this.props.postingAd.town = townOptions.selectedItem;
197
- }
133
+ if (district.subList.length == 1) {
134
+ townOptions.selectedItem = district.subList[0].value;
135
+ this.props.postingAd.town = townOptions.selectedItem;
136
+ }
198
137
 
199
- await this.setState({ townOptions: townOptions });
138
+ await this.setState({ townOptions: townOptions });
200
139
 
201
- if (responseJson.list.length == 1) {
202
- this.inputSelectTown?.onSubmitValidate();
203
- }
140
+ if (district.subList.length == 1) {
141
+ this.inputSelectTown?.onSubmitValidate();
204
142
  }
205
143
  }
206
-
207
- if (showLoading) {
208
- this.props.hideLoading();
209
- }
210
144
  }
211
145
 
212
146
  async nextStep() {
@@ -216,7 +150,7 @@ export default class Publish2b extends React.Component {
216
150
  cityId: this.props.postingAd.city
217
151
  });
218
152
 
219
- if (responseCheckZone.value === 'true') {
153
+ if (responseCheckZone.value === 'true') {
220
154
  if (this.props.postingAd.id == null || this.props.fullPosting) {
221
155
  this.props.goToPage(Views.PUBLISH_3);
222
156
  } else {
@@ -246,7 +180,7 @@ export default class Publish2b extends React.Component {
246
180
 
247
181
  render() {
248
182
  return (
249
- <View style={{ flex: 1}}>
183
+ <View style={{ flex: 1 }}>
250
184
  <View style={commonStyles.formFieldset}>
251
185
  <View style={commonStyles.progressbarInputArea}>
252
186
  <Text style={commonStyles.progressbarInputAreaH3}>{strings('setup.location')}</Text>
@@ -264,7 +198,7 @@ export default class Publish2b extends React.Component {
264
198
  required={true}
265
199
  scroll={(ref) => this.props.scroll(ref)}
266
200
  options={this.state.regionOptions}
267
- onChange={(value) => this.loadCities(value, true)}
201
+ onChange={(value) => this.loadCities(value)}
268
202
  ref={(element) => this.inputSelectRegion = element}
269
203
  selectStyle={commonStyles.inputSelect} />
270
204
  <InputSelect
@@ -274,7 +208,7 @@ export default class Publish2b extends React.Component {
274
208
  required={true}
275
209
  scroll={(ref) => this.props.scroll(ref)}
276
210
  options={this.state.cityOptions}
277
- onChange={(value) => this.loadDistricts(value, true)}
211
+ onChange={(value) => this.loadDistricts(value)}
278
212
  ref={(element) => this.inputSelecCity = element}
279
213
  disabled={this.state.cityOptions.elements.length === 1}
280
214
  selectStyle={commonStyles.inputSelect} />
@@ -285,7 +219,7 @@ export default class Publish2b extends React.Component {
285
219
  required={true}
286
220
  scroll={(ref) => this.props.scroll(ref)}
287
221
  options={this.state.districtOptions}
288
- onChange={(value) => this.loadTowns(value, true)}
222
+ onChange={(value) => this.loadTowns(value)}
289
223
  ref={(element) => this.inputSelectDistrict = element}
290
224
  disabled={this.state.districtOptions.elements.length === 1}
291
225
  visible={this.state.districtOptions.elements.length !== 2}
@@ -315,7 +249,7 @@ export default class Publish2b extends React.Component {
315
249
  <PopupAdvice dialogStyle={commonStyles.popupBox} ref={(popupNoZone) => { this.popupNoZone = popupNoZone; }}
316
250
  title={strings('setup.ad_cant_post_zone')} icon={<FontAwesomeIcon name='block' />}>
317
251
  <Text style={commonStyles.popupText}></Text>
318
- </PopupAdvice>
252
+ </PopupAdvice>
319
253
  </View>
320
254
  );
321
255
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "6.0.13",
3
+ "version": "6.0.14",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {