muba-posting 4.1.11 → 4.1.12

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 +73 -78
  2. package/package.json +1 -1
package/Publish2b.js CHANGED
@@ -66,26 +66,12 @@ export default class Publish2b extends React.Component {
66
66
  const town = this.props.postingAd.town;
67
67
 
68
68
  await this.loadRegions();
69
+ await this.loadCities(region, false);
70
+ await this.loadDistricts(city, false);
71
+ await this.loadTowns(district, false);
69
72
 
70
- if (region !== null) {
71
- await this.setState({ regionOptions: { ...this.state.regionOptions, selectedItem: region } });
72
- await this.loadCities(region, false);
73
- }
74
-
75
- if (city !== null) {
76
- await this.setState({ cityOptions: { ...this.state.cityOptions, selectedItem: city } })
77
- await this.loadDistricts(city, false);
78
- }
79
-
80
- if (district !== null) {
81
- await this.setState({ districtOptions: { ...this.state.districtOptions, selectedItem: district } })
82
- await this.loadTowns(district, false);
83
- }
84
-
85
- if (town !== null) {
86
- await this.setState({ townOptions: { ...this.state.townOptions, selectedItem: town } })
87
- this.props.postingAd.town = town
88
- }
73
+ await this.setState({ townOptions: { ...this.state.townOptions, selectedItem: town } })
74
+ this.props.postingAd.town = town
89
75
 
90
76
  this.props.hideLoading();
91
77
  }
@@ -114,31 +100,34 @@ export default class Publish2b extends React.Component {
114
100
  this.props.showLoading();
115
101
  }
116
102
 
103
+ await this.setState({ regionOptions: { ...this.state.regionOptions, selectedItem: value } });
117
104
  this.props.postingAd.region = value;
118
105
 
119
- const responseJson = await this.props.request(this.props.context, GET_CITIES_FROM_REGION, {
120
- regionId: this.props.postingAd.region
121
- });
106
+ if (value !== null) {
107
+ const responseJson = await this.props.request(this.props.context, GET_CITIES_FROM_REGION, {
108
+ regionId: this.props.postingAd.region
109
+ });
122
110
 
123
- if (responseJson.httpStatus === 200) {
124
- var cityOptions = {
125
- elements: [this.state.cityOptions.elements[0]],
126
- selectedItem: null
127
- };
111
+ if (responseJson.httpStatus === 200) {
112
+ var cityOptions = {
113
+ elements: [this.state.cityOptions.elements[0]],
114
+ selectedItem: null
115
+ };
128
116
 
129
- responseJson.list.map((item) => {
130
- cityOptions.elements.push(item);
131
- });
117
+ responseJson.list.map((item) => {
118
+ cityOptions.elements.push(item);
119
+ });
132
120
 
133
- await this.setState({
134
- cityOptions: cityOptions,
135
- districtOptions: { elements: [this.state.districtOptions.elements[0]], selectedItem: null },
136
- townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null }
137
- });
121
+ await this.setState({
122
+ cityOptions: cityOptions,
123
+ districtOptions: { elements: [this.state.districtOptions.elements[0]], selectedItem: null },
124
+ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null }
125
+ });
138
126
 
139
- this.props.postingAd.city = null;
140
- this.props.postingAd.district = null;
141
- this.props.postingAd.town = null;
127
+ this.props.postingAd.city = null;
128
+ this.props.postingAd.district = null;
129
+ this.props.postingAd.town = null;
130
+ }
142
131
  }
143
132
 
144
133
  if (showLoading) {
@@ -151,35 +140,38 @@ export default class Publish2b extends React.Component {
151
140
  this.props.showLoading();
152
141
  }
153
142
 
143
+ await this.setState({ cityOptions: { ...this.state.cityOptions, selectedItem: value } });
154
144
  this.props.postingAd.city = value;
155
145
 
156
- const responseJson = await this.props.request(this.props.context, GET_DISTRICTS_FROM_CITY, {
157
- cityId: this.props.postingAd.city
158
- });
146
+ if (value != null) {
147
+ const responseJson = await this.props.request(this.props.context, GET_DISTRICTS_FROM_CITY, {
148
+ cityId: this.props.postingAd.city
149
+ });
159
150
 
160
- if (responseJson.httpStatus === 200) {
161
- let districtOptions = {
162
- elements: [this.state.districtOptions.elements[0]],
163
- selectedItem: null
164
- };
151
+ if (responseJson.httpStatus === 200) {
152
+ let districtOptions = {
153
+ elements: [this.state.districtOptions.elements[0]],
154
+ selectedItem: null
155
+ };
165
156
 
166
- responseJson.list.map((item) => {
167
- districtOptions.elements.push(item);
168
- });
157
+ responseJson.list.map((item) => {
158
+ districtOptions.elements.push(item);
159
+ });
169
160
 
170
- if (responseJson.list.length == 1) {
171
- districtOptions.selectedItem = responseJson.list[0].value;
172
- }
161
+ if (responseJson.list.length == 1) {
162
+ districtOptions.selectedItem = responseJson.list[0].value;
163
+ }
173
164
 
174
- await this.setState({ districtOptions: districtOptions });
175
- this.props.postingAd.district = null;
176
- this.props.postingAd.town = null;
165
+ await this.setState({ districtOptions: districtOptions });
166
+ this.props.postingAd.district = null;
167
+ this.props.postingAd.town = null;
177
168
 
178
- if (responseJson.list.length == 1) {
179
- this.inputSelectDistrict?.onSubmitValidate();
180
- await this.loadTowns(districtOptions.selectedItem);
181
- } else {
182
- await this.setState({ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null } });
169
+ if (responseJson.list.length == 1) {
170
+ this.inputSelectDistrict?.onSubmitValidate();
171
+ await this.loadTowns(districtOptions.selectedItem);
172
+ } else {
173
+ await this.setState({ townOptions: { elements: [this.state.townOptions.elements[0]], selectedItem: null } });
174
+ }
183
175
  }
184
176
  }
185
177
 
@@ -193,31 +185,34 @@ export default class Publish2b extends React.Component {
193
185
  this.props.showLoading();
194
186
  }
195
187
 
188
+ await this.setState({ districtOptions: { ...this.state.districtOptions, selectedItem: value } })
196
189
  this.props.postingAd.district = value;
197
190
 
198
- const responseJson = await this.props.request(this.props.context, GET_TOWNS_FROM_DISTRICT, {
199
- districtId: this.props.postingAd.district
200
- });
191
+ if (value != null) {
192
+ const responseJson = await this.props.request(this.props.context, GET_TOWNS_FROM_DISTRICT, {
193
+ districtId: this.props.postingAd.district
194
+ });
201
195
 
202
- if (responseJson.httpStatus === 200) {
203
- var townOptions = {
204
- elements: [this.state.townOptions.elements[0]],
205
- selectedItem: null
206
- };
196
+ if (responseJson.httpStatus === 200) {
197
+ var townOptions = {
198
+ elements: [this.state.townOptions.elements[0]],
199
+ selectedItem: null
200
+ };
207
201
 
208
- responseJson.list.map((item) => {
209
- townOptions.elements.push(item);
210
- });
202
+ responseJson.list.map((item) => {
203
+ townOptions.elements.push(item);
204
+ });
211
205
 
212
- if (responseJson.list.length == 1) {
213
- townOptions.selectedItem = responseJson.list[0].value;
214
- this.props.postingAd.town = townOptions.selectedItem;
215
- }
206
+ if (responseJson.list.length == 1) {
207
+ townOptions.selectedItem = responseJson.list[0].value;
208
+ this.props.postingAd.town = townOptions.selectedItem;
209
+ }
216
210
 
217
- await this.setState({ townOptions: townOptions });
211
+ await this.setState({ townOptions: townOptions });
218
212
 
219
- if (responseJson.list.length == 1) {
220
- this.inputSelectTown?.onSubmitValidate();
213
+ if (responseJson.list.length == 1) {
214
+ this.inputSelectTown?.onSubmitValidate();
215
+ }
221
216
  }
222
217
  }
223
218
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "4.1.11",
3
+ "version": "4.1.12",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {