muba-posting 4.0.5 → 4.1.0

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/EditHead.js CHANGED
@@ -7,10 +7,10 @@ export default class EditHead extends React.Component {
7
7
  super(props);
8
8
 
9
9
  let mainPictureUrl = null;
10
- let mainPicture = this.props.postingAd?.images.filter(item => item.photo.mainPicture === true)[0];
10
+ let mainPicture = this.props.postingAd?.images.filter(item => item.mainPicture === true)[0];
11
11
 
12
12
  if (mainPicture !== undefined) {
13
- mainPictureUrl = mainPicture.photo.url;
13
+ mainPictureUrl = mainPicture.uri;
14
14
  }
15
15
 
16
16
  this.state = {
@@ -21,10 +21,10 @@ export default class EditHead extends React.Component {
21
21
  componentDidUpdate(prevProps) {
22
22
  if (!this.isSameList(prevProps.postingAd.images, this.props.postingAd.images)) {
23
23
  let mainPictureUrl = '';
24
- let mainPicture = this.props.postingAd.images.filter(item => item.photo.mainPicture === true)[0];
24
+ let mainPicture = this.props.postingAd.images.filter(item => item.mainPicture === true)[0];
25
25
 
26
26
  if (mainPicture !== undefined) {
27
- mainPictureUrl = mainPicture.photo.url;
27
+ mainPictureUrl = mainPicture.uri;
28
28
  }
29
29
  this.setState({ mainPictureUrl: mainPictureUrl })
30
30
  }
@@ -44,7 +44,7 @@ export default class EditHead extends React.Component {
44
44
 
45
45
  render() {
46
46
  return (
47
- <ImageBackground style={{ width: '100%' }} source={this.state.mainPictureUrl} resizeMode='cover'>
47
+ <ImageBackground style={{ width: '100%' }} source={{ uri: this.state.mainPictureUrl }} resizeMode='cover'>
48
48
  <View style={commonStyles.editBar}>
49
49
  {this.props.postingAd.reference && this.props.postingAd.reference != '' ?
50
50
  <View style={commonStyles.editRef}>
@@ -7,8 +7,8 @@ import Icon from '@expo/vector-icons/FontAwesome';
7
7
  import { strings } from 'muba-i18n';
8
8
  import commonStyles from './commonStyles';
9
9
 
10
- export const PROMOTE_AD = '/api/posting/PromoteAd';
11
- const GET_COUNTRY_PHONE = '/api/common/GetCountryPhone';
10
+ export const PROMOTE_AD = { method: 'PUT', url: '/controller/ad/{adId}/promote' };
11
+ const COUNTRY_PHONE = { method: 'GET', url: '/controller/countries/{countryCode}/phones' };
12
12
 
13
13
  export default class PopupSpendProduct extends React.Component {
14
14
  constructor(props) {
@@ -21,9 +21,9 @@ export default class PopupSpendProduct extends React.Component {
21
21
  }
22
22
 
23
23
  async componentDidMount() {
24
- const resultJson = await this.props.request(this, GET_COUNTRY_PHONE);
25
- if (resultJson.success) {
26
- this.setState({ countryPhone: resultJson.countryPhones[0].formattedPhone });
24
+ const resultJson = await this.props.request(this, COUNTRY_PHONE);
25
+ if (resultJson.status === 200) {
26
+ this.setState({ countryPhone: resultJson.list[0].formattedPhone });
27
27
  }
28
28
  }
29
29
 
@@ -42,7 +42,7 @@ export default class PopupSpendProduct extends React.Component {
42
42
  });
43
43
 
44
44
  this.props.hideLoading();
45
- if (responseJson.success && responseJson.remaining >= -1) {
45
+ if (responseJson.status === 200 && responseJson.remaining >= -1) {
46
46
  if (responseJson.remaining > -1) {
47
47
  result = 1;
48
48
  }
@@ -65,7 +65,7 @@ export default class PopupSpendProduct extends React.Component {
65
65
  });
66
66
 
67
67
  this.props.hideLoading();
68
- if (responseJson.success && responseJson.remaining >= -1) {
68
+ if (responseJson.status === 200 && responseJson.remaining >= -1) {
69
69
  if (responseJson.remaining > -1) {
70
70
  result = 1;
71
71
  }
package/Posting.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { BackHandler, Text, TouchableOpacity, View } from 'react-native';
3
- import { manipulateAsync } from 'expo-image-manipulator';
4
3
  import CustomScrollView from 'muba-custom-scroll-view';
5
4
  import { CommonActions } from '@react-navigation/native';
6
5
  import { loadLocaleData, currentLocale, strings } from 'muba-i18n';
@@ -22,17 +21,18 @@ import Preview from './Preview';
22
21
  import PublishProgressBar from './PublishProgressBar.js';
23
22
  import EditHead from './EditHead.js';
24
23
  import PictureSelector from 'muba-picture';
25
- import ProgressBar from './shared/ProgressBar.js';
26
24
  import PopupPermissions from 'muba-popup-permissions';
27
25
  import { createIconSetFromFontello } from 'react-native-vector-icons';
28
26
  import fontelloConfig from './fonts/config.json';
29
27
  const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
30
28
 
31
- const SET_AD = '/api/posting/SetAd';
32
- const GET_AD = '/api/posting/GetPostingAd';
33
- const GET_BUSINESS_PRODUCTS = '/api/posting/GetBusinessProducts';
34
- const GET_MAX_PICTURES = '/api/posting/GetMaxPictures';
35
- const GET_COUNTRY_PHONE = '/api/common/GetCountryPhone';
29
+ const CREATE_AD = { method: 'POST', url: '/controller/ads' };
30
+ const UPDATE_AD = { method: 'PUT', url: '/controller/ads/{adId}' };
31
+ const AD = { method: 'GET', url: '/controller/ads/{adId}' };
32
+ const BUSINESS_ID = { method: 'GET', url: '/controller/users/{userId}/businessId' };
33
+ const BUSINESS_PRODUCTS = { method: 'GET', url: '/controller/products/{key}/remaining' };
34
+ const MAX_PICTURES = { method: 'GET', url: '/controller/max-pictures' };
35
+ const COUNTRY_PHONE = { method: 'GET', url: '/controller/countries/{countryCode}/phones' };
36
36
 
37
37
  export default class Posting extends React.Component {
38
38
  constructor(props) {
@@ -47,10 +47,10 @@ export default class Posting extends React.Component {
47
47
  });
48
48
 
49
49
  this.state = {
50
- loading: false,
51
50
  progress: 0,
52
51
  view: null,
53
52
  originView: this.props.adId ? Views.EDIT_SELECTOR : Views.PUBLISH_1,
53
+ fullPosting: this.props.adId == null,
54
54
  prevViews: [],
55
55
  currentScreen: 1,
56
56
  fontLoaded: false,
@@ -66,10 +66,11 @@ export default class Posting extends React.Component {
66
66
  category: null,
67
67
  subCategory: null,
68
68
  subCategoryDetails: [],
69
- isExactlyLocated: true,
69
+ exactlyLocated: true,
70
70
  latitude: null,
71
71
  longitude: null,
72
72
  address: null,
73
+ country: this.props.country,
73
74
  region: null,
74
75
  city: null,
75
76
  district: null,
@@ -116,7 +117,6 @@ export default class Posting extends React.Component {
116
117
  internet: false,
117
118
  phones: this.props.phones ? this.props.phones.includes('###') ? this.props.phones.split('###') : Array.isArray(this.props.phones) ? this.props.phones : [this.props.phones] : [],
118
119
  reference: null,
119
- mail: null,
120
120
  id: null,
121
121
  languageId: currentLocale().toUpperCase(),
122
122
  languages: [{ language: currentLocale().toUpperCase(), title: null, description: null, automatic: true }],
@@ -158,7 +158,6 @@ export default class Posting extends React.Component {
158
158
  }
159
159
  ]);
160
160
  this.setState({ fontLoaded: true });
161
-
162
161
  this.popupPermissions.open();
163
162
  }
164
163
 
@@ -184,12 +183,13 @@ export default class Posting extends React.Component {
184
183
 
185
184
  loadData = async (canPublish) => {
186
185
  if (canPublish) {
187
- const resultJson = await this.props.request(this, GET_COUNTRY_PHONE);
188
- if (resultJson.success) {
189
- this.setState({ countryPhone: resultJson.countryPhones[0].formattedPhone });
186
+ const resultJson = await this.props.request(this, COUNTRY_PHONE, { code: this.props.country });
187
+ if (resultJson.status === 200) {
188
+ this.setState({ countryPhone: resultJson.list[0].formattedPhone });
190
189
  }
191
190
 
192
191
  this.getMaxPictures();
192
+ this.readBusinessId();
193
193
  const hasListings = await this.checkListings();
194
194
  if (this.state.adId != null) {
195
195
  this.setState({ view: this.state.originView });
@@ -228,18 +228,23 @@ export default class Posting extends React.Component {
228
228
  }
229
229
 
230
230
  async checkListings() {
231
- const response = await this.props.request(this, GET_BUSINESS_PRODUCTS, {});
232
- this.setState({
233
- businessId: response.businessId
234
- })
231
+ const response = await this.props.request(this, BUSINESS_PRODUCTS, { key: 'LISTING' });
232
+ return response > 0;
233
+ }
235
234
 
236
- return response.success && response.listings > 0;
235
+ async readBusinessId() {
236
+ const response = await this.props.request(this, BUSINESS_ID, { userId: this.props.userId });
237
+ if (response.status !== 404) {
238
+ this.setState({
239
+ businessId: response
240
+ });
241
+ }
237
242
  }
238
243
 
239
244
  async getMaxPictures() {
240
- const response = await this.props.request(this, GET_MAX_PICTURES, {});
245
+ const response = await this.props.request(this, MAX_PICTURES, {});
241
246
  this.setState({
242
- maxPictures: response.maxPictures
247
+ maxPictures: response
243
248
  })
244
249
  }
245
250
 
@@ -256,6 +261,15 @@ export default class Posting extends React.Component {
256
261
 
257
262
  prevViews.unshift(this.state.view);
258
263
 
264
+ if (!this.state.postingAd.id && this.state.postingAd.town) {
265
+ const response = await this.props.request(this, CREATE_AD, this.state.postingAd);
266
+ if (response.status === 200) {
267
+ await this.setState({
268
+ postingAd: { ...this.state.postingAd, id: response.id }
269
+ })
270
+ }
271
+ }
272
+
259
273
  await this.setState({ prevViews: prevViews, editingStepOne: editingStepOne });
260
274
  await this._updateCurrentScreen(view, params);
261
275
  }
@@ -333,81 +347,39 @@ export default class Posting extends React.Component {
333
347
  }
334
348
 
335
349
  async _saveEditAd() {
336
- this.setState({ loading: true });
337
-
338
- const formData = new FormData();
339
-
340
- let i = 0;
341
- for (let imageObject of this.state.postingAd.images) {
342
- if (imageObject.photo.url) {
343
- if (imageObject.photo.extension === 'heic' || imageObject.photo.extension === 'heif') {
344
- const manipResult = await manipulateAsync(
345
- imageObject.photo.url.uri, [], {}
346
- );
347
-
348
- imageObject.photo.url.uri = manipResult.uri;
349
- }
350
-
351
- formData.append('photo' + i, {
352
- uri: imageObject.photo.url.uri,
353
- name: imageObject.photo.fileName ? imageObject.photo.fileName : 'photo_' + i + '.' + imageObject.photo.extension,
354
- type: 'image/jpeg'
355
- });
356
- if (imageObject.photo.id !== 0) {
357
- formData.append('photo' + i + 'Id', imageObject.photo.id);
358
- }
359
- formData.append('photo' + i + 'ReferenceType', 'AD');
360
- formData.append('photo' + i + 'ReferenceId', this.state.adId);
361
- formData.append('photo' + i + 'ExtraInfo', i);
362
- i++;
350
+ const response = await this.props.request(this, UPDATE_AD, { ...this.state.postingAd, id: { adId: this.state.postingAd.id } });
351
+ if (this.props.adId) {
352
+ if (this.state.originView === Views.EDIT_SELECTOR) {
353
+ this.setState({ isLoading: true });
354
+ await this.loadAd();
355
+ this.editSelector.refresh();
356
+ this._goToPage(Views.EDIT_SELECTOR);
357
+ } else {
358
+ this.props.navigation.goBack();
363
359
  }
360
+ } else {
361
+ await this.setState({ postingAd: { ...this.state.postingAd, adId: response.id } });
362
+ this._goToPage(Views.PREVIEW, null, response);
364
363
  }
365
364
 
366
- this.props.request(this, SET_AD, this.state.postingAd, formData,
367
- this.updateProgress.bind(this),
368
- async (responseJson) => {
369
- await this.setState({ loading: false, progress: 0 });
370
-
371
- if (responseJson.success) {
372
- if (this.props.adId) {
373
- if (this.state.originView === Views.EDIT_SELECTOR) {
374
- this.setState({ isLoading: true });
375
- await this.loadAd();
376
- this.editSelector.refresh();
377
- this._goToPage(Views.EDIT_SELECTOR);
378
- } else {
379
- this.props.navigation.goBack();
380
- }
381
- } else {
382
- await this.setState({ postingAd: { ...this.state.postingAd, adId: responseJson.adId } });
383
- this._goToPage(Views.PREVIEW, null, responseJson);
384
- }
385
-
386
- if (this.props.showRatingPopup) {
387
- this.props.showRatingPopup();
388
- }
389
- }
390
- });
391
- }
392
-
393
- updateProgress(oEvent) {
394
- if (oEvent.lengthComputable) {
395
- var progress = oEvent.loaded / oEvent.total;
396
- var picturesUploaded = Math.round(this.state.postingAd.images.length * progress);
397
- this.setState({ progress: progress, picturesUploaded: picturesUploaded });
398
- } else {
399
- // Unable to compute progress information since the total size is unknown
365
+ if (this.props.showRatingPopup) {
366
+ this.props.showRatingPopup();
400
367
  }
401
368
  }
402
369
 
403
- _showLoading() {
370
+ async _showLoading() {
404
371
  this.setState({ isLoading: true });
405
372
  }
406
373
 
407
- _hideLoading() {
374
+ async _hideLoading() {
375
+ await this.sleep(500);
408
376
  this.setState({ isLoading: false });
409
377
  }
410
378
 
379
+ sleep = (ms) => {
380
+ return new Promise(resolve => setTimeout(resolve, ms));
381
+ }
382
+
411
383
  _openPictureSelector() {
412
384
  this.setState({ showImageBrowser: true })
413
385
  }
@@ -416,12 +388,12 @@ export default class Posting extends React.Component {
416
388
  await this.setState({ showImageBrowser: false });
417
389
 
418
390
  for (let photo of photos) {
419
- this.publish4Screen.loadImage(photo.uri);
391
+ this.publish4Screen.loadImage(photo);
420
392
  }
421
393
  }
422
394
 
423
395
  getAd = async (id) => {
424
- const responseJson = await this.props.request(this, GET_AD, {
396
+ const responseJson = await this.props.request(this, AD, {
425
397
  adId: id
426
398
  });
427
399
 
@@ -431,7 +403,7 @@ export default class Posting extends React.Component {
431
403
  _savePicture = async (picture) => {
432
404
  await this.setState({ showImageBrowser: false })
433
405
  this.setState({ view: Views.PUBLISH_4 }, () => {
434
- this.publish4Screen.loadImage(picture.uri);
406
+ this.publish4Screen.loadImage(picture);
435
407
  })
436
408
  }
437
409
 
@@ -474,6 +446,7 @@ export default class Posting extends React.Component {
474
446
  showLoading={() => this._showLoading()}
475
447
  hideLoading={() => this._hideLoading()}
476
448
  scroll={(ref) => this.scroll.scrollIntoView(ref)}
449
+ fullPosting={this.state.fullPosting}
477
450
  goToPage={(view, editingStepOne) => this._goToPage(view, editingStepOne)}
478
451
  saveEditAd={() => this._saveEditAd()}
479
452
  showView={this.state.view === Views.PUBLISH_1}
@@ -492,6 +465,7 @@ export default class Posting extends React.Component {
492
465
  hideLoading={() => this._hideLoading()}
493
466
  hereAppId={this.props.hereAppId} hereAppCode={this.props.hereAppCode}
494
467
  showView={this.state.view === Views.PUBLISH_2}
468
+ fullPosting={this.state.fullPosting}
495
469
  progressBarHeight={this.state.progressBarHeight}
496
470
  headerHeight={this.state.headerHeight} />
497
471
 
@@ -506,6 +480,7 @@ export default class Posting extends React.Component {
506
480
  showLoading={() => this._showLoading()}
507
481
  hideLoading={() => this._hideLoading()}
508
482
  showView={this.state.view === Views.PUBLISH_2_B}
483
+ fullPosting={this.state.fullPosting}
509
484
  progressBarHeight={this.state.progressBarHeight}
510
485
  headerHeight={this.state.headerHeight} />
511
486
 
@@ -521,6 +496,7 @@ export default class Posting extends React.Component {
521
496
  showLoading={() => this._showLoading()}
522
497
  hideLoading={() => this._hideLoading()}
523
498
  showView={this.state.view === Views.PUBLISH_3}
499
+ fullPosting={this.state.fullPosting}
524
500
  progressBarHeight={this.state.progressBarHeight}
525
501
  headerHeight={this.state.headerHeight} />
526
502
 
@@ -533,6 +509,7 @@ export default class Posting extends React.Component {
533
509
  showLoading={() => this._showLoading()}
534
510
  hideLoading={() => this._hideLoading()}
535
511
  showView={this.state.view === Views.PUBLISH_4}
512
+ fullPosting={this.state.fullPosting}
536
513
  progressBarHeight={this.state.progressBarHeight}
537
514
  headerHeight={this.state.headerHeight}
538
515
  openPictureSelector={() => this._openPictureSelector()}
@@ -548,6 +525,7 @@ export default class Posting extends React.Component {
548
525
  showLoading={() => this._showLoading()}
549
526
  hideLoading={() => this._hideLoading()}
550
527
  showView={this.state.view === Views.PUBLISH_5}
528
+ fullPosting={this.state.fullPosting}
551
529
  progressBarHeight={this.state.progressBarHeight}
552
530
  headerHeight={this.state.headerHeight} />
553
531
 
@@ -562,6 +540,7 @@ export default class Posting extends React.Component {
562
540
  showLoading={() => this._showLoading()}
563
541
  hideLoading={() => this._hideLoading()}
564
542
  showView={this.state.view === Views.PUBLISH_6}
543
+ fullPosting={this.state.fullPosting}
565
544
  progressBarHeight={this.state.progressBarHeight}
566
545
  headerHeight={this.state.headerHeight} />
567
546
 
@@ -583,16 +562,6 @@ export default class Posting extends React.Component {
583
562
  topBar={this.props.topBar}
584
563
  goToPage={(view) => this._goToPage(view)} />
585
564
 
586
- <ProgressBar loading={this.state.loading} progress={(this.state.progress * 100).toFixed(0)}>
587
- <View style={commonStyles.loadingPicturesNote}>
588
- {this.state.picturesUploaded == this.state.postingAd.images.length ?
589
- <Text style={commonStyles.mapNoteText}>{strings('setup.savingAd')}</Text>
590
- :
591
- <Text style={commonStyles.mapNoteText}>{strings('setup.uploadingPicture')} {this.state.picturesUploaded} / {this.state.postingAd.images.length}</Text>
592
- }
593
- </View>
594
- </ProgressBar>
595
-
596
565
  </CustomScrollView>
597
566
  <PopupAdvice icon={<FontAwesomeIcon name='block' />} title={strings('setup.noPromoteTitle', { product: '' })} headerColor={commonStyles.red} ref={(popupAdvice) => { this.popupNoListings = popupAdvice; }}
598
567
  onClose={async () => this.state.view !== Views.PREVIEW ? this.goBack() : null} hideButton={true}>
package/PostingEdit.js CHANGED
@@ -10,12 +10,12 @@ export default class PostingEdit extends React.Component {
10
10
  super(props);
11
11
 
12
12
  this.state = {
13
- showFunctionalities: null
13
+ showFunctionalities: this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0
14
14
  };
15
15
  }
16
16
 
17
17
  componentDidUpdate = (prevProps) => {
18
- if (prevProps.postingAd.adId !== this.props.postingAd.adId) {
18
+ if (prevProps.postingAd.id !== this.props.postingAd.id) {
19
19
  this.refresh();
20
20
  }
21
21
  }
@@ -27,7 +27,7 @@ export default class PostingEdit extends React.Component {
27
27
  }
28
28
 
29
29
  navigateToPublish2() {
30
- if (this.props.postingAd.isExactlyLocated) {
30
+ if (this.props.postingAd.exactlyLocated) {
31
31
  this.props.goToPage(Views.PUBLISH_2);
32
32
  } else {
33
33
  this.props.goToPage(Views.PUBLISH_2_B);
package/Preview.js CHANGED
@@ -198,7 +198,7 @@ export default class Preview extends React.Component {
198
198
  </View>
199
199
  </View>
200
200
  : null}
201
- <PopupSpendProduct adId={this.props.postingAd.adId} ref={(popupShowAdvice) => { this.popupShowAdvice = popupShowAdvice }} businessId={this.props.businessId} request={this.props.request}
201
+ <PopupSpendProduct adId={this.props.postingAd.id} ref={(popupShowAdvice) => { this.popupShowAdvice = popupShowAdvice }} businessId={this.props.businessId} request={this.props.request}
202
202
  showLoading={this.props.showLoading} hideLoading={this.props.hideLoading} />
203
203
  </View>
204
204
  );
package/Publish1.js CHANGED
@@ -6,7 +6,7 @@ import RadioButtonGroup from 'muba-radio-button-group';
6
6
  import { Views } from './utils/Views';
7
7
  const window = Dimensions.get('window');
8
8
 
9
- const GET_CATEGORIES = '/api/common/GetPostingCategories';
9
+ const GET_CATEGORIES = { method: 'GET', url: '/controller/categories' };
10
10
 
11
11
  export default class Publish1 extends React.Component {
12
12
  constructor(props) {
@@ -31,11 +31,11 @@ export default class Publish1 extends React.Component {
31
31
  });
32
32
 
33
33
  const responseJson = await this.props.request(this.props.context, GET_CATEGORIES, {
34
- userEmail: this.props.postingAd.userEmail
34
+ userId: this.props.postingAd.userId
35
35
  });
36
36
 
37
- if (responseJson.success) {
38
- this.jsonCategories = responseJson.categoryList;
37
+ if (responseJson.status === 200) {
38
+ this.jsonCategories = responseJson.list;
39
39
  this.props.postingAd.category = this.props.postingAd.category != null ? this.props.postingAd.category : this.jsonCategories[0].value;
40
40
  this.props.postingAd.subCategory = this.props.postingAd.subCategory != null ? this.props.postingAd.subCategory : this.jsonCategories[0].subCategoryList[0].value;
41
41
 
@@ -113,7 +113,7 @@ export default class Publish1 extends React.Component {
113
113
  }
114
114
  }
115
115
 
116
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
116
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
117
117
  if (this.props.postingAd.isExactlyLocated) {
118
118
  this.props.goToPage(Views.PUBLISH_2);
119
119
  } else {
@@ -166,7 +166,7 @@ export default class Publish1 extends React.Component {
166
166
  <View style={commonStyles.buttomButton}>
167
167
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
168
168
  <Text style={commonStyles.actionButtonText}>
169
- {this.props.postingAd.adId == null || this.props.fullPosting || this.oldCategory != this.state.transactionOptions.selectedItem || this.oldSubCategory != this.state.typeBienOptions.selectedItem ?
169
+ {this.props.postingAd.id == null || this.props.fullPosting || this.oldCategory != this.state.transactionOptions.selectedItem || this.oldSubCategory != this.state.typeBienOptions.selectedItem ?
170
170
  strings('setup.next').toUpperCase()
171
171
  :
172
172
  strings('setup.enregistrer').toUpperCase()}
package/Publish2.js CHANGED
@@ -10,7 +10,7 @@ import fontelloConfig from './fonts/config.json';
10
10
  const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
11
11
  const window = Dimensions.get('window');
12
12
 
13
- const GET_LOCATION_FROM_COORDINATES = '/api/common/GetLocationFromCoordinates';
13
+ const GET_LOCATION_FROM_COORDINATES = { method: 'GET', url: '/controller/location' };
14
14
 
15
15
  export default class Publish2 extends React.Component {
16
16
  constructor(props) {
@@ -42,7 +42,7 @@ export default class Publish2 extends React.Component {
42
42
 
43
43
  async nextStep() {
44
44
  if (await this.validateLocation()) {
45
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
45
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
46
46
  this.props.goToPage(Views.PUBLISH_3);
47
47
  } else {
48
48
  this.props.saveEditAd()
@@ -63,11 +63,11 @@ export default class Publish2 extends React.Component {
63
63
  });
64
64
 
65
65
  if (responseJson.success) {
66
- if (responseJson.isExactlyLocated) {
67
- this.props.postingAd.isExactlyLocated = true;
66
+ if (responseJson.exactlyLocated) {
67
+ this.props.postingAd.exactlyLocated = true;
68
68
  validateLocation = true;
69
69
  } else {
70
- this.props.postingAd.isExactlyLocated = false;
70
+ this.props.postingAd.exactlyLocated = false;
71
71
  }
72
72
 
73
73
  if (responseJson.region !== undefined) {
@@ -131,9 +131,9 @@ export default class Publish2 extends React.Component {
131
131
  : null}
132
132
  <View style={commonStyles.buttomButton} onLayout={this.onLayout}>
133
133
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
134
- <Text style={commonStyles.actionButtonText}>{this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
134
+ <Text style={commonStyles.actionButtonText}>{this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
135
135
  </TouchableHighlight>
136
- <TouchableHighlight underlayColor="rgba(0,0,0,0)" onPress={() => { this.props.postingAd.isExactlyLocated = false; this.props.replacePage(Views.PUBLISH_2_B) }}>
136
+ <TouchableHighlight underlayColor="rgba(0,0,0,0)" onPress={() => { this.props.postingAd.exactlyLocated = false; this.props.replacePage(Views.PUBLISH_2_B) }}>
137
137
  <Text style={[commonStyles.carteNote, commonStyles.carteNoteMap]}>{strings('setup.notUseMap')}</Text>
138
138
  </TouchableHighlight>
139
139
  </View>
package/Publish2b.js CHANGED
@@ -7,7 +7,10 @@ import InputText from 'muba-input-text';
7
7
  import { Views } from './utils/Views';
8
8
  const window = Dimensions.get('window');
9
9
 
10
- const GET_LOCATIONS = '/api/common/GetLocations';
10
+ const GET_REGIONS = { method: 'GET', url: '/controller/countries/{countryCode}/regions' };
11
+ const GET_CITIES_FROM_REGION = { method: 'GET', url: '/controller/regions/{regionId}/cities' };
12
+ const GET_DISTRICTS_FROM_CITY = { method: 'GET', url: '/controller/cities/{cityId}/districts' };
13
+ const GET_TOWNS_FROM_DISTRICT = { method: 'GET', url: '/controller/districts/{districtId}/towns' };
11
14
 
12
15
  export default class Publish2b extends React.Component {
13
16
  constructor(props) {
@@ -89,17 +92,15 @@ export default class Publish2b extends React.Component {
89
92
 
90
93
  async loadRegions() {
91
94
  if (this.state.regionOptions.elements.length <= 1) {
92
- const responseJson = await this.props.request(this.props.context, GET_LOCATIONS, {
93
- locationLevel: '1'
94
- });
95
+ const responseJson = await this.props.request(this.props.context, GET_REGIONS, {});
95
96
 
96
- if (responseJson.success) {
97
+ if (responseJson.status === 200) {
97
98
  const regionOptions = {
98
99
  elements: [this.state.regionOptions.elements[0]],
99
100
  selectedItem: this.props.postingAd.region
100
101
  };
101
102
 
102
- responseJson.resultList.map((item) => {
103
+ responseJson.list.map((item) => {
103
104
  regionOptions.elements.push(item);
104
105
  });
105
106
 
@@ -115,18 +116,17 @@ export default class Publish2b extends React.Component {
115
116
 
116
117
  this.props.postingAd.region = value;
117
118
 
118
- const responseJson = await this.props.request(this.props.context, GET_LOCATIONS, {
119
- locationLevel: '3',
120
- parentId: this.props.postingAd.region
119
+ const responseJson = await this.props.request(this.props.context, GET_CITIES_FROM_REGION, {
120
+ regionId: this.props.postingAd.region
121
121
  });
122
122
 
123
- if (responseJson.success) {
123
+ if (responseJson.status === 200) {
124
124
  var cityOptions = {
125
125
  elements: [this.state.cityOptions.elements[0]],
126
126
  selectedItem: null
127
127
  };
128
128
 
129
- responseJson.resultList.map((item) => {
129
+ responseJson.list.map((item) => {
130
130
  cityOptions.elements.push(item);
131
131
  });
132
132
 
@@ -153,30 +153,29 @@ export default class Publish2b extends React.Component {
153
153
 
154
154
  this.props.postingAd.city = value;
155
155
 
156
- const responseJson = await this.props.request(this.props.context, GET_LOCATIONS, {
157
- locationLevel: '4',
158
- parentId: this.props.postingAd.city
156
+ const responseJson = await this.props.request(this.props.context, GET_DISTRICTS_FROM_CITY, {
157
+ cityId: this.props.postingAd.city
159
158
  });
160
159
 
161
- if (responseJson.success) {
160
+ if (responseJson.status === 200) {
162
161
  let districtOptions = {
163
162
  elements: [this.state.districtOptions.elements[0]],
164
163
  selectedItem: null
165
164
  };
166
165
 
167
- responseJson.resultList.map((item) => {
166
+ responseJson.list.map((item) => {
168
167
  districtOptions.elements.push(item);
169
168
  });
170
169
 
171
- if (responseJson.resultList.length == 1) {
172
- districtOptions.selectedItem = responseJson.resultList[0].value;
170
+ if (responseJson.list.length == 1) {
171
+ districtOptions.selectedItem = responseJson.list[0].value;
173
172
  }
174
173
 
175
174
  await this.setState({ districtOptions: districtOptions });
176
175
  this.props.postingAd.district = null;
177
176
  this.props.postingAd.town = null;
178
177
 
179
- if (responseJson.resultList.length == 1) {
178
+ if (responseJson.list.length == 1) {
180
179
  this.inputSelectDistrict?.onSubmitValidate();
181
180
  await this.loadTowns(districtOptions.selectedItem);
182
181
  } else {
@@ -196,29 +195,28 @@ export default class Publish2b extends React.Component {
196
195
 
197
196
  this.props.postingAd.district = value;
198
197
 
199
- const responseJson = await this.props.request(this.props.context, GET_LOCATIONS, {
200
- locationLevel: '5',
201
- parentId: this.props.postingAd.district
198
+ const responseJson = await this.props.request(this.props.context, GET_TOWNS_FROM_DISTRICT, {
199
+ districtId: this.props.postingAd.district
202
200
  });
203
201
 
204
- if (responseJson.success) {
202
+ if (responseJson.status === 200) {
205
203
  var townOptions = {
206
204
  elements: [this.state.townOptions.elements[0]],
207
205
  selectedItem: null
208
206
  };
209
207
 
210
- responseJson.resultList.map((item) => {
208
+ responseJson.list.map((item) => {
211
209
  townOptions.elements.push(item);
212
210
  });
213
211
 
214
- if (responseJson.resultList.length == 1) {
215
- townOptions.selectedItem = responseJson.resultList[0].value;
212
+ if (responseJson.list.length == 1) {
213
+ townOptions.selectedItem = responseJson.list[0].value;
216
214
  this.props.postingAd.town = townOptions.selectedItem;
217
215
  }
218
216
 
219
217
  await this.setState({ townOptions: townOptions });
220
218
 
221
- if (responseJson.resultList.length == 1) {
219
+ if (responseJson.list.length == 1) {
222
220
  this.inputSelectTown?.onSubmitValidate();
223
221
  }
224
222
  }
@@ -230,7 +228,7 @@ export default class Publish2b extends React.Component {
230
228
 
231
229
  async nextStep() {
232
230
  if (this.validateForm()) {
233
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
231
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
234
232
  this.props.goToPage(Views.PUBLISH_3);
235
233
  } else {
236
234
  this.props.saveEditAd();
@@ -318,9 +316,9 @@ export default class Publish2b extends React.Component {
318
316
  </View>
319
317
  <View style={commonStyles.buttomButton}>
320
318
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
321
- <Text style={commonStyles.actionButtonText}>{this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
319
+ <Text style={commonStyles.actionButtonText}>{this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
322
320
  </TouchableHighlight>
323
- <TouchableHighlight underlayColor="rgba(0,0,0,0)" onPress={() => { this.props.postingAd.isExactlyLocated = true; this.props.replacePage(Views.PUBLISH_2) }}>
321
+ <TouchableHighlight underlayColor="rgba(0,0,0,0)" onPress={() => { this.props.postingAd.exactlyLocated = true; this.props.replacePage(Views.PUBLISH_2) }}>
324
322
  <Text style={[commonStyles.carteNote, commonStyles.carteNoteMap]}>{strings('setup.useMap')}</Text>
325
323
  </TouchableHighlight>
326
324
  </View>
package/Publish3.js CHANGED
@@ -9,7 +9,7 @@ import InputText from 'muba-input-text';
9
9
  import { Views } from './utils/Views';
10
10
  const window = Dimensions.get('window');
11
11
 
12
- const GET_CURRENCIES = '/api/mubawabapp/GetCurrencyList';
12
+ const GET_CURRENCIES = { method: 'GET', url: '/controller/countries/{countryCode}/currencies' };
13
13
 
14
14
  export default class Publish3 extends React.Component {
15
15
  constructor(props) {
@@ -64,8 +64,8 @@ export default class Publish3 extends React.Component {
64
64
  const responseJson = await this.props.request(this.props.context, GET_CURRENCIES, {});
65
65
  const priceOptions = this.state.priceOptions;
66
66
 
67
- if (responseJson.success) {
68
- responseJson.currencyList.map((item) => {
67
+ if (responseJson.status === 200) {
68
+ responseJson.list.map((item) => {
69
69
  priceOptions.elements.push(item);
70
70
  });
71
71
  priceOptions.selectedItem = priceOptions.elements[1]?.value;
@@ -157,7 +157,7 @@ export default class Publish3 extends React.Component {
157
157
  this.props.postingAd.pricePeriod = null;
158
158
  }
159
159
 
160
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
160
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
161
161
  this.props.goToPage(Views.PUBLISH_4);
162
162
  } else {
163
163
  if (this.props.editingStepOne && this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) {
@@ -385,7 +385,7 @@ export default class Publish3 extends React.Component {
385
385
  <View style={commonStyles.buttomButton}>
386
386
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
387
387
  <Text style={commonStyles.actionButtonText}>
388
- {this.props.postingAd.adId == null || this.props.fullPosting || (this.props.editingStepOne && this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) ?
388
+ {this.props.postingAd.id == null || this.props.fullPosting || (this.props.editingStepOne && this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) ?
389
389
  strings('setup.next').toUpperCase()
390
390
  :
391
391
  strings('setup.enregistrer').toUpperCase()}
package/Publish4.js CHANGED
@@ -3,7 +3,6 @@ import { Text, View, TouchableHighlight, TouchableOpacity, ImageBackground, Dime
3
3
  import PopupAdvice from 'muba-popup-advice';
4
4
  import { strings } from 'muba-i18n';
5
5
  import commonStyles from './commonStyles';
6
- import { canOpenCamera } from './utils/Common.js';
7
6
  import { Views } from './utils/Views';
8
7
  import { createIconSetFromFontello } from 'react-native-vector-icons';
9
8
  import fontelloConfig from './fonts/config.json';
@@ -47,12 +46,16 @@ export default class Publish4 extends React.Component {
47
46
 
48
47
  async loadImage(imgUri) {
49
48
  if (imgUri) {
49
+ let fileType = imgUri.substring(imgUri.lastIndexOf('.') + 1).toLowerCase();
50
+
50
51
  const image = {
51
- photo: {
52
- id: 0,
53
- url: { uri: imgUri },
54
- extension: imgUri.substring(imgUri.lastIndexOf('.') + 1)
55
- }
52
+ uri: imgUri,
53
+ name: 'photo_' + this.props.postingAd.images.length + '.' + fileType,
54
+ type: 'image/' + fileType,
55
+ mainPicture: this.props.postingAd.images.length === 0,
56
+ referenceType: 'AD',
57
+ referenceId: this.props.postingAd.id,
58
+ extraInfo: this.props.postingAd.images.length
56
59
  }
57
60
 
58
61
  let imagesArray = this.props.postingAd.images;
@@ -70,11 +73,11 @@ export default class Publish4 extends React.Component {
70
73
  }
71
74
 
72
75
  async deleteImage(itemDeleted) {
73
- if (itemDeleted.photo.id) {
76
+ if (itemDeleted.id) {
74
77
  if (!this.props.postingAd.deletedPictures) {
75
78
  this.props.postingAd.deletedPictures = [];
76
79
  }
77
- this.props.postingAd.deletedPictures.push(itemDeleted.photo.id);
80
+ this.props.postingAd.deletedPictures.push(itemDeleted.id);
78
81
  }
79
82
 
80
83
  let filteredArray = this.props.postingAd.images.filter(item => item !== itemDeleted);
@@ -90,15 +93,22 @@ export default class Publish4 extends React.Component {
90
93
  let imagesArray = this.props.postingAd.images.slice();
91
94
 
92
95
  for (let imageObject of imagesArray) {
93
- imageObject.photo.mainPicture = false;
96
+ imageObject.mainPicture = false;
94
97
 
95
- if (imageObject.photo.url === itemSelected.photo.url) {
96
- imageObject.photo.mainPicture = true;
97
- this.props.postingAd.images.splice(this.props.postingAd.images.indexOf(imageObject), 1);
98
- this.props.postingAd.images.splice(0, 0, imageObject);
98
+ if (imageObject.uri === itemSelected.uri) {
99
+ imageObject.mainPicture = true;
100
+ imagesArray.splice(imagesArray.indexOf(imageObject), 1);
101
+ imagesArray.splice(0, 0, imageObject);
99
102
  }
100
103
  }
104
+ let index = 0;
105
+ for (let imageObject of imagesArray) {
106
+ imageObject.name = 'photo_' + index + (imageObject.id ? '_' + imageObject.id : '') + imageObject.name.substring(imageObject.name.indexOf('.'));
107
+ imageObject.extraInfo = index;
108
+ ++index;
109
+ }
101
110
 
111
+ this.props.postingAd.images = imagesArray;
102
112
  this.setState({ updateMainPhoto: true });
103
113
  }
104
114
 
@@ -107,8 +117,7 @@ export default class Publish4 extends React.Component {
107
117
  this.setState({ showErrorNoSelectedImages: true });
108
118
  } else {
109
119
  this.setState({ showErrorNoSelectedImages: false });
110
-
111
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
120
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
112
121
  if (this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) {
113
122
  this.props.goToPage(Views.PUBLISH_5);
114
123
  } else {
@@ -160,14 +169,14 @@ export default class Publish4 extends React.Component {
160
169
  }
161
170
  {this.props.postingAd.images.map((item, index) => {
162
171
  return (
163
- <ImageBackground style={[commonStyles.photoBox, commonStyles.photoBoxImage]} source={item.photo.url} borderRadius={10} key={index}>
172
+ <ImageBackground style={[commonStyles.photoBox, commonStyles.photoBoxImage]} source={{ uri: item.uri }} borderRadius={10} key={index}>
164
173
  <ImageBackground style={[commonStyles.photoControls, commonStyles.row]} source={require('./assets/images/bg-shadow.png')} resizeMode='stretch' borderRadius={1.5}>
165
174
 
166
175
  <TouchableHighlight style={commonStyles.leftIcon} onPress={() => this.deleteImage(item)}>
167
176
  <FontAwesomeIcon style={commonStyles.whiteIcon} name="cancel-circled" />
168
177
  </TouchableHighlight>
169
178
  <TouchableHighlight style={commonStyles.rightIcon} onPress={() => this.selectMainPhoto(item)}>
170
- <FontAwesomeIcon style={[commonStyles.heartIcon, item.photo.mainPicture ? '' : commonStyles.whiteIcon]} name={item.photo.mainPicture ? 'heart' : 'heart-empty'} />
179
+ <FontAwesomeIcon style={[commonStyles.heartIcon, item.mainPicture ? '' : commonStyles.whiteIcon]} name={item.mainPicture ? 'heart' : 'heart-empty'} />
171
180
  </TouchableHighlight>
172
181
 
173
182
  </ImageBackground>
@@ -186,7 +195,7 @@ export default class Publish4 extends React.Component {
186
195
  </View>
187
196
  <View style={commonStyles.buttomButton}>
188
197
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
189
- <Text style={commonStyles.actionButtonText}>{this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
198
+ <Text style={commonStyles.actionButtonText}>{this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
190
199
  </TouchableHighlight>
191
200
  </View>
192
201
 
package/Publish5.js CHANGED
@@ -124,7 +124,7 @@ export default class Publish5 extends React.Component {
124
124
 
125
125
  nextStep() {
126
126
  if (this.validateForm()) {
127
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
127
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
128
128
  this.props.goToPage(Views.PUBLISH_6);
129
129
  } else {
130
130
  this.props.saveEditAd();
@@ -464,7 +464,7 @@ export default class Publish5 extends React.Component {
464
464
  <View style={commonStyles.buttomButton}>
465
465
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
466
466
  <Text style={commonStyles.actionButtonText}>
467
- {this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}
467
+ {this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}
468
468
  </Text>
469
469
  </TouchableHighlight>
470
470
  </View>
package/Publish6.js CHANGED
@@ -8,10 +8,10 @@ import PopupAdvice from 'muba-popup-advice';
8
8
  import { createIconSetFromFontello } from 'react-native-vector-icons';
9
9
  import fontelloConfig from './fonts/config.json';
10
10
  const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
11
- const GET_GENERATE_TITLE_DESCRIPTION = '/api/posting/GetGeneratedAdTitleDescription';
12
- const GET_PHONE_REGISTERED = '/api/posting/GetPhoneRegistered';
11
+
12
+ const GENERATE_TITLE_DESCRIPTION = { method: 'POST', url: '/controller/generate-title-description' };
13
+ const PHONE_REGISTERED = { method: 'GET', url: '/controller/phone-registered' };
13
14
  const window = Dimensions.get('window');
14
- const OK_MESSAGE = 'ok';
15
15
  const PHONE_SEPARATOR = '###';
16
16
 
17
17
  let submitClicked;
@@ -74,10 +74,11 @@ export default class Publish6 extends React.Component {
74
74
  this.props.postingAd.languages[0].description === undefined || this.props.postingAd.languages[0].description === null) {
75
75
 
76
76
  this.props.showLoading();
77
+ const ad = { ...this.props.postingAd };
78
+ delete ad.images;
79
+ const responseJson = await this.props.request(this.props.context, GENERATE_TITLE_DESCRIPTION, ad);
77
80
 
78
- const responseJson = await this.props.request(this.props.context, GET_GENERATE_TITLE_DESCRIPTION, this.props.postingAd);
79
-
80
- if (responseJson.success) {
81
+ if (responseJson?.status === 200) {
81
82
  if (this.props.postingAd.languages[0].title === undefined || this.props.postingAd.languages[0].title === null) {
82
83
  this.props.postingAd.languages[0].title = responseJson.title;
83
84
  }
@@ -92,6 +93,7 @@ export default class Publish6 extends React.Component {
92
93
  } else {
93
94
  this.setState({ titleDescriptionLoaded: true });
94
95
  }
96
+ this.props.hideLoading();
95
97
  }
96
98
 
97
99
  async nextStep() {
@@ -117,19 +119,17 @@ export default class Publish6 extends React.Component {
117
119
  const phones = this.props.postingAd.phones.join(PHONE_SEPARATOR);
118
120
 
119
121
  const body = {
120
- adId: this.props.postingAd.adId,
122
+ adId: this.props.postingAd.id,
121
123
  userId: this.props.postingAd.userId,
122
- phone: phones
124
+ phones: phones
123
125
  };
124
126
 
127
+
125
128
  this.setState({ loading: true });
126
129
 
127
- const responseJson = await this.props.request(this.props.context, GET_PHONE_REGISTERED, body);
128
- if (responseJson.success) {
129
- const phoneFree = (responseJson.responseStatus === OK_MESSAGE);
130
- validate = phoneFree && validate;
131
- this.setState({ existingPhoneError: !phoneFree });
132
- }
130
+ const phoneFree = await this.props.request(this.props.context, PHONE_REGISTERED, body);
131
+ validate = phoneFree && validate;
132
+ this.setState({ existingPhoneError: !phoneFree });
133
133
 
134
134
  this.languageItem.forEach(element => validate = element.validateLanguageItem() && validate);
135
135
  }
@@ -228,7 +228,7 @@ export default class Publish6 extends React.Component {
228
228
  <Text style={commonStyles.legalNoteText}>{strings('setup.legalNote')}</Text>
229
229
  </View>
230
230
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={async () => this.nextStep()}>
231
- <Text style={commonStyles.actionButtonText}>{this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.publish').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
231
+ <Text style={commonStyles.actionButtonText}>{this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.publish').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
232
232
  </TouchableHighlight>
233
233
  </View>
234
234
  <PopupAdvice width={0.9} dialogStyle={commonStyles.popupBox} ref={(popupShowAdvice) => { this.popupShowAdvice = popupShowAdvice; }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "4.0.5",
3
+ "version": "4.1.0",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {
@@ -18,7 +18,6 @@
18
18
  "homepage": "https://github.com/Mubawab/muba-posting#readme",
19
19
  "dependencies": {
20
20
  "@react-native-async-storage/async-storage": "~1.15.0",
21
- "expo-image-manipulator": "~10.2.0",
22
21
  "muba-custom-scroll-view": "4",
23
22
  "muba-display-price": "4",
24
23
  "muba-font": "4",
@@ -1,177 +0,0 @@
1
- /** React Native Percentage Circle
2
- ** @github https://github.com/JackPu/react-native-percentage-circle
3
- ** React Native Version >=0.25
4
- ** to fixed react native version
5
- **/
6
-
7
- import React, { Component } from 'react';
8
- import {
9
- StyleSheet,
10
- View,
11
- Text,
12
- } from 'react-native';
13
-
14
- const styles = StyleSheet.create({
15
- circle: {
16
- overflow: 'hidden',
17
- position: 'relative',
18
- justifyContent: 'center',
19
- alignItems: 'center',
20
- backgroundColor: '#e3e3e3',
21
- },
22
- leftWrap: {
23
- overflow: 'hidden',
24
- position: 'absolute',
25
- top: 0,
26
- },
27
- rightWrap: {
28
- position: 'absolute',
29
-
30
- },
31
-
32
- loader: {
33
- position: 'absolute',
34
- left: 0,
35
- top: 0,
36
- borderRadius: 1000,
37
-
38
- },
39
-
40
- innerCircle: {
41
- overflow: 'hidden',
42
- position: 'relative',
43
- justifyContent: 'center',
44
- alignItems: 'center',
45
- },
46
- text: {
47
- fontSize: 11,
48
- color: '#888',
49
- },
50
- });
51
-
52
- class PercentageCircle extends Component {
53
- constructor(props) {
54
- super(props);
55
- let percent = this.props.percent;
56
- let leftTransformerDegree = '0deg';
57
- let rightTransformerDegree = '0deg';
58
- if (percent >= 50) {
59
- rightTransformerDegree = '180deg';
60
- leftTransformerDegree = (percent - 50) * 3.6 + 'deg';
61
- } else {
62
- rightTransformerDegree = percent * 3.6 + 'deg';
63
- leftTransformerDegree = '180deg';
64
- }
65
-
66
- this.state = {
67
- percent: this.props.percent,
68
- borderWidth: this.props.borderWidth < 2 || !this.props.borderWidth ? 2 : this.props.borderWidth,
69
- leftTransformerDegree: leftTransformerDegree,
70
- rightTransformerDegree: rightTransformerDegree,
71
- textStyle: this.props.textStyle ? this.props.textStyle : null
72
- };
73
- }
74
-
75
- componentDidUpdate = (prevProps) => {
76
- if (prevProps.percent !== this.props.percent) {
77
- const percent = this.props.percent;
78
- let leftTransformerDegree = '0deg';
79
- let rightTransformerDegree = '0deg';
80
- if (percent >= 50) {
81
- rightTransformerDegree = '180deg';
82
- leftTransformerDegree = (percent - 50) * 3.6 + 'deg';
83
- } else {
84
- rightTransformerDegree = percent * 3.6 + 'deg';
85
- leftTransformerDegree = "180deg";
86
- }
87
- this.setState({
88
- percent: percent,
89
- borderWidth: this.props.borderWidth < 2 || !this.props.borderWidth ? 2 : this.props.borderWidth,
90
- leftTransformerDegree: leftTransformerDegree,
91
- rightTransformerDegree: rightTransformerDegree
92
- });
93
- }
94
- }
95
-
96
- render() {
97
- if (this.props.disabled) {
98
- return (
99
- <View style={[styles.circle, {
100
- width: this.props.radius * 2,
101
- height: this.props.radius * 2,
102
- borderRadius: this.props.radius
103
- }]}>
104
- <Text style={styles.text}>{this.props.disabledText}</Text>
105
- </View>
106
- );
107
- }
108
- return (
109
- <View style={[styles.circle, {
110
- width: this.props.radius * 2,
111
- height: this.props.radius * 2,
112
- borderRadius: this.props.radius,
113
- backgroundColor: this.props.bgcolor
114
- }]}>
115
- <View style={[styles.leftWrap, {
116
- left: this.props.radius,
117
- width: this.props.radius,
118
- height: this.props.radius * 2,
119
- }]}>
120
- <View style={[styles.loader, {
121
- left: -this.props.radius,
122
- width: this.props.radius,
123
- height: this.props.radius * 2,
124
- borderTopRightRadius: 0,
125
- borderBottomRightRadius: 0,
126
- backgroundColor: this.props.color,
127
- transform: [{ translateX: this.props.radius / 2 }, { rotate: this.state.rightTransformerDegree }, { translateX: -this.props.radius / 2 }],
128
- }]}></View>
129
- </View>
130
-
131
-
132
- <View style={[styles.leftWrap, {
133
- width: this.props.radius,
134
- height: this.props.radius * 2,
135
- left: 0,
136
- }]}>
137
- <View style={[styles.loader, {
138
- left: this.props.radius,
139
- width: this.props.radius,
140
- height: this.props.radius * 2,
141
- borderTopLeftRadius: 0,
142
- borderBottomLeftRadius: 0,
143
- backgroundColor: this.props.percent >= 50 ? this.props.color : this.props.bgcolor, // changed this line
144
- transform: [{ translateX: -this.props.radius / 2 }, { rotate: this.state.leftTransformerDegree }, { translateX: this.props.radius / 2 }],
145
- }]}></View>
146
- </View>
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
- <View style={[styles.innerCircle, {
157
- width: (this.props.radius - this.state.borderWidth) * 2,
158
- height: (this.props.radius - this.state.borderWidth) * 2,
159
- borderRadius: this.props.radius - this.state.borderWidth,
160
- backgroundColor: this.props.innerColor,
161
- }]}>
162
- {this.props.children ? this.props.children :
163
- <Text style={[styles.text, this.state.textStyle]}>{this.props.percent}%</Text>}
164
- </View>
165
-
166
- </View>
167
- );
168
- }
169
- }
170
-
171
- // set some attributes default value
172
- PercentageCircle.defaultProps = {
173
- bgcolor: '#e3e3e3',
174
- innerColor: '#fff'
175
- };
176
-
177
- module.exports = PercentageCircle;
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import { StyleSheet, View, Modal, Text, ActivityIndicator } from 'react-native';
3
- import PercentageCircle from './PercentageCircle.js';
4
- import { isRTL } from 'muba-i18n';
5
- import commonStyles from '../commonStyles';
6
-
7
- const ProgressBar = props => {
8
- const {
9
- loading,
10
- progress,
11
- ...attributes
12
- } = props;
13
-
14
- return (
15
- <Modal transparent={true} animationType={'none'} visible={loading}>
16
- <View style={styles.modalBackground}>
17
- {isRTL() ?
18
- <View>
19
- <ActivityIndicator size="large" color="#ffffff" />
20
- <Text style={[commonStyles.percentage]}>{progress} %</Text>
21
- </View>
22
- :
23
- <PercentageCircle radius={50} percent={progress} color={"#00afca"} borderWidth={5} textStyle={{ fontSize: 22, fontFamily: 'PostingSemiBold', color: '#00afca', alignSelf: 'center' }}></PercentageCircle>
24
- }
25
- <View>
26
- {props.children}
27
- </View>
28
- </View>
29
- </Modal>
30
- )
31
- }
32
-
33
- const styles = StyleSheet.create({
34
- modalBackground: {
35
- flex: 1,
36
- alignItems: 'center',
37
- flexDirection: 'column',
38
- justifyContent: 'center',
39
- backgroundColor: '#00000080'
40
- }
41
- });
42
-
43
- export default ProgressBar;