project-booster-vue 9.52.0 → 9.54.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-booster-vue",
3
- "version": "9.52.0",
3
+ "version": "9.54.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -257,12 +257,16 @@ export default defineComponent({
257
257
  updateHeaderHeight() {
258
258
  this.headerHeight = this.$refs?.pbCitySearchHeader?.$el?.offsetHeight;
259
259
  },
260
- formatSuggestion(suggestion: google.maps.places.AutocompletePrediction) {
261
- let text = '';
262
- for (let i = 0; i < suggestion.terms.length - 1; i++) {
263
- text = `${text} ${suggestion.terms[i].value}`;
260
+ formatSuggestion(suggestion: any) {
261
+ if (suggestion.name) {
262
+ return suggestion.name;
263
+ } else {
264
+ let text = '';
265
+ for (let i = 0; i < suggestion.terms.length - 1; i++) {
266
+ text = `${text} ${suggestion.terms[i].value}`;
267
+ }
268
+ return text;
264
269
  }
265
- return text;
266
270
  },
267
271
  handleSearchKeywordChange() {
268
272
  this.updateHeaderHeight();
@@ -289,24 +293,39 @@ export default defineComponent({
289
293
  return;
290
294
  }
291
295
 
292
- const request = {
293
- input: this.searchKeyword,
294
- types: ['(regions)'],
295
- componentRestrictions: {
296
- country: 'fr',
297
- },
298
- };
299
-
300
296
  try {
301
- this.googlePlacesAutocompleteService?.getPlacePredictions(request, (results, status) => {
297
+ this.loadingSuggestions = false;
298
+ this.displaySuggestions = true;
299
+
300
+ if (Number.isNaN(parseInt(this.searchKeyword))) {
301
+ const request = {
302
+ input: this.searchKeyword,
303
+ types: ['(regions)'],
304
+ componentRestrictions: {
305
+ country: 'fr',
306
+ },
307
+ };
308
+
309
+ this.googlePlacesAutocompleteService?.getPlacePredictions(request, (results, status) => {
310
+ this.loadingSuggestions = false;
311
+ this.displaySuggestions = true;
312
+ if (status === 'OK') {
313
+ this.suggestions = results;
314
+ } else if (status === 'ZERO_RESULTS') {
315
+ this.suggestions = null;
316
+ }
317
+ });
318
+ } else {
319
+ const results = await this.getPlaceFromGeoGouvAPI(this.searchKeyword);
320
+
302
321
  this.loadingSuggestions = false;
303
322
  this.displaySuggestions = true;
304
- if (status === 'OK') {
323
+ if (results) {
305
324
  this.suggestions = results;
306
- } else if (status === 'ZERO_RESULTS') {
325
+ } else {
307
326
  this.suggestions = null;
308
327
  }
309
- });
328
+ }
310
329
  } catch (error) {
311
330
  console.error(`Could not get city search suggestions for ${this.searchKeyword}`, error);
312
331
  }
@@ -333,14 +352,10 @@ export default defineComponent({
333
352
  const selectedCity = results[0];
334
353
  this.suggestions = null;
335
354
 
336
- const placeData = await this.getPlaceFromGeoGouvAPI(
337
- selectedCity.geometry.location.lat(),
338
- selectedCity.geometry.location.lng(),
339
- );
355
+ const postalCode = selectedCity.address_components.filter((field) => field.types.includes('postal_code'))[0]
356
+ ?.short_name;
340
357
 
341
- const postalCode =
342
- selectedCity.address_components.filter((field) => field.types.includes('postal_code'))[0]?.short_name ||
343
- placeData.postalCode;
358
+ const placeData: any = await this.getPlaceFromGeoGouvAPI(postalCode);
344
359
 
345
360
  const region =
346
361
  selectedCity.address_components.filter((field) => field.types.includes('administrative_area_level_1'))[0]
@@ -374,22 +389,26 @@ export default defineComponent({
374
389
  ],
375
390
  });
376
391
  },
377
- async getPlaceFromGeoGouvAPI(lat: number, lng: number) {
392
+ async getPlaceFromGeoGouvAPI(codePostal: string) {
378
393
  const placeData = await axios.get('https://geo.api.gouv.fr/communes', {
379
394
  params: {
380
- lat: lat,
381
- lon: lng,
395
+ codePostal: codePostal,
382
396
  fields: 'nom,code,codesPostaux',
383
397
  format: 'json',
384
398
  geometry: 'centre',
385
399
  },
386
400
  });
401
+ let placeDataFormatted: any = [];
387
402
 
388
- return {
389
- inseeCode: placeData.data[0].code,
390
- postalCode: placeData.data[0].codesPostaux[0],
391
- name: placeData.data[0].nom,
392
- };
403
+ placeData.data.forEach((element: any) => {
404
+ placeDataFormatted.push({
405
+ inseeCode: element.code,
406
+ postalCode: element.codesPostaux[0],
407
+ name: element.nom,
408
+ });
409
+ });
410
+
411
+ return placeDataFormatted;
393
412
  },
394
413
  selectedCityToKeyword(): string {
395
414
  return this.selectedCity?.postalCode + ' ' + this.selectedCity?.name + ', ' + this.selectedCity?.region;
@@ -46,6 +46,11 @@ export default {
46
46
  switch (response.status) {
47
47
  case 200:
48
48
  case 201:
49
+ // 998 is status returned from trezor for duplicated leads
50
+ if (response.data.status == 998) {
51
+ return 'LEAD_DUPLICATED';
52
+ }
53
+
49
54
  return 'LEAD_CREATED_SUCCESSFULLY';
50
55
  case 400:
51
56
  return 'LEAD_CREATION_FAILED_DUE_TO_QUOTA';