muba-posting 8.0.16 → 8.0.17

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.
Files changed (2) hide show
  1. package/Posting.js +57 -40
  2. package/package.json +1 -1
package/Posting.js CHANGED
@@ -230,11 +230,13 @@ export default class Posting extends React.Component {
230
230
  this.popupNoListings.show();
231
231
  } else {
232
232
  const pendingAd = await this.props.request(this.props.context, LOAD_PENDING_CREATED, { businessId: this.state.businessId });
233
+
233
234
  if (pendingAd.httpStatus === 200) {
234
235
  delete pendingAd.phones;
235
236
  const languages = pendingAd?.languages.length > 0 ? pendingAd?.languages : this.state.postingAd.languages
236
237
  const languageId = languages[0].language;
237
- await this.setState({
238
+
239
+ this.setState({
238
240
  postingAd: { ...this.state.postingAd, ...pendingAd, languageId: languageId, languages: languages },
239
241
  originalAd: { ...this.state.postingAd, ...pendingAd, languageId: languageId, languages: languages }
240
242
  });
@@ -327,7 +329,7 @@ export default class Posting extends React.Component {
327
329
  if (bddAd.status === 'PENDING_CREATED') {
328
330
  const languages = bddAd?.languages.length > 0 ? bddAd?.languages : this.state.postingAd.languages
329
331
  const languageId = languages[0].language;
330
- await this.setState({
332
+ this.setState({
331
333
  postingAd: { ...this.state.postingAd, ...bddAd, languageId: languageId, languages: languages },
332
334
  originalAd: { ...this.state.postingAd, ...bddAd, languageId: languageId, languages: languages },
333
335
  adId: null,
@@ -335,7 +337,7 @@ export default class Posting extends React.Component {
335
337
  fullPosting: true
336
338
  })
337
339
  } else {
338
- await this.setState({
340
+ this.setState({
339
341
  postingAd: { ...this.state.postingAd, ...bddAd },
340
342
  originalAd: { ...this.state.postingAd, ...bddAd }
341
343
  });
@@ -369,57 +371,71 @@ export default class Posting extends React.Component {
369
371
  }
370
372
  }
371
373
 
372
- this.setState({ prevViews: prevViews, editingStepOne: editingStepOne });
373
- await this._updateCurrentScreen(view, params);
374
+ this.setState({ prevViews: prevViews, editingStepOne: editingStepOne }, () => {
375
+ this._updateCurrentScreen(view, params);
376
+ });
374
377
  }
375
378
 
376
- async _updateCurrentScreen(view, params) {
379
+ _updateCurrentScreen(view, params) {
380
+ let currentScreen = this.state.currentScreen;
381
+ let prevViews = this.state.prevViews;
382
+ let onlyShowCreateBusiness = this.state.onlyShowCreateBusiness;
383
+ let newParams = this.state.params;
384
+
377
385
  switch (view) {
378
386
  case Views.PUBLISH_1:
379
- this.setState({ currentScreen: 1 });
387
+ currentScreen = 1;
380
388
  break;
381
389
  case Views.PUBLISH_2:
382
390
  if (this.state.locationList.length === 0) {
383
391
  this.loadLocations();
384
392
  }
385
- this.setState({ currentScreen: 2 });
393
+ currentScreen = 2;
386
394
  break;
387
395
  case Views.PUBLISH_2_B:
388
- this.setState({ currentScreen: 2 });
396
+ currentScreen = 2;
389
397
  break;
390
398
  case Views.PUBLISH_3:
391
- this.setState({ currentScreen: 3 });
399
+ currentScreen = 3;
392
400
  break;
393
401
  case Views.PUBLISH_4:
394
- this.setState({ currentScreen: 4 });
402
+ currentScreen = 4;
395
403
  break;
396
404
  case Views.PUBLISH_5:
397
- this.setState({ currentScreen: 5 });
405
+ currentScreen = 5;
398
406
  break;
399
407
  case Views.PUBLISH_6:
400
- this.setState({ currentScreen: 6 });
408
+ currentScreen = 6;
401
409
  break;
402
410
  case Views.PREVIEW:
403
411
  if (params) {
404
- this.setState({ params: params });
412
+ newParams = params;
405
413
  }
406
- this.setState({ prevViews: [] })
414
+ prevViews = [];
407
415
  break;
408
416
  case Views.EDIT_SELECTOR:
409
- this.setState({ prevViews: [] })
417
+ prevViews = [];
410
418
  break;
411
419
  case Views.PAYMENT_ONLINE:
412
420
  if (params) {
413
- this.setState({ onlyShowCreateBusiness: params.onlyShowCreateBusiness});
421
+ onlyShowCreateBusiness = params.onlyShowCreateBusiness;
414
422
  } else {
415
- this.setState({ onlyShowCreateBusiness: false});
423
+ onlyShowCreateBusiness = false;
416
424
  }
417
425
  }
418
- this.scroll.scrollTop();
419
- this.setState({ view: view });
420
- if (this.props.changeView && Views.PAYMENT_ONLINE !== view) {
421
- this.props.changeView(view);
422
- }
426
+
427
+ this.setState({
428
+ view: view,
429
+ prevViews: prevViews,
430
+ currentScreen: currentScreen,
431
+ onlyShowCreateBusiness: onlyShowCreateBusiness,
432
+ params: newParams
433
+ }, () => {
434
+ this.scroll.scrollTop();
435
+ if (this.props.changeView && Views.PAYMENT_ONLINE !== view) {
436
+ this.props.changeView(view);
437
+ }
438
+ });
423
439
  }
424
440
 
425
441
  goBack = async () => {
@@ -446,12 +462,13 @@ export default class Posting extends React.Component {
446
462
  originalAd = { ...this.state.originalAd };
447
463
  }
448
464
 
449
- await this.setState({
465
+ this.setState({
450
466
  prevViews: prevViews,
451
467
  postingAd: { ...originalAd },
452
468
  originalAd: { ...originalAd }
469
+ }, () => {
470
+ this._updateCurrentScreen(view);
453
471
  });
454
- this._updateCurrentScreen(view);
455
472
  }
456
473
  }
457
474
  }
@@ -479,24 +496,24 @@ export default class Posting extends React.Component {
479
496
  this.props.navigation.goBack();
480
497
  }
481
498
  } else {
482
- await this.setState({
499
+ this.setState({
483
500
  postingAd: { ...this.state.postingAd, adId: response.id },
484
501
  originalAd: { ...this.state.postingAd, adId: response.id }
485
- });
486
-
487
- this._goToPage(Views.PREVIEW, null, response);
488
- if (!showRating && this.props.showRatingPopup) {
489
- const popupShowed = await this.props.showRatingPopup();
490
- this.setState({
491
- showRatePopup: popupShowed
492
- });
493
-
494
- if (!popupShowed) {
495
- this.checkPaymentOnline();
502
+ }, async () => {
503
+ this._goToPage(Views.PREVIEW, null, response);
504
+ if (!showRating && this.props.showRatingPopup) {
505
+ const popupShowed = await this.props.showRatingPopup();
506
+ this.setState({
507
+ showRatePopup: popupShowed
508
+ });
509
+
510
+ if (!popupShowed) {
511
+ this.checkPaymentOnline();
512
+ }
496
513
  }
497
- }
498
-
499
- showRating = true;
514
+
515
+ showRating = true;
516
+ });
500
517
  }
501
518
  this._hideLoading();
502
519
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "8.0.16",
3
+ "version": "8.0.17",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {