muba-posting 5.0.9 → 5.0.11

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/Publish1.js CHANGED
@@ -3,9 +3,12 @@ import { Text, View, TouchableHighlight, Dimensions } from 'react-native';
3
3
  import { strings } from 'muba-i18n';
4
4
  import commonStyles from './commonStyles';
5
5
  import RadioButtonGroup from 'muba-radio-button-group';
6
+ import InputSelect from 'muba-input-select';
6
7
  import { Views } from './utils/Views';
7
8
  const window = Dimensions.get('window');
8
9
 
10
+ const GET_PROMOTIONS = { method: 'GET', url: '/controller/posting/promotions' };
11
+ const PROMOTION_LOCATION = { method: 'GET', url: '/controller/promotions/{promotionId}/location' };
9
12
  const GET_TRANSACTIONS = { method: 'GET', url: '/controller/transactions' };
10
13
 
11
14
  export default class Publish1 extends React.Component {
@@ -18,6 +21,10 @@ export default class Publish1 extends React.Component {
18
21
  this.state = {
19
22
  isLoading: false,
20
23
  showTypeBienError: false,
24
+ promotionOptions: {
25
+ elements: [{ section: true, value: null, label: strings('setup.selectPromotion') }],
26
+ selectedItem: this.props.postingAd.promotionId
27
+ },
21
28
  transactionOptions: { elements: [], selectedItem: this.props.postingAd.transaction },
22
29
  typeBienOptions: { elements: [], selectedItem: this.props.postingAd.adType }
23
30
  };
@@ -47,6 +54,24 @@ export default class Publish1 extends React.Component {
47
54
  if (this.state.minHeight != minHeight) {
48
55
  this.setState({ minHeight: minHeight })
49
56
  }
57
+
58
+ this.loadPromotions();
59
+ }
60
+
61
+ async loadPromotions() {
62
+ const responseJson = await this.props.request(this.props.context, GET_PROMOTIONS);
63
+ if (responseJson.httpStatus === 200) {
64
+ const promotionOptions = {
65
+ elements: [this.state.promotionOptions.elements[0]],
66
+ selectedItem: this.props.postingAd.promotionId
67
+ };
68
+
69
+ responseJson.list.map((item) => {
70
+ promotionOptions.elements.push(item);
71
+ });
72
+
73
+ this.setState({ promotionOptions: promotionOptions });
74
+ }
50
75
  }
51
76
 
52
77
  getAdTypes(transaction) {
@@ -88,6 +113,23 @@ export default class Publish1 extends React.Component {
88
113
  this.props.postingAd.adType = value;
89
114
  }
90
115
 
116
+ async changePromotion(value) {
117
+ const responseJson = await this.props.request(this.props.context, PROMOTION_LOCATION, {
118
+ promotionId: value
119
+ });
120
+ if (responseJson.httpStatus === 200) {
121
+ this.props.postingAd.latitude = responseJson.latitude;
122
+ this.props.postingAd.longitude = responseJson.longitude;
123
+ this.props.postingAd.region = responseJson.regionId;
124
+ this.props.postingAd.province = responseJson.provinceId;
125
+ this.props.postingAd.city = responseJson.cityId;
126
+ this.props.postingAd.district = responseJson.districtId;
127
+ this.props.postingAd.town = responseJson.townId;
128
+ this.props.postingAd.exactlyLocated = true;
129
+ }
130
+ this.props.postingAd.promotionId = value;
131
+ }
132
+
91
133
  async nextStep() {
92
134
  if (this.validateForm()) {
93
135
  for (var i = 0; i < this.state.typeBienOptions.elements.length; i++) {
@@ -99,8 +141,10 @@ export default class Publish1 extends React.Component {
99
141
 
100
142
  if (this.props.postingAd.id == null || this.props.fullPosting) {
101
143
  if (this.props.postingAd.exactlyLocated) {
144
+ console.log('2')
102
145
  this.props.goToPage(Views.PUBLISH_2);
103
146
  } else {
147
+ console.log('2-b')
104
148
  this.props.goToPage(Views.PUBLISH_2_B);
105
149
  }
106
150
  } else {
@@ -114,7 +158,11 @@ export default class Publish1 extends React.Component {
114
158
  }
115
159
 
116
160
  validateForm() {
117
- return this.radioButtonAdType.onSubmitValidate();
161
+ let validPromotions = this.state.promotionOptions.elements.length <= 1;
162
+ if (!validPromotions) {
163
+ validPromotions = this.inputSelectPromotions.onSubmitValidate();
164
+ }
165
+ return validPromotions && this.radioButtonAdType.onSubmitValidate();
118
166
  }
119
167
 
120
168
  render() {
@@ -124,6 +172,18 @@ export default class Publish1 extends React.Component {
124
172
  <View style={commonStyles.progressbarInputArea}>
125
173
  <Text style={commonStyles.progressbarInputAreaH3}>{strings('setup.typeTransaction')}</Text>
126
174
 
175
+ <InputSelect
176
+ label={strings('setup.selectPromotion')}
177
+ placeholder={strings('setup.select')}
178
+ labelStyle={commonStyles.progressbarField}
179
+ ref={(element) => this.inputSelectPromotions = element}
180
+ visible={this.state.promotionOptions.elements.length > 1}
181
+ required={true}
182
+ scroll={(ref) => this.props.scroll(ref)}
183
+ options={this.state.promotionOptions}
184
+ onChange={(value) => this.changePromotion(value)}
185
+ selectStyle={commonStyles.inputSelect} />
186
+
127
187
  <RadioButtonGroup
128
188
  style={commonStyles.progressbarFieldContainer}
129
189
  required={true}
package/Publish2.js CHANGED
@@ -11,6 +11,7 @@ const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
11
11
  const window = Dimensions.get('window');
12
12
 
13
13
  const GET_LOCATION_FROM_COORDINATES = { method: 'GET', url: '/controller/location' };
14
+ const GET_CHECK_ZONE = { method: 'GET', url: '/controller/posting/check-zone' };
14
15
 
15
16
  export default class Publish2 extends React.Component {
16
17
  constructor(props) {
@@ -26,10 +27,19 @@ export default class Publish2 extends React.Component {
26
27
 
27
28
  async nextStep() {
28
29
  if (await this.validateLocation()) {
29
- if (this.props.postingAd.id == null || this.props.fullPosting) {
30
- this.props.goToPage(Views.PUBLISH_3);
30
+ const responseCheckZone = await this.props.request(this.props.context, GET_CHECK_ZONE, {
31
+ businessId: this.props.postingAd.businessId,
32
+ townId: this.props.postingAd.town
33
+ });
34
+
35
+ if (responseCheckZone.value === 'true') {
36
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
37
+ this.props.goToPage(Views.PUBLISH_3);
38
+ } else {
39
+ this.props.saveEditAd()
40
+ }
31
41
  } else {
32
- this.props.saveEditAd()
42
+ this.popupNoZone.show();
33
43
  }
34
44
  } else {
35
45
  this.popupNoLocation.show();
@@ -123,6 +133,10 @@ export default class Publish2 extends React.Component {
123
133
  onClose={() => this.props.replacePage(Views.PUBLISH_2_B)} title={strings('setup.titleLocationNotFound')} onSubmit={() => { this.props.replacePage(Views.PUBLISH_2_B); return true; }} icon={<FontAwesomeIcon name='block' />}>
124
134
  <Text style={commonStyles.popupText}>{strings('setup.locationNotFound')}</Text>
125
135
  </PopupAdvice>
136
+ <PopupAdvice dialogStyle={commonStyles.popupBox} ref={(popupNoZone) => { this.popupNoZone = popupNoZone; }}
137
+ title={strings('setup.ad_cant_post_zone')} icon={<FontAwesomeIcon name='block' />}>
138
+ <Text style={commonStyles.popupText}></Text>
139
+ </PopupAdvice>
126
140
  </View>
127
141
  );
128
142
  }
package/Publish2b.js CHANGED
@@ -4,13 +4,18 @@ import { strings } from 'muba-i18n';
4
4
  import commonStyles from './commonStyles';
5
5
  import InputSelect from 'muba-input-select';
6
6
  import InputText from 'muba-input-text';
7
+ import PopupAdvice from 'muba-popup-advice';
7
8
  import { Views } from './utils/Views';
9
+ import { createIconSetFromFontello } from 'react-native-vector-icons';
10
+ import fontelloConfig from './fonts/config.json';
11
+ const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
8
12
  const window = Dimensions.get('window');
9
13
 
10
14
  const GET_REGIONS = { method: 'GET', url: '/controller/countries/{countryCode}/regions' };
11
15
  const GET_CITIES_FROM_REGION = { method: 'GET', url: '/controller/regions/{regionId}/cities' };
12
16
  const GET_DISTRICTS_FROM_CITY = { method: 'GET', url: '/controller/cities/{cityId}/districts' };
13
17
  const GET_TOWNS_FROM_DISTRICT = { method: 'GET', url: '/controller/districts/{districtId}/towns' };
18
+ const GET_CHECK_ZONE = { method: 'GET', url: '/controller/posting/check-zone' };
14
19
 
15
20
  export default class Publish2b extends React.Component {
16
21
  constructor(props) {
@@ -213,10 +218,19 @@ export default class Publish2b extends React.Component {
213
218
 
214
219
  async nextStep() {
215
220
  if (this.validateForm()) {
216
- if (this.props.postingAd.id == null || this.props.fullPosting) {
217
- this.props.goToPage(Views.PUBLISH_3);
221
+ const responseCheckZone = await this.props.request(this.props.context, GET_CHECK_ZONE, {
222
+ businessId: this.props.postingAd.businessId,
223
+ townId: this.props.postingAd.town
224
+ });
225
+
226
+ if (responseCheckZone.value === 'true') {
227
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
228
+ this.props.goToPage(Views.PUBLISH_3);
229
+ } else {
230
+ this.props.saveEditAd();
231
+ }
218
232
  } else {
219
- this.props.saveEditAd();
233
+ this.popupNoZone.show();
220
234
  }
221
235
  }
222
236
  }
@@ -305,6 +319,10 @@ export default class Publish2b extends React.Component {
305
319
  <Text style={[commonStyles.carteNote, commonStyles.carteNoteMap]}>{strings('setup.useMap')}</Text>
306
320
  </TouchableHighlight>
307
321
  </View>
322
+ <PopupAdvice dialogStyle={commonStyles.popupBox} ref={(popupNoZone) => { this.popupNoZone = popupNoZone; }}
323
+ title={strings('setup.ad_cant_post_zone')} icon={<FontAwesomeIcon name='block' />}>
324
+ <Text style={commonStyles.popupText}></Text>
325
+ </PopupAdvice>
308
326
  </View>
309
327
  );
310
328
  }
package/locales/ar.json CHANGED
@@ -117,7 +117,9 @@
117
117
  "south": "جنوب",
118
118
  "west": "الغرب",
119
119
  "est": "شرق",
120
- "highlight": "رفع قيمة"
120
+ "highlight": "رفع قيمة",
121
+ "ad_cant_post_zone": "لا يمكنك النشر في هذه المدينة",
122
+ "selectPromotion": "إلى أي ترويج وتخفيض تنتمي الممتلكات الخاصة بك؟*"
121
123
  },
122
124
  "product": {
123
125
  "LISTING": "قوائم",
package/locales/en.json CHANGED
@@ -117,7 +117,9 @@
117
117
  "south": "South",
118
118
  "west": "West",
119
119
  "est": "Est",
120
- "highlight": "Highlight"
120
+ "highlight": "Highlight",
121
+ "ad_cant_post_zone": "You can't post in this city",
122
+ "selectPromotion": "What promotion does your property belong to? *"
121
123
  },
122
124
  "product": {
123
125
  "LISTING": "Listing",
package/locales/es.json CHANGED
@@ -117,7 +117,9 @@
117
117
  "south": "Sur",
118
118
  "west": "Oeste",
119
119
  "est": "Este",
120
- "highlight": "Destacar"
120
+ "highlight": "Destacar",
121
+ "ad_cant_post_zone": "No puedes publicar en esta ciudad",
122
+ "selectPromotion": "¿A qué promoción pertenece tu bien? *"
121
123
  },
122
124
  "product": {
123
125
  "LISTING": "Listing",
package/locales/fr.json CHANGED
@@ -117,7 +117,9 @@
117
117
  "south": "South",
118
118
  "west": "Ouest",
119
119
  "est": "Est",
120
- "highlight": "Mettre en valeur"
120
+ "highlight": "Mettre en valeur",
121
+ "ad_cant_post_zone": "Vous ne pouvez pas poster dans cette ville",
122
+ "selectPromotion": "A quelle promotion appartient votre bien? *"
121
123
  },
122
124
  "product": {
123
125
  "LISTING": "Liste",
package/locales/it.json CHANGED
@@ -117,7 +117,9 @@
117
117
  "south": "Sud",
118
118
  "west": "Ovest",
119
119
  "est": "Est",
120
- "highlight": "Evidenziare"
120
+ "highlight": "Evidenziare",
121
+ "ad_cant_post_zone": "Non puoi postare in questa città",
122
+ "selectPromotion": "A quale promozione appartiene il tuo immobile? *"
121
123
  },
122
124
  "product": {
123
125
  "LISTING": "Inserzioni",
package/locales/nl.json CHANGED
@@ -117,7 +117,9 @@
117
117
  "south": "Zuid",
118
118
  "west": "Oost",
119
119
  "est": "North",
120
- "highlight": "Highlighting"
120
+ "highlight": "Highlighting",
121
+ "ad_cant_post_zone": "In deze stad mag je niet posten",
122
+ "selectPromotion": "Bij welke promotie hoort uw accommodatie? *"
121
123
  },
122
124
  "product": {
123
125
  "LISTING": "Advertenties",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "5.0.9",
3
+ "version": "5.0.11",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {