muba-posting 9.0.3 → 9.0.5

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/Publish2b.js +62 -37
  2. package/package.json +1 -1
package/Publish2b.js CHANGED
@@ -53,21 +53,44 @@ export default class Publish2b extends React.Component {
53
53
  }
54
54
 
55
55
  loadData = async () => {
56
- const region = this.props.postingAd.region;
57
- const city = this.props.postingAd.city;
58
- const district = this.props.postingAd.district;
59
- const town = this.props.postingAd.town;
60
-
61
- await this.loadRegions();
62
- await this.loadCities(region);
63
- await this.loadDistricts(city);
64
- await this.loadTowns(district);
65
-
66
- await this.setState({ townOptions: { ...this.state.townOptions, selectedItem: town } })
67
- this.props.postingAd.town = town
56
+ const { region, city, district, town } = this.props.postingAd;
57
+
58
+ this.setState({
59
+ regionOptions: {
60
+ elements: [this.state.regionOptions.elements[0], ...this.state.locationsList.map(({ subList, ...rest }) => ({ ...rest }))],
61
+ selectedItem: region
62
+ }
63
+ });
64
+
65
+ if (region != null) {
66
+ this.setState({
67
+ cityOptions: {
68
+ elements: [this.state.cityOptions.elements[0], ...this.state.locationsList.filter(r => r.value === region)[0].subList.map(({ subList, ...rest }) => ({ ...rest }))],
69
+ selectedItem: city
70
+ }
71
+ });
72
+ }
73
+
74
+ if (city != null) {
75
+ this.setState({
76
+ districtOptions: {
77
+ elements: [this.state.districtOptions.elements[0], ...this.state.locationsList.filter(r => r.value === region)[0].subList.filter(c => c.value === city)[0].subList.map(({ subList, ...rest }) => ({ ...rest }))],
78
+ selectedItem: district
79
+ }
80
+ });
81
+ }
82
+
83
+ if (district != null) {
84
+ this.setState({
85
+ townOptions: {
86
+ elements: [this.state.townOptions.elements[0], ...this.state.locationsList.filter(r => r.value === region)[0].subList.filter(c => c.value === city)[0].subList.filter(d => d.value === district)[0].subList],
87
+ selectedItem: town
88
+ }
89
+ });
90
+ }
68
91
  }
69
92
 
70
- async loadRegions() {
93
+ loadRegions() {
71
94
  if (this.state.regionOptions.elements.length <= 1) {
72
95
  const regionOptions = {
73
96
  elements: [this.state.regionOptions.elements[0], ...this.state.locationsList.map(({ subList, ...rest }) => ({ ...rest }))],
@@ -78,8 +101,8 @@ export default class Publish2b extends React.Component {
78
101
  }
79
102
  }
80
103
 
81
- async loadCities(value) {
82
- await this.setState({ regionOptions: { ...this.state.regionOptions, selectedItem: value } });
104
+ loadCities(value) {
105
+ this.setState({ regionOptions: { ...this.state.regionOptions, selectedItem: value } });
83
106
  this.props.postingAd.region = value;
84
107
 
85
108
  if (value != null) {
@@ -89,7 +112,7 @@ export default class Publish2b extends React.Component {
89
112
  selectedItem: null
90
113
  }
91
114
 
92
- await this.setState({
115
+ this.setState({
93
116
  cityOptions: cityOptions,
94
117
  districtOptions: { elements: [this.state.districtOptions.elements[0]], selectedItem: null },
95
118
  townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null }
@@ -101,8 +124,8 @@ export default class Publish2b extends React.Component {
101
124
  }
102
125
  }
103
126
 
104
- async loadDistricts(value) {
105
- await this.setState({ cityOptions: { ...this.state.cityOptions, selectedItem: value } });
127
+ loadDistricts(value) {
128
+ this.setState({ cityOptions: { ...this.state.cityOptions, selectedItem: value } });
106
129
  this.props.postingAd.city = value;
107
130
 
108
131
  if (value != null) {
@@ -116,21 +139,22 @@ export default class Publish2b extends React.Component {
116
139
  districtOptions.selectedItem = city.subList[0].value;
117
140
  }
118
141
 
119
- await this.setState({ districtOptions: districtOptions });
120
- this.props.postingAd.district = null;
121
- this.props.postingAd.town = null;
142
+ this.setState({ districtOptions: districtOptions }, async () => {
143
+ this.props.postingAd.district = null;
144
+ this.props.postingAd.town = null;
122
145
 
123
- if (city.subList.length == 1) {
124
- this.inputSelectDistrict?.onSubmitValidate();
125
- await this.loadTowns(districtOptions.selectedItem);
126
- } else {
127
- await this.setState({ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null } });
128
- }
146
+ if (city.subList.length == 1) {
147
+ this.inputSelectDistrict?.onSubmitValidate();
148
+ this.loadTowns(districtOptions.selectedItem);
149
+ } else {
150
+ this.setState({ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null } });
151
+ }
152
+ });
129
153
  }
130
154
  }
131
155
 
132
- async loadTowns(value) {
133
- await this.setState({ districtOptions: { ...this.state.districtOptions, selectedItem: value } })
156
+ loadTowns(value) {
157
+ this.setState({ districtOptions: { ...this.state.districtOptions, selectedItem: value } })
134
158
  this.props.postingAd.district = value;
135
159
 
136
160
  if (value != null) {
@@ -145,11 +169,11 @@ export default class Publish2b extends React.Component {
145
169
  this.props.postingAd.town = townOptions.selectedItem;
146
170
  }
147
171
 
148
- await this.setState({ townOptions: townOptions });
149
-
150
- if (district.subList.length == 1) {
151
- this.inputSelectTown?.onSubmitValidate();
152
- }
172
+ this.setState({ townOptions: townOptions }, () => {
173
+ if (district.subList.length == 1) {
174
+ this.inputSelectTown?.onSubmitValidate();
175
+ }
176
+ });
153
177
  }
154
178
  }
155
179
 
@@ -173,10 +197,10 @@ export default class Publish2b extends React.Component {
173
197
  errorCity: !responseCheckZone.correctCity
174
198
  })
175
199
 
176
- if (!responseCheckZone.correctCity){
200
+ if (!responseCheckZone.correctCity) {
177
201
  this.popupNoZone.show();
178
202
  } else {
179
- this.props.goToPage(Views.PAYMENT_ONLINE, false, {onlyShowCreateBusiness: true});
203
+ this.props.goToPage(Views.PAYMENT_ONLINE, false, { onlyShowCreateBusiness: true });
180
204
  }
181
205
  }
182
206
  }
@@ -219,7 +243,8 @@ export default class Publish2b extends React.Component {
219
243
  <InputText value={this.state.address}
220
244
  label={strings('setup.adress')}
221
245
  labelStyle={commonStyles.progressbarField}
222
- required={false}
246
+ required={true}
247
+ scroll={(ref) => this.props.scroll(ref)}
223
248
  onChangeText={(text) => this.onChangeAddress(text)}
224
249
  textContainerStyle={commonStyles.inputContainer}
225
250
  disabled={!this.props.allowedToModify.address || this.props.postingAd.promotionId != null}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "9.0.3",
3
+ "version": "9.0.5",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {