@woosmap/ui 4.221.0 → 4.222.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 +108 -120
- package/src/components/Button/Button.js +2 -2
- package/src/components/Button/Button.stories.js +5 -5
- package/src/components/Button/Button.test.js +1 -1
- package/src/components/Button/ButtonSwitch.js +1 -1
- package/src/components/Button/ButtonWithDropdown.js +3 -3
- package/src/components/Button/ButtonWithDropdown.test.js +1 -1
- package/src/components/Card/Card.js +29 -29
- package/src/components/Card/Card.stories.js +6 -6
- package/src/components/Card/Card.test.js +1 -1
- package/src/components/Card/SimpleCard.js +2 -2
- package/src/components/Card/SimpleCard.test.js +1 -1
- package/src/components/CodeSnippet/CodeSnippet.stories.js +1 -1
- package/src/components/CodeSnippet/CodeSnippet.test.js +1 -1
- package/src/components/CopyClipboardButton/CopyClipboardButton.js +3 -3
- package/src/components/CopyClipboardButton/CopyToClipboard.stories.js +1 -1
- package/src/components/CopyClipboardButton/CopyToClipboard.test.js +1 -1
- package/src/components/DateTime/DateTime.stories.js +1 -1
- package/src/components/DateTime/DateTime.test.js +1 -1
- package/src/components/Demo/AddressDemo.js +10 -10
- package/src/components/Demo/AddressDemo.stories.js +1 -1
- package/src/components/Demo/AutocompleteAddressDemo.js +10 -10
- package/src/components/Demo/AutocompleteAddressDemo.stories.js +2 -2
- package/src/components/Demo/DistanceDemo.js +12 -12
- package/src/components/Demo/DistanceDemo.stories.js +1 -1
- package/src/components/Demo/DistanceDemo.test.js +1 -1
- package/src/components/Demo/GeolocationDemo.js +7 -7
- package/src/components/Demo/GeolocationDemo.stories.js +1 -1
- package/src/components/Demo/GeolocationDemo.test.js +1 -1
- package/src/components/Demo/LocalitiesAddressDemo.js +8 -8
- package/src/components/Demo/LocalitiesAddressDemo.stories.js +1 -1
- package/src/components/Demo/LocalitiesAllDemo.js +5 -5
- package/src/components/Demo/LocalitiesAllDemo.stories.js +1 -1
- package/src/components/Demo/LocalitiesDemo.js +10 -10
- package/src/components/Demo/LocalitiesDemo.stories.js +1 -1
- package/src/components/Demo/LocalitiesFRAddressDemo.js +239 -261
- package/src/components/Demo/LocalitiesFRAddressDemo.stories.js +2 -2
- package/src/components/Demo/LocalitiesUKAddressDemo.js +271 -294
- package/src/components/Demo/LocalitiesUKAddressDemo.stories.js +1 -1
- package/src/components/Demo/MapDemo.js +231 -233
- package/src/components/Demo/MapDemo.stories.js +1 -1
- package/src/components/Demo/SearchDemo.js +9 -9
- package/src/components/Demo/SearchDemo.stories.js +1 -1
- package/src/components/Demo/SearchDemo.test.js +1 -1
- package/src/components/Demo/Showcase.stories.js +7 -7
- package/src/components/Demo/SkeletonDemo.js +8 -8
- package/src/components/Demo/SkeletonDemo.stories.js +2 -2
- package/src/components/Demo/SkeletonDemo.test.js +2 -2
- package/src/components/Demo/W3WDemo.js +9 -9
- package/src/components/Demo/W3WDemo.stories.js +2 -2
- package/src/components/Dropdown/Dropdown.js +4 -4
- package/src/components/Dropdown/Dropdown.stories.js +1 -1
- package/src/components/Dropdown/Dropdown.test.js +1 -1
- package/src/components/DynamicTag/DynamicTag.js +5 -5
- package/src/components/DynamicTag/DynamicTag.stories.js +1 -1
- package/src/components/DynamicTag/DynamicTag.test.js +1 -1
- package/src/components/Flash/Flash.js +1 -1
- package/src/components/Flash/Flash.stories.js +1 -1
- package/src/components/Flash/Flash.test.js +1 -1
- package/src/components/Icon/Icon.js +409 -409
- package/src/components/Icon/Icon.stories.js +1 -1
- package/src/components/Icon/Icon.test.js +1 -1
- package/src/components/Icon/WebSiteIcon.js +231 -231
- package/src/components/InfoMessage/Flash.js +1 -1
- package/src/components/InfoMessage/InfoMessage.js +2 -2
- package/src/components/InfoMessage/InfoMessage.stories.js +1 -1
- package/src/components/InfoMessage/InfoMessage.test.js +1 -1
- package/src/components/Input/Input.js +2 -2
- package/src/components/Input/Input.password.test.js +1 -1
- package/src/components/Input/Input.stories.js +1 -1
- package/src/components/Input/Input.test.js +1 -1
- package/src/components/Label/Label.js +1 -1
- package/src/components/Label/Label.stories.js +1 -1
- package/src/components/Label/Label.test.js +1 -1
- package/src/components/Map/InfoWindow.test.js +1 -1
- package/src/components/Map/Map.stories.js +3 -3
- package/src/components/Map/Marker.test.js +1 -1
- package/src/components/Map/drawOnMap.test.js +2 -10
- package/src/components/Modal/ConfirmationModal.js +2 -2
- package/src/components/Modal/ConfirmationModal.test.js +1 -1
- package/src/components/Modal/Modal.js +6 -6
- package/src/components/Modal/Modal.stories.js +3 -3
- package/src/components/Modal/Modal.test.js +1 -1
- package/src/components/OfflineChatBot/OfflineChatBot.js +4 -4
- package/src/components/OfflineChatBot/OfflineChatBot.stories.js +2 -2
- package/src/components/Panel/Panel.js +2 -2
- package/src/components/Panel/Panel.stories.js +2 -2
- package/src/components/Panel/Panel.test.js +1 -1
- package/src/components/PasswordStrengthBar/PasswordStrengthBar.stories.js +1 -1
- package/src/components/PasswordStrengthBar/PasswordStrengthBar.test.js +1 -1
- package/src/components/Popover/ConfirmationPopover.js +3 -3
- package/src/components/Popover/ConfirmationPopover.test.js +1 -1
- package/src/components/Popover/Popover.js +1 -1
- package/src/components/Popover/Popover.stories.js +3 -3
- package/src/components/Popover/Popover.test.js +2 -2
- package/src/components/PricingSlider/PricingData.js +97 -107
- package/src/components/PricingSlider/PricingSimulator.js +3 -3
- package/src/components/PricingSlider/PricingSimulator.stories.js +1 -1
- package/src/components/PricingSlider/PricingSlider.js +4 -5
- package/src/components/ProgressBar/ProgressBar.js +1 -1
- package/src/components/ProgressBar/ProgressBar.stories.js +1 -1
- package/src/components/ProgressBar/ProgressBar.test.js +1 -1
- package/src/components/ScrollBar/ScrollBar.stories.js +1 -1
- package/src/components/ScrollBar/ScrollBar.test.js +1 -1
- package/src/components/Select/Select.stories.js +4 -4
- package/src/components/Select/TagSelect.test.js +1 -1
- package/src/components/ServiceMessage/ServiceMessage.js +1 -1
- package/src/components/ServiceMessage/ServiceMessage.stories.js +2 -2
- package/src/components/SnackBar/SnackBar.js +2 -2
- package/src/components/SnackBar/SnackBar.stories.js +3 -3
- package/src/components/SnackBar/SnackBar.test.js +3 -3
- package/src/components/SnackBar/withSnackBar.js +1 -1
- package/src/components/Stepper/Stepper.js +2 -2
- package/src/components/Stepper/Stepper.stories.js +1 -1
- package/src/components/Switch/Switch.stories.js +1 -1
- package/src/components/Switch/Switch.test.js +1 -1
- package/src/components/Tab/Tab.js +1 -1
- package/src/components/Tab/Tab.stories.js +1 -1
- package/src/components/Tooltip/Tooltip.stories.js +1 -1
- package/src/components/Tooltip/Tooltip.test.js +1 -1
- package/src/components/UseCase/UseCase.js +9 -9
- package/src/components/UseCase/UseCase.stories.js +4 -4
- package/src/components/Woosmap/AddressAutocomplete.js +3 -3
- package/src/components/Woosmap/LocalitiesAutocomplete.js +1 -1
- package/src/components/Woosmap/Woosmap.stories.js +3 -3
- package/src/components/utils/Script.test.js +1 -1
- package/src/components/utils/locale.js +2 -2
- package/src/components/withClickOutside/withClickOutside.test.js +1 -1
- package/src/components/withFormValidation/withFormValidation.js +2 -2
- package/src/components/withFormValidation/withFormValidation.stories.js +2 -2
- package/src/components/withFormValidation/withFormValidation.test.js +2 -2
- package/src/index.js +61 -61
- package/src/locales/en/translation.json +143 -128
- package/src/locales/fr/translation.json +143 -128
- package/src/styles/console/pricing-slider-back.styl +593 -0
- package/src/website.js +25 -25
- package/craco.config.js +0 -9
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import React, { Component } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import markerIcon from '
|
|
6
|
-
import markerGeolocationIcon from '
|
|
7
|
-
import Demo from '
|
|
8
|
-
import Constants from '
|
|
9
|
-
import { tr } from '
|
|
10
|
-
import Input from '
|
|
11
|
-
import { WoosmapMapBoundingBox, woosmapBoundsFromViewport, createWoosmapMap } from '
|
|
5
|
+
import markerIcon from '../../images/marker-dot.svg';
|
|
6
|
+
import markerGeolocationIcon from '../../images/marker-alt.png';
|
|
7
|
+
import Demo from './SkeletonDemo';
|
|
8
|
+
import Constants from '../../Constants';
|
|
9
|
+
import { tr } from '../utils/locale';
|
|
10
|
+
import Input from '../Input/Input';
|
|
11
|
+
import { WoosmapMapBoundingBox, woosmapBoundsFromViewport, createWoosmapMap } from '../Map/drawOnMap';
|
|
12
12
|
|
|
13
13
|
export default class GeolocationDemo extends Component {
|
|
14
14
|
constructor(props) {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
|
|
5
|
-
import GeolocationDemo from '
|
|
5
|
+
import GeolocationDemo from './GeolocationDemo';
|
|
6
6
|
|
|
7
7
|
it('render geolocation demo', () => {
|
|
8
8
|
const { container } = render(<GeolocationDemo />);
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import markerIcon from '
|
|
6
|
-
import Demo from '
|
|
7
|
-
import Constants from '
|
|
8
|
-
import AddressAutocomplete from '
|
|
9
|
-
import CountrySelect from '
|
|
10
|
-
import Input from '
|
|
11
|
-
import { tr } from '
|
|
12
|
-
import { createWoosmapMap } from '
|
|
5
|
+
import markerIcon from '../../images/marker.png';
|
|
6
|
+
import Demo from './SkeletonDemo';
|
|
7
|
+
import Constants from '../../Constants';
|
|
8
|
+
import AddressAutocomplete from '../Woosmap/AddressAutocomplete';
|
|
9
|
+
import CountrySelect from '../Select/CountrySelect';
|
|
10
|
+
import Input from '../Input/Input';
|
|
11
|
+
import { tr } from '../utils/locale';
|
|
12
|
+
import { createWoosmapMap } from '../Map/drawOnMap';
|
|
13
13
|
|
|
14
14
|
export default class LocalitiesAddressDemo extends Component {
|
|
15
15
|
constructor(props) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
-
import LocalitiesDemo from '
|
|
4
|
-
import Button from '
|
|
5
|
-
import ButtonGroup from '
|
|
6
|
-
import { tr } from '
|
|
7
|
-
import LocalitiesAddressDemo from '
|
|
3
|
+
import LocalitiesDemo from './LocalitiesDemo';
|
|
4
|
+
import Button from '../Button/Button';
|
|
5
|
+
import ButtonGroup from '../Button/ButtonGroup';
|
|
6
|
+
import { tr } from '../utils/locale';
|
|
7
|
+
import LocalitiesAddressDemo from './LocalitiesAddressDemo';
|
|
8
8
|
|
|
9
9
|
export default class LocalitiesAllDemo extends Component {
|
|
10
10
|
constructor(props) {
|
|
@@ -3,16 +3,16 @@ import axios from 'axios';
|
|
|
3
3
|
import cl from 'classnames';
|
|
4
4
|
import React, { Component } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import Demo from '
|
|
7
|
-
import Select from '
|
|
8
|
-
import Button from '
|
|
9
|
-
import ButtonGroup from '
|
|
10
|
-
import LocalitiesAutocomplete from '
|
|
11
|
-
import CountrySelect, { countriesOptions } from '
|
|
12
|
-
import Constants from '
|
|
13
|
-
import { tr } from '
|
|
14
|
-
import { WoosmapMapBoundingBox, createWoosmapMap } from '
|
|
15
|
-
import markerIcon from '
|
|
6
|
+
import Demo from './SkeletonDemo';
|
|
7
|
+
import Select from '../Select/Select';
|
|
8
|
+
import Button from '../Button/Button';
|
|
9
|
+
import ButtonGroup from '../Button/ButtonGroup';
|
|
10
|
+
import LocalitiesAutocomplete from '../Woosmap/LocalitiesAutocomplete';
|
|
11
|
+
import CountrySelect, { countriesOptions } from '../Select/CountrySelect';
|
|
12
|
+
import Constants from '../../Constants';
|
|
13
|
+
import { tr } from '../utils/locale';
|
|
14
|
+
import { WoosmapMapBoundingBox, createWoosmapMap } from '../Map/drawOnMap';
|
|
15
|
+
import markerIcon from '../../images/marker.png';
|
|
16
16
|
|
|
17
17
|
const languages = [
|
|
18
18
|
{ value: 'fr', label: 'French' },
|
|
@@ -1,283 +1,261 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import React, { Component } from 'react';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
4
|
+
import { changeLanguage } from '../utils/locale';
|
|
5
|
+
import Demo from './SkeletonDemo';
|
|
6
|
+
import LocalitiesAutocomplete from '../Woosmap/LocalitiesAutocomplete';
|
|
7
|
+
import Constants from '../../Constants';
|
|
8
|
+
import { tr } from '../utils/locale';
|
|
9
|
+
import Input from '../Input/Input';
|
|
9
10
|
|
|
10
11
|
export default class LocalitiesDemo extends Component {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
error: null,
|
|
34
|
-
input: "",
|
|
35
|
-
localitiesTypes: [{ label: "Address", value: "address" }],
|
|
36
|
-
countries: [{ label: "FR", value: "fr" }],
|
|
37
|
-
language: "fr",
|
|
38
|
-
};
|
|
39
|
-
this.types = types.map((item) => ({
|
|
40
|
-
label: item.label,
|
|
41
|
-
value: item.value,
|
|
42
|
-
}));
|
|
43
|
-
this.mounted = true;
|
|
44
|
-
this.viewport = null;
|
|
45
|
-
this.requestUrl = "https://api.woosmap.com/localities/autocomplete/";
|
|
46
|
-
this.requestDetailsUrl = "https://api.woosmap.com/localities/details/";
|
|
47
|
-
this.inputRef = React.createRef();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
componentDidMount() {
|
|
51
|
-
this.requestLocalities();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
componentWillUnmount() {
|
|
55
|
-
this.mounted = false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
requestLocalities = () => {
|
|
59
|
-
axios
|
|
60
|
-
.get(this.requestUrl, {
|
|
61
|
-
params: this.getRequestparams(),
|
|
62
|
-
})
|
|
63
|
-
.then((response) => {
|
|
64
|
-
if (this.mounted) {
|
|
65
|
-
this.setState({
|
|
66
|
-
localities: response.data,
|
|
67
|
-
error: null,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
.catch((error) => {
|
|
72
|
-
const errorResult =
|
|
73
|
-
(error && error.response && error.response.data) || "Unhandled error";
|
|
74
|
-
this.setState({ error: errorResult });
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
requestLocalityDetails = (publicId) => {
|
|
79
|
-
axios
|
|
80
|
-
.get(this.requestDetailsUrl, {
|
|
81
|
-
params: {
|
|
82
|
-
public_id: publicId,
|
|
83
|
-
key: Constants.woosmapKey,
|
|
84
|
-
language: "fr",
|
|
85
|
-
},
|
|
86
|
-
})
|
|
87
|
-
.then((response) => {
|
|
88
|
-
if (this.mounted) {
|
|
89
|
-
this.setState({
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
const types = [
|
|
15
|
+
{ label: tr('Localities'), value: 'locality' },
|
|
16
|
+
{ label: tr('Postal codes'), value: 'postal_code' },
|
|
17
|
+
{
|
|
18
|
+
label: tr('Administrative areas (States, regions, ...)'),
|
|
19
|
+
value: 'admin_level',
|
|
20
|
+
},
|
|
21
|
+
{ label: tr('Airports'), value: 'airport' },
|
|
22
|
+
{ label: tr('Train stations'), value: 'train_station' },
|
|
23
|
+
{ label: tr('Metro stations'), value: 'metro_station' },
|
|
24
|
+
{ label: tr('Shopping centers'), value: 'shopping' },
|
|
25
|
+
{ label: tr('Museums'), value: 'museum' },
|
|
26
|
+
{ label: tr('Tourist attractions'), value: 'tourist_attraction' },
|
|
27
|
+
{ label: tr('Amusement parks'), value: 'amusement_park' },
|
|
28
|
+
{ label: tr('Art galleries'), value: 'art_gallery' },
|
|
29
|
+
{ label: tr('Zoos'), value: 'zoo' },
|
|
30
|
+
];
|
|
31
|
+
this.state = {
|
|
32
|
+
localities: null,
|
|
33
|
+
selectedLocality: null,
|
|
90
34
|
error: null,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (selectedLocality) {
|
|
106
|
-
return {
|
|
107
|
-
key: Constants.woosmapKey,
|
|
108
|
-
public_id: selectedLocality.public_id,
|
|
109
|
-
};
|
|
35
|
+
input: '',
|
|
36
|
+
localitiesTypes: [{ label: 'Address', value: 'address' }],
|
|
37
|
+
countries: [{ label: 'FR', value: 'fr' }],
|
|
38
|
+
language: 'fr',
|
|
39
|
+
};
|
|
40
|
+
this.types = types.map((item) => ({
|
|
41
|
+
label: item.label,
|
|
42
|
+
value: item.value,
|
|
43
|
+
}));
|
|
44
|
+
this.mounted = true;
|
|
45
|
+
this.viewport = null;
|
|
46
|
+
this.requestUrl = 'https://api.woosmap.com/localities/autocomplete/';
|
|
47
|
+
this.requestDetailsUrl = 'https://api.woosmap.com/localities/details/';
|
|
48
|
+
this.inputRef = React.createRef();
|
|
110
49
|
}
|
|
111
|
-
return {
|
|
112
|
-
key: Constants.woosmapKey,
|
|
113
|
-
input,
|
|
114
|
-
language,
|
|
115
|
-
types: localitiesTypes.map((item) => item.value).join("|"),
|
|
116
|
-
components: countries.map((item) => `country:${item.value}`).join("|"),
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
50
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this.requestLocalityDetails(locality.public_id);
|
|
123
|
-
} else {
|
|
124
|
-
this.setState({
|
|
125
|
-
error: null,
|
|
126
|
-
selectedLocality: null,
|
|
127
|
-
});
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
this.requestLocalities();
|
|
128
53
|
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
getHighlightedLocalityDesc = (locality) => {
|
|
132
|
-
let { description } = locality;
|
|
133
54
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
locality.matched_substrings.description
|
|
137
|
-
) {
|
|
138
|
-
for (
|
|
139
|
-
let j = locality.matched_substrings.description.length - 1;
|
|
140
|
-
j >= 0;
|
|
141
|
-
j--
|
|
142
|
-
) {
|
|
143
|
-
const match = locality.matched_substrings.description[j];
|
|
144
|
-
description = `${description.substring(
|
|
145
|
-
0,
|
|
146
|
-
match.offset,
|
|
147
|
-
)}<span class="localities-matched">${description.substring(
|
|
148
|
-
match.offset,
|
|
149
|
-
match.offset + match.length,
|
|
150
|
-
)}</span>${description.substring(match.offset + match.length)}`;
|
|
151
|
-
}
|
|
55
|
+
componentWillUnmount() {
|
|
56
|
+
this.mounted = false;
|
|
152
57
|
}
|
|
153
|
-
// eslint-disable-next-line react/no-danger
|
|
154
|
-
return <div dangerouslySetInnerHTML={{ __html: description }} />;
|
|
155
|
-
};
|
|
156
58
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
59
|
+
requestLocalities = () => {
|
|
60
|
+
axios
|
|
61
|
+
.get(this.requestUrl, {
|
|
62
|
+
params: this.getRequestparams(),
|
|
63
|
+
})
|
|
64
|
+
.then((response) => {
|
|
65
|
+
if (this.mounted) {
|
|
66
|
+
this.setState({
|
|
67
|
+
localities: response.data,
|
|
68
|
+
error: null,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
.catch((error) => {
|
|
73
|
+
const errorResult = (error && error.response && error.response.data) || 'Unhandled error';
|
|
74
|
+
this.setState({ error: errorResult });
|
|
75
|
+
});
|
|
172
76
|
};
|
|
173
|
-
return [inputFilter];
|
|
174
|
-
};
|
|
175
77
|
|
|
176
|
-
|
|
78
|
+
requestLocalityDetails = (publicId) => {
|
|
79
|
+
axios
|
|
80
|
+
.get(this.requestDetailsUrl, {
|
|
81
|
+
params: {
|
|
82
|
+
public_id: publicId,
|
|
83
|
+
key: Constants.woosmapKey,
|
|
84
|
+
language: 'fr',
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
.then((response) => {
|
|
88
|
+
if (this.mounted) {
|
|
89
|
+
this.setState({
|
|
90
|
+
error: null,
|
|
91
|
+
selectedLocality: response.data.result,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
.catch((error) => {
|
|
96
|
+
const errorResult = (error && error.response && error.response.data) || 'Unhandled error';
|
|
97
|
+
this.setState({ error: errorResult });
|
|
98
|
+
});
|
|
99
|
+
};
|
|
177
100
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
let shippingAddress = "";
|
|
187
|
-
let postcode = "";
|
|
188
|
-
let locality = "";
|
|
189
|
-
let country = "";
|
|
190
|
-
addressComponents.forEach((component) => {
|
|
191
|
-
const [componentType] = component.types;
|
|
192
|
-
switch (componentType) {
|
|
193
|
-
case "street_number": {
|
|
194
|
-
shippingAddress = `${component.long_name} ${shippingAddress}`;
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
case "route": {
|
|
198
|
-
shippingAddress += component.short_name;
|
|
199
|
-
break;
|
|
101
|
+
getRequestparams = () => {
|
|
102
|
+
const { input, language, localitiesTypes, countries, selectedLocality } = this.state;
|
|
103
|
+
if (selectedLocality) {
|
|
104
|
+
return {
|
|
105
|
+
key: Constants.woosmapKey,
|
|
106
|
+
public_id: selectedLocality.public_id,
|
|
107
|
+
};
|
|
200
108
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
109
|
+
return {
|
|
110
|
+
key: Constants.woosmapKey,
|
|
111
|
+
input,
|
|
112
|
+
language,
|
|
113
|
+
types: localitiesTypes.map((item) => item.value).join('|'),
|
|
114
|
+
components: countries.map((item) => `country:${item.value}`).join('|'),
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
selectLocality = (locality) => {
|
|
119
|
+
if (locality) {
|
|
120
|
+
this.requestLocalityDetails(locality.public_id);
|
|
121
|
+
} else {
|
|
122
|
+
this.setState({
|
|
123
|
+
error: null,
|
|
124
|
+
selectedLocality: null,
|
|
125
|
+
});
|
|
208
126
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
getHighlightedLocalityDesc = (locality) => {
|
|
130
|
+
let { description } = locality;
|
|
131
|
+
|
|
132
|
+
if (locality.matched_substrings && locality.matched_substrings.description) {
|
|
133
|
+
for (let j = locality.matched_substrings.description.length - 1; j >= 0; j--) {
|
|
134
|
+
const match = locality.matched_substrings.description[j];
|
|
135
|
+
description = `${description.substring(
|
|
136
|
+
0,
|
|
137
|
+
match.offset
|
|
138
|
+
)}<span class="localities-matched">${description.substring(
|
|
139
|
+
match.offset,
|
|
140
|
+
match.offset + match.length
|
|
141
|
+
)}</span>${description.substring(match.offset + match.length)}`;
|
|
142
|
+
}
|
|
215
143
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
});
|
|
144
|
+
// eslint-disable-next-line react/no-danger
|
|
145
|
+
return <div dangerouslySetInnerHTML={{ __html: description }} />;
|
|
146
|
+
};
|
|
220
147
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
value={locality}
|
|
242
|
-
placeholder="Ville"
|
|
243
|
-
onChange={() => {}}
|
|
244
|
-
/>
|
|
245
|
-
<div className="demo__input-container--inline">
|
|
246
|
-
<Input
|
|
247
|
-
className="fullw"
|
|
248
|
-
label="Code postal"
|
|
249
|
-
placeholder="Postal code"
|
|
250
|
-
value={postcode}
|
|
251
|
-
onChange={() => {}}
|
|
252
|
-
/>
|
|
253
|
-
</div>
|
|
254
|
-
<Input
|
|
255
|
-
label="Pays"
|
|
256
|
-
placeholder="Pays"
|
|
257
|
-
value={country}
|
|
258
|
-
onChange={() => {}}
|
|
259
|
-
/>
|
|
260
|
-
</div>
|
|
261
|
-
);
|
|
262
|
-
};
|
|
148
|
+
renderHeaderFilters = () => {
|
|
149
|
+
const inputFilter = {
|
|
150
|
+
label: 'Saisir une adresse française',
|
|
151
|
+
component: (
|
|
152
|
+
<LocalitiesAutocomplete
|
|
153
|
+
inputRef={this.inputRef}
|
|
154
|
+
woosmapKey={Constants.woosmapKey}
|
|
155
|
+
placeholder="Saisir une adresse"
|
|
156
|
+
defaultLocality={this.defaultOrigin}
|
|
157
|
+
language="fr"
|
|
158
|
+
components="country:fr"
|
|
159
|
+
types="address"
|
|
160
|
+
callback={this.selectLocality}
|
|
161
|
+
/>
|
|
162
|
+
),
|
|
163
|
+
};
|
|
164
|
+
return [inputFilter];
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
renderFooterFilters = () => [];
|
|
263
168
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
className="demo--localities--fr"
|
|
271
|
-
footerFilters={this.renderFooterFilters()}
|
|
272
|
-
headerFilters={this.renderHeaderFilters()}
|
|
273
|
-
request={selectedLocality ? this.requestDetailsUrl : this.requestUrl}
|
|
274
|
-
params={this.getRequestparams()}
|
|
275
|
-
referer="http://localhost/"
|
|
276
|
-
response={
|
|
277
|
-
error || selectedLocality ? { result: selectedLocality } : localities
|
|
169
|
+
renderAddress = () => {
|
|
170
|
+
const { selectedLocality } = this.state;
|
|
171
|
+
let addressComponents = [];
|
|
172
|
+
const hasComponents = selectedLocality && selectedLocality.address_components;
|
|
173
|
+
if (hasComponents) {
|
|
174
|
+
addressComponents = selectedLocality.address_components;
|
|
278
175
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
176
|
+
let shippingAddress = '';
|
|
177
|
+
let postcode = '';
|
|
178
|
+
let locality = '';
|
|
179
|
+
let country = '';
|
|
180
|
+
addressComponents.forEach((component) => {
|
|
181
|
+
const [componentType] = component.types;
|
|
182
|
+
switch (componentType) {
|
|
183
|
+
case 'street_number': {
|
|
184
|
+
shippingAddress = `${component.long_name} ${shippingAddress}`;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case 'route': {
|
|
188
|
+
shippingAddress += component.short_name;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case 'postal_codes': {
|
|
192
|
+
postcode = `${component.long_name}${postcode}`;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case 'postal_code_suffix': {
|
|
196
|
+
postcode = `${postcode}-${component.long_name}`;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case 'locality':
|
|
200
|
+
locality = component.long_name;
|
|
201
|
+
break;
|
|
202
|
+
case 'country': {
|
|
203
|
+
country = component.long_name;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
default:
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<div className="demo--localities--uk__formcontainer">
|
|
213
|
+
{!hasComponents && (
|
|
214
|
+
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
215
|
+
<div
|
|
216
|
+
role="button"
|
|
217
|
+
className="overlay"
|
|
218
|
+
onClick={() => {
|
|
219
|
+
this.inputRef.current.focus();
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
<Input
|
|
224
|
+
label="Numéro et nom de rue"
|
|
225
|
+
placeholder="Numéro et nom de rue"
|
|
226
|
+
value={shippingAddress}
|
|
227
|
+
onChange={() => {}}
|
|
228
|
+
/>
|
|
229
|
+
<Input label="Ville" value={locality} placeholder="Ville" onChange={() => {}} />
|
|
230
|
+
<div className="demo__input-container--inline">
|
|
231
|
+
<Input
|
|
232
|
+
className="fullw"
|
|
233
|
+
label="Code postal"
|
|
234
|
+
placeholder="Postal code"
|
|
235
|
+
value={postcode}
|
|
236
|
+
onChange={() => {}}
|
|
237
|
+
/>
|
|
238
|
+
</div>
|
|
239
|
+
<Input label="Pays" placeholder="Pays" value={country} onChange={() => {}} />
|
|
240
|
+
</div>
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
render() {
|
|
245
|
+
const { localities, error, selectedLocality } = this.state;
|
|
246
|
+
return (
|
|
247
|
+
<Demo
|
|
248
|
+
noheader
|
|
249
|
+
id="localities-demo-fr"
|
|
250
|
+
className="demo--localities--fr"
|
|
251
|
+
footerFilters={this.renderFooterFilters()}
|
|
252
|
+
headerFilters={this.renderHeaderFilters()}
|
|
253
|
+
request={selectedLocality ? this.requestDetailsUrl : this.requestUrl}
|
|
254
|
+
params={this.getRequestparams()}
|
|
255
|
+
referer="http://localhost/"
|
|
256
|
+
response={error || selectedLocality ? { result: selectedLocality } : localities}
|
|
257
|
+
result={this.renderAddress()}
|
|
258
|
+
/>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
283
261
|
}
|