@woosmap/ui 4.220.10 → 4.220.13
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/.eslintrc +0 -10
- package/.storybook/main.js +0 -7
- package/package.json +3 -11
- 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.styl +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/Map/marker.styl +2 -2
- 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 +94 -113
- package/src/components/PricingSlider/PricingSimulator.js +132 -90
- package/src/components/PricingSlider/PricingSimulator.stories.js +1 -1
- package/src/components/PricingSlider/PricingSlider.js +9 -10
- 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/UseCase/UseCase.styl +8 -8
- 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/commons/flags.styl +1 -1
- package/src/styles/console/button.styl +3 -3
- package/src/styles/console/{pricing-slider.styl → pricing-slider-back.styl} +48 -21
- package/src/styles/style-console.styl +1 -2
- package/src/website.js +25 -25
- package/craco.config.js +0 -9
|
@@ -1,317 +1,294 @@
|
|
|
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: [
|
|
37
|
-
{ label: "UK", value: "gb" },
|
|
38
|
-
{ label: "JE", value: "je" },
|
|
39
|
-
{ label: "GG", value: "gg" },
|
|
40
|
-
{ label: "IM", value: "im" },
|
|
41
|
-
],
|
|
42
|
-
language: "en",
|
|
43
|
-
};
|
|
44
|
-
this.types = types.map((item) => ({
|
|
45
|
-
label: item.label,
|
|
46
|
-
value: item.value,
|
|
47
|
-
}));
|
|
48
|
-
this.mounted = true;
|
|
49
|
-
this.viewport = null;
|
|
50
|
-
this.requestUrl = "https://api.woosmap.com/localities/autocomplete/";
|
|
51
|
-
this.requestDetailsUrl = "https://api.woosmap.com/localities/details/";
|
|
52
|
-
this.inputRef = React.createRef();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
componentDidMount() {
|
|
56
|
-
this.requestLocalities();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
componentWillUnmount() {
|
|
60
|
-
this.mounted = false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
requestLocalities = () => {
|
|
64
|
-
axios
|
|
65
|
-
.get(this.requestUrl, {
|
|
66
|
-
params: this.getRequestparams(),
|
|
67
|
-
})
|
|
68
|
-
.then((response) => {
|
|
69
|
-
if (this.mounted) {
|
|
70
|
-
this.setState({
|
|
71
|
-
localities: response.data,
|
|
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,
|
|
72
34
|
error: null,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.then((response) => {
|
|
93
|
-
if (this.mounted) {
|
|
94
|
-
this.setState({
|
|
95
|
-
error: null,
|
|
96
|
-
selectedLocality: response.data.result,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
.catch((error) => {
|
|
101
|
-
const errorResult =
|
|
102
|
-
(error && error.response && error.response.data) || "Unhandled error";
|
|
103
|
-
this.setState({ error: errorResult });
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
getRequestparams = () => {
|
|
108
|
-
const { input, language, localitiesTypes, countries, selectedLocality } =
|
|
109
|
-
this.state;
|
|
110
|
-
if (selectedLocality) {
|
|
111
|
-
return {
|
|
112
|
-
key: Constants.woosmapKey,
|
|
113
|
-
public_id: selectedLocality.public_id,
|
|
114
|
-
};
|
|
35
|
+
input: '',
|
|
36
|
+
localitiesTypes: [{ label: 'Address', value: 'address' }],
|
|
37
|
+
countries: [
|
|
38
|
+
{ label: 'UK', value: 'gb' },
|
|
39
|
+
{ label: 'JE', value: 'je' },
|
|
40
|
+
{ label: 'GG', value: 'gg' },
|
|
41
|
+
{ label: 'IM', value: 'im' },
|
|
42
|
+
],
|
|
43
|
+
language: 'en',
|
|
44
|
+
};
|
|
45
|
+
this.types = types.map((item) => ({
|
|
46
|
+
label: item.label,
|
|
47
|
+
value: item.value,
|
|
48
|
+
}));
|
|
49
|
+
this.mounted = true;
|
|
50
|
+
this.viewport = null;
|
|
51
|
+
this.requestUrl = 'https://api.woosmap.com/localities/autocomplete/';
|
|
52
|
+
this.requestDetailsUrl = 'https://api.woosmap.com/localities/details/';
|
|
53
|
+
this.inputRef = React.createRef();
|
|
115
54
|
}
|
|
116
|
-
return {
|
|
117
|
-
key: Constants.woosmapKey,
|
|
118
|
-
input,
|
|
119
|
-
language,
|
|
120
|
-
types: localitiesTypes.map((item) => item.value).join("|"),
|
|
121
|
-
components: countries.map((item) => `country:${item.value}`).join("|"),
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
55
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.requestLocalityDetails(locality.public_id);
|
|
128
|
-
} else {
|
|
129
|
-
this.setState({
|
|
130
|
-
error: null,
|
|
131
|
-
selectedLocality: null,
|
|
132
|
-
});
|
|
56
|
+
componentDidMount() {
|
|
57
|
+
this.requestLocalities();
|
|
133
58
|
}
|
|
134
|
-
};
|
|
135
59
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (
|
|
140
|
-
locality.matched_substrings &&
|
|
141
|
-
locality.matched_substrings.description
|
|
142
|
-
) {
|
|
143
|
-
for (
|
|
144
|
-
let j = locality.matched_substrings.description.length - 1;
|
|
145
|
-
j >= 0;
|
|
146
|
-
j--
|
|
147
|
-
) {
|
|
148
|
-
const match = locality.matched_substrings.description[j];
|
|
149
|
-
description = `${description.substring(
|
|
150
|
-
0,
|
|
151
|
-
match.offset,
|
|
152
|
-
)}<span class="localities-matched">${description.substring(
|
|
153
|
-
match.offset,
|
|
154
|
-
match.offset + match.length,
|
|
155
|
-
)}</span>${description.substring(match.offset + match.length)}`;
|
|
156
|
-
}
|
|
60
|
+
componentWillUnmount() {
|
|
61
|
+
this.mounted = false;
|
|
157
62
|
}
|
|
158
|
-
// eslint-disable-next-line react/no-danger
|
|
159
|
-
return <div dangerouslySetInnerHTML={{ __html: description }} />;
|
|
160
|
-
};
|
|
161
63
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
64
|
+
requestLocalities = () => {
|
|
65
|
+
axios
|
|
66
|
+
.get(this.requestUrl, {
|
|
67
|
+
params: this.getRequestparams(),
|
|
68
|
+
})
|
|
69
|
+
.then((response) => {
|
|
70
|
+
if (this.mounted) {
|
|
71
|
+
this.setState({
|
|
72
|
+
localities: response.data,
|
|
73
|
+
error: null,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.catch((error) => {
|
|
78
|
+
const errorResult = (error && error.response && error.response.data) || 'Unhandled error';
|
|
79
|
+
this.setState({ error: errorResult });
|
|
80
|
+
});
|
|
177
81
|
};
|
|
178
|
-
return [inputFilter];
|
|
179
|
-
};
|
|
180
82
|
|
|
181
|
-
|
|
83
|
+
requestLocalityDetails = (publicId) => {
|
|
84
|
+
axios
|
|
85
|
+
.get(this.requestDetailsUrl, {
|
|
86
|
+
params: {
|
|
87
|
+
public_id: publicId,
|
|
88
|
+
key: Constants.woosmapKey,
|
|
89
|
+
language: 'en',
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
.then((response) => {
|
|
93
|
+
if (this.mounted) {
|
|
94
|
+
this.setState({
|
|
95
|
+
error: null,
|
|
96
|
+
selectedLocality: response.data.result,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
.catch((error) => {
|
|
101
|
+
const errorResult = (error && error.response && error.response.data) || 'Unhandled error';
|
|
102
|
+
this.setState({ error: errorResult });
|
|
103
|
+
});
|
|
104
|
+
};
|
|
182
105
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
let shippingAddress = "";
|
|
192
|
-
let shippingAddress2 = "";
|
|
193
|
-
let postcode = "";
|
|
194
|
-
let locality = "";
|
|
195
|
-
let state = "";
|
|
196
|
-
let country = "";
|
|
197
|
-
addressComponents.forEach((component) => {
|
|
198
|
-
const [componentType] = component.types;
|
|
199
|
-
switch (componentType) {
|
|
200
|
-
case "street_number": {
|
|
201
|
-
shippingAddress = `${component.long_name} ${shippingAddress}`;
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
case "route": {
|
|
205
|
-
shippingAddress += component.short_name;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
case "postal_codes": {
|
|
209
|
-
postcode = `${component.long_name}${postcode}`;
|
|
210
|
-
break;
|
|
106
|
+
getRequestparams = () => {
|
|
107
|
+
const { input, language, localitiesTypes, countries, selectedLocality } = this.state;
|
|
108
|
+
if (selectedLocality) {
|
|
109
|
+
return {
|
|
110
|
+
key: Constants.woosmapKey,
|
|
111
|
+
public_id: selectedLocality.public_id,
|
|
112
|
+
};
|
|
211
113
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
114
|
+
return {
|
|
115
|
+
key: Constants.woosmapKey,
|
|
116
|
+
input,
|
|
117
|
+
language,
|
|
118
|
+
types: localitiesTypes.map((item) => item.value).join('|'),
|
|
119
|
+
components: countries.map((item) => `country:${item.value}`).join('|'),
|
|
120
|
+
};
|
|
121
|
+
};
|
|
219
122
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
case "country": {
|
|
229
|
-
country = component.long_name;
|
|
230
|
-
break;
|
|
123
|
+
selectLocality = (locality) => {
|
|
124
|
+
if (locality) {
|
|
125
|
+
this.requestLocalityDetails(locality.public_id);
|
|
126
|
+
} else {
|
|
127
|
+
this.setState({
|
|
128
|
+
error: null,
|
|
129
|
+
selectedLocality: null,
|
|
130
|
+
});
|
|
231
131
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
getHighlightedLocalityDesc = (locality) => {
|
|
135
|
+
let { description } = locality;
|
|
136
|
+
|
|
137
|
+
if (locality.matched_substrings && locality.matched_substrings.description) {
|
|
138
|
+
for (let j = locality.matched_substrings.description.length - 1; j >= 0; j--) {
|
|
139
|
+
const match = locality.matched_substrings.description[j];
|
|
140
|
+
description = `${description.substring(
|
|
141
|
+
0,
|
|
142
|
+
match.offset
|
|
143
|
+
)}<span class="localities-matched">${description.substring(
|
|
144
|
+
match.offset,
|
|
145
|
+
match.offset + match.length
|
|
146
|
+
)}</span>${description.substring(match.offset + match.length)}`;
|
|
147
|
+
}
|
|
235
148
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
});
|
|
149
|
+
// eslint-disable-next-line react/no-danger
|
|
150
|
+
return <div dangerouslySetInnerHTML={{ __html: description }} />;
|
|
151
|
+
};
|
|
240
152
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
placeholder="Street number, street name"
|
|
262
|
-
value={shippingAddress}
|
|
263
|
-
onChange={() => {}}
|
|
264
|
-
/>
|
|
265
|
-
<Input
|
|
266
|
-
label="City"
|
|
267
|
-
value={locality}
|
|
268
|
-
placeholder="City"
|
|
269
|
-
onChange={() => {}}
|
|
270
|
-
disabled
|
|
271
|
-
/>
|
|
272
|
-
<div className="demo__input-container--inline">
|
|
273
|
-
<Input
|
|
274
|
-
className="fullw"
|
|
275
|
-
label="State/Province"
|
|
276
|
-
placeholder="State/Province"
|
|
277
|
-
value={state}
|
|
278
|
-
onChange={() => {}}
|
|
279
|
-
/>
|
|
280
|
-
<Input
|
|
281
|
-
className="fullw"
|
|
282
|
-
label="Postal code"
|
|
283
|
-
placeholder="Postal code"
|
|
284
|
-
value={postcode}
|
|
285
|
-
onChange={() => {}}
|
|
286
|
-
/>
|
|
287
|
-
</div>
|
|
288
|
-
<Input
|
|
289
|
-
label="Country/Region"
|
|
290
|
-
placeholder="Country/Region"
|
|
291
|
-
value={country}
|
|
292
|
-
onChange={() => {}}
|
|
293
|
-
/>
|
|
294
|
-
</div>
|
|
295
|
-
);
|
|
296
|
-
};
|
|
153
|
+
renderHeaderFilters = () => {
|
|
154
|
+
const inputFilter = {
|
|
155
|
+
label: tr('Type in a UK address '),
|
|
156
|
+
component: (
|
|
157
|
+
<LocalitiesAutocomplete
|
|
158
|
+
inputRef={this.inputRef}
|
|
159
|
+
woosmapKey={Constants.woosmapKey}
|
|
160
|
+
placeholder="Type in an address"
|
|
161
|
+
defaultLocality={this.defaultOrigin}
|
|
162
|
+
language="en"
|
|
163
|
+
components="country:gb|country:je|country:gg|country:im"
|
|
164
|
+
types="address"
|
|
165
|
+
callback={this.selectLocality}
|
|
166
|
+
/>
|
|
167
|
+
),
|
|
168
|
+
};
|
|
169
|
+
return [inputFilter];
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
renderFooterFilters = () => [];
|
|
297
173
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
className="demo--localities--uk"
|
|
305
|
-
footerFilters={this.renderFooterFilters()}
|
|
306
|
-
headerFilters={this.renderHeaderFilters()}
|
|
307
|
-
request={selectedLocality ? this.requestDetailsUrl : this.requestUrl}
|
|
308
|
-
params={this.getRequestparams()}
|
|
309
|
-
referer="http://localhost/"
|
|
310
|
-
response={
|
|
311
|
-
error || selectedLocality ? { result: selectedLocality } : localities
|
|
174
|
+
renderAddress = () => {
|
|
175
|
+
const { selectedLocality } = this.state;
|
|
176
|
+
let addressComponents = [];
|
|
177
|
+
const hasComponents = selectedLocality && selectedLocality.address_components;
|
|
178
|
+
if (hasComponents) {
|
|
179
|
+
addressComponents = selectedLocality.address_components;
|
|
312
180
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
181
|
+
let shippingAddress = '';
|
|
182
|
+
let shippingAddress2 = '';
|
|
183
|
+
let postcode = '';
|
|
184
|
+
let locality = '';
|
|
185
|
+
let state = '';
|
|
186
|
+
let country = '';
|
|
187
|
+
addressComponents.forEach((component) => {
|
|
188
|
+
const [componentType] = component.types;
|
|
189
|
+
switch (componentType) {
|
|
190
|
+
case 'street_number': {
|
|
191
|
+
shippingAddress = `${component.long_name} ${shippingAddress}`;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case 'route': {
|
|
195
|
+
shippingAddress += component.short_name;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case 'postal_codes': {
|
|
199
|
+
postcode = `${component.long_name}${postcode}`;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
case 'postal_code_suffix': {
|
|
203
|
+
postcode = `${postcode}-${component.long_name}`;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
case 'locality':
|
|
207
|
+
locality = component.long_name;
|
|
208
|
+
break;
|
|
209
|
+
|
|
210
|
+
case 'state': {
|
|
211
|
+
state = component.long_name;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
case 'administrative_area_level_1': {
|
|
215
|
+
state = component.long_name;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
case 'country': {
|
|
219
|
+
country = component.long_name;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case 'premise': {
|
|
223
|
+
shippingAddress2 = component.long_name;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
default:
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<div className="demo--localities--uk__formcontainer">
|
|
233
|
+
{!hasComponents && (
|
|
234
|
+
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
235
|
+
<div
|
|
236
|
+
role="button"
|
|
237
|
+
className="overlay"
|
|
238
|
+
onClick={() => {
|
|
239
|
+
this.inputRef.current.focus();
|
|
240
|
+
}}
|
|
241
|
+
/>
|
|
242
|
+
)}
|
|
243
|
+
<Input
|
|
244
|
+
label="Apartment, unit, suite, or floor #"
|
|
245
|
+
placeholder="Apartment, unit, suite, or floor #"
|
|
246
|
+
value={shippingAddress2}
|
|
247
|
+
onChange={() => {}}
|
|
248
|
+
/>
|
|
249
|
+
<Input
|
|
250
|
+
label="Street number, street name"
|
|
251
|
+
placeholder="Street number, street name"
|
|
252
|
+
value={shippingAddress}
|
|
253
|
+
onChange={() => {}}
|
|
254
|
+
/>
|
|
255
|
+
<Input label="City" value={locality} placeholder="City" onChange={() => {}} disabled />
|
|
256
|
+
<div className="demo__input-container--inline">
|
|
257
|
+
<Input
|
|
258
|
+
className="fullw"
|
|
259
|
+
label="State/Province"
|
|
260
|
+
placeholder="State/Province"
|
|
261
|
+
value={state}
|
|
262
|
+
onChange={() => {}}
|
|
263
|
+
/>
|
|
264
|
+
<Input
|
|
265
|
+
className="fullw"
|
|
266
|
+
label="Postal code"
|
|
267
|
+
placeholder="Postal code"
|
|
268
|
+
value={postcode}
|
|
269
|
+
onChange={() => {}}
|
|
270
|
+
/>
|
|
271
|
+
</div>
|
|
272
|
+
<Input label="Country/Region" placeholder="Country/Region" value={country} onChange={() => {}} />
|
|
273
|
+
</div>
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
render() {
|
|
278
|
+
const { localities, error, selectedLocality } = this.state;
|
|
279
|
+
return (
|
|
280
|
+
<Demo
|
|
281
|
+
noheader
|
|
282
|
+
id="localities-demo-uk"
|
|
283
|
+
className="demo--localities--uk"
|
|
284
|
+
footerFilters={this.renderFooterFilters()}
|
|
285
|
+
headerFilters={this.renderHeaderFilters()}
|
|
286
|
+
request={selectedLocality ? this.requestDetailsUrl : this.requestUrl}
|
|
287
|
+
params={this.getRequestparams()}
|
|
288
|
+
referer="http://localhost/"
|
|
289
|
+
response={error || selectedLocality ? { result: selectedLocality } : localities}
|
|
290
|
+
result={this.renderAddress()}
|
|
291
|
+
/>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
317
294
|
}
|