muba-posting 4.2.2 → 4.2.4

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 (3) hide show
  1. package/Posting.js +16 -9
  2. package/Publish4.js +15 -11
  3. package/package.json +16 -16
package/Posting.js CHANGED
@@ -35,6 +35,7 @@ const BUSINESS_PRODUCTS = { method: 'GET', url: '/controller/products/{key}/rema
35
35
  const MAX_PICTURES = { method: 'GET', url: '/controller/posting/max-pictures' };
36
36
  const COUNTRY_PHONE = { method: 'GET', url: '/controller/countries/{countryCode}/phones' };
37
37
  const LOAD_PENDING_CREATED = { method: 'GET', url: '/controller/ads/pending-created/posting' };
38
+ const PAYMENT_ONLINE_ACTIVE = { method: 'GET', url: '/controller/payments-online/{countryCode}/active' };
38
39
 
39
40
  export default class Posting extends React.Component {
40
41
  constructor(props) {
@@ -65,7 +66,6 @@ export default class Posting extends React.Component {
65
66
  countryPhone: '',
66
67
  businessId: this.props.businessId,
67
68
  picturesUploaded: 0,
68
- images: [],
69
69
  params: null,
70
70
  postingAd: {
71
71
  transaction: null,
@@ -400,6 +400,11 @@ export default class Posting extends React.Component {
400
400
  } else {
401
401
  await this.setState({ postingAd: { ...this.state.postingAd, adId: response.id } });
402
402
  this._goToPage(Views.PREVIEW, null, response);
403
+
404
+ const paymentOnlineActive = await this.props.request(this, PAYMENT_ONLINE_ACTIVE, { regionId: this.state.postingAd.region });
405
+ if (!this.businessId && paymentOnlineActive.value === 'true') {
406
+ this._goToPage(Views.PAYMENT_ONLINE);
407
+ }
403
408
  }
404
409
  this._hideLoading();
405
410
 
@@ -427,8 +432,11 @@ export default class Posting extends React.Component {
427
432
 
428
433
  imageBrowserCallback = async (photos) => {
429
434
  this.setState({
430
- showImageBrowser: false,
431
- images: photos
435
+ showImageBrowser: false
436
+ }, () => {
437
+ for (let photo of photos) {
438
+ this.publish4?.loadUri(photo)
439
+ }
432
440
  });
433
441
  }
434
442
 
@@ -442,9 +450,8 @@ export default class Posting extends React.Component {
442
450
 
443
451
  _savePicture = async (picture) => {
444
452
  this.setState({
445
- showImageBrowser: false,
446
- images: [picture]
447
- });
453
+ showImageBrowser: false
454
+ }, () => this.publish4?.loadUri(picture));
448
455
  }
449
456
 
450
457
  render() {
@@ -552,6 +559,7 @@ export default class Posting extends React.Component {
552
559
 
553
560
  {this.state.view === Views.PUBLISH_4 ?
554
561
  <Publish4 postingAd={this.state.postingAd}
562
+ ref={publish4 => this.publish4 = publish4}
555
563
  saveEditAd={() => this._saveEditAd()}
556
564
  goToPage={(view) => this._goToPage(view)}
557
565
  request={this.props.request}
@@ -562,8 +570,7 @@ export default class Posting extends React.Component {
562
570
  progressBarHeight={this.state.progressBarHeight}
563
571
  headerHeight={this.state.headerHeight}
564
572
  openPictureSelector={() => this._openPictureSelector()}
565
- maxPictures={this.state.maxPictures}
566
- images={this.state.images} />
573
+ maxPictures={this.state.maxPictures} />
567
574
  :
568
575
  null
569
576
  }
@@ -642,7 +649,7 @@ export default class Posting extends React.Component {
642
649
  }
643
650
 
644
651
  </CustomScrollView>
645
- <PopupAdvice icon={<FontAwesomeIcon name='block' />} title={strings('setup.noPromoteTitle', { product: '' })} headerColor={commonStyles.red} ref={(popupAdvice) => { this.popupNoListings = popupAdvice; }}
652
+ <PopupAdvice icon={<FontAwesomeIcon name='block' />} title={strings('setup.noPromoteTitle', { product: '' })} headerColor={commonStyles.red} ref={popupAdvice => this.popupNoListings = popupAdvice}
646
653
  onClose={async () => this.state.view !== Views.PREVIEW ? this.goBack() : null} hideButton={true}>
647
654
  <OutputText style={commonStyles.popupText}>{strings('setup.noPromoteSubtitle', { countryPhone: this.state.countryPhone })}</OutputText>
648
655
  <TouchableOpacity style={[commonStyles.okBtnBoxPopup, commonStyles.okBtnPopup]} onPress={() => this.popupNoListings.hide()} >
package/Publish4.js CHANGED
@@ -25,7 +25,7 @@ export default class Publish4 extends React.Component {
25
25
  }
26
26
 
27
27
  componentDidMount() {
28
- for (let photo of this.props.images) {
28
+ for (let photo of this.props.postingAd.images) {
29
29
  this.loadImage(photo);
30
30
  }
31
31
 
@@ -37,9 +37,9 @@ export default class Publish4 extends React.Component {
37
37
  }
38
38
 
39
39
  componentDidUpdate = async (prevProps) => {
40
- if (!this.isSameList(prevProps.images, this.props.images)) {
40
+ if (!this.isSameList(prevProps.postingAd.images, this.props.postingAd.images)) {
41
41
  this.setState({ images: [] }, () => {
42
- for (let photo of this.props.images) {
42
+ for (let photo of this.props.postingAd.images) {
43
43
  this.loadImage(photo);
44
44
  }
45
45
  });
@@ -58,7 +58,7 @@ export default class Publish4 extends React.Component {
58
58
  return true;
59
59
  }
60
60
 
61
- async loadImage(imgUri) {
61
+ async loadUri(imgUri) {
62
62
  if (imgUri) {
63
63
  let fileType = imgUri.substring(imgUri.lastIndexOf('.') + 1).toLowerCase();
64
64
 
@@ -72,20 +72,24 @@ export default class Publish4 extends React.Component {
72
72
  extraInfo: this.state.images.length
73
73
  }
74
74
 
75
- let imagesArray = this.state.images;
76
- imagesArray.push(image);
75
+ this.loadImage(image);
76
+ }
77
+ }
77
78
 
78
- await this.setState({
79
- showErrorNoSelectedImages: false,
80
- images: imagesArray
81
- });
79
+ loadImage(image) {
80
+ let imagesArray = this.state.images;
81
+ imagesArray.push(image);
82
82
 
83
+ this.setState({
84
+ showErrorNoSelectedImages: false,
85
+ images: imagesArray
86
+ }, () => {
83
87
  if (this.state.images.length == this.props.maxPictures) {
84
88
  this.setState({ allPhotosSelected: true });
85
89
  } else if (this.state.images.length == 1) {
86
90
  this.selectMainPhoto(this.state.images[0]);
87
91
  }
88
- }
92
+ });
89
93
  }
90
94
 
91
95
  async deleteImage(itemId, index) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {
@@ -18,20 +18,20 @@
18
18
  "homepage": "https://github.com/Mubawab/muba-posting#readme",
19
19
  "dependencies": {
20
20
  "@react-native-async-storage/async-storage": "~1.17.3",
21
- "muba-custom-scroll-view": "4",
22
- "muba-display-price": "4",
23
- "muba-font": "4",
24
- "muba-i18n": "4",
25
- "muba-input-select": "4",
26
- "muba-input-text": "4",
27
- "muba-loading-cursor": "4",
28
- "muba-map": "4",
29
- "muba-output-text": "4",
30
- "muba-phone-group": "4",
31
- "muba-picture": "4",
32
- "muba-payment-online": "4",
33
- "muba-popup-advice": "4",
34
- "muba-popup-permissions": "4",
35
- "muba-radio-button-group": "4"
21
+ "muba-custom-scroll-view": "5",
22
+ "muba-display-price": "5",
23
+ "muba-font": "5",
24
+ "muba-i18n": "5",
25
+ "muba-input-select": "5",
26
+ "muba-input-text": "5",
27
+ "muba-loading-cursor": "5",
28
+ "muba-map": "5",
29
+ "muba-output-text": "5",
30
+ "muba-phone-group": "5",
31
+ "muba-picture": "5",
32
+ "muba-payment-online": "5",
33
+ "muba-popup-advice": "5",
34
+ "muba-popup-permissions": "5",
35
+ "muba-radio-button-group": "5"
36
36
  }
37
37
  }