@sellout/ui 0.0.395 → 0.0.397
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.
|
@@ -22,20 +22,19 @@ function AddressSearchDropdown(_a) {
|
|
|
22
22
|
innerValue = placeName;
|
|
23
23
|
}, []);
|
|
24
24
|
var selectAddress = React.useCallback(function (address) {
|
|
25
|
+
console.log(address, "address");
|
|
25
26
|
setValue(address);
|
|
26
27
|
var doEffect = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
27
|
-
var
|
|
28
|
+
var result, location_1, addressObject_1, e_1;
|
|
28
29
|
return __generator(this, function (_a) {
|
|
29
30
|
switch (_a.label) {
|
|
30
31
|
case 0:
|
|
31
32
|
_a.trys.push([0, 2, , 3]);
|
|
32
|
-
return [4 /*yield*/, getGeocode({
|
|
33
|
+
return [4 /*yield*/, getGeocode({
|
|
34
|
+
address: address,
|
|
35
|
+
})];
|
|
33
36
|
case 1:
|
|
34
|
-
|
|
35
|
-
result = results.find(function (r) {
|
|
36
|
-
return r.address_components.length > 2 &&
|
|
37
|
-
r.types.includes('street_address');
|
|
38
|
-
}) || results[0];
|
|
37
|
+
result = (_a.sent())[0];
|
|
39
38
|
location_1 = result.geometry.location;
|
|
40
39
|
addressObject_1 = {
|
|
41
40
|
address1: "",
|
|
@@ -54,9 +53,7 @@ function AddressSearchDropdown(_a) {
|
|
|
54
53
|
addressObject_1.address1 = ac.short_name;
|
|
55
54
|
}
|
|
56
55
|
if (ac.types.includes("route")) {
|
|
57
|
-
addressObject_1.address1 = addressObject_1.address1
|
|
58
|
-
? (addressObject_1.address1 + " " + ac.short_name).trim()
|
|
59
|
-
: ac.short_name;
|
|
56
|
+
addressObject_1.address1 = addressObject_1.address1 + " " + ac.short_name;
|
|
60
57
|
}
|
|
61
58
|
if (ac.types.includes("subpremise")) {
|
|
62
59
|
addressObject_1.address2 = ac.short_name;
|
|
@@ -81,6 +78,7 @@ function AddressSearchDropdown(_a) {
|
|
|
81
78
|
return [3 /*break*/, 3];
|
|
82
79
|
case 2:
|
|
83
80
|
e_1 = _a.sent();
|
|
81
|
+
// HANDLE ERROR
|
|
84
82
|
console.error(e_1);
|
|
85
83
|
return [3 /*break*/, 3];
|
|
86
84
|
case 3: return [2 /*return*/];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddressSearchDropdown.js","sources":["../../src/components/AddressSearchDropdown.tsx"],"sourcesContent":["import React from \"react\";\r\nimport usePlacesAutocomplete, { getGeocode } from \"use-places-autocomplete\";\r\nimport styled from \"styled-components\";\r\nimport SearchDropdown, { SearchDropdownTypes } from \"./SearchDropdown\";\r\nimport { IconEnum } from \"./Icons\";\r\n\r\ninterface IAddress {\r\n address1?: string;\r\n address2?: string;\r\n city?: string;\r\n state?: string;\r\n zip?: string;\r\n country?: string;\r\n phone?: string;\r\n lat?: number | null;\r\n lng?: number | null;\r\n placeId?: string;\r\n placeName?: string;\r\n timezone?: string;\r\n}\r\n\r\ninterface ISearchDropdownItem {\r\n text: string;\r\n value: any;\r\n}\r\n\r\nconst Container = styled.div`\r\n width: 100%;\r\n z-index: 100000;\r\n`;\r\n\r\nexport type AddressSearchDropdownProps = {\r\n value: IAddress;\r\n onChange: (address: IAddress) => void;\r\n width?: string;\r\n label?:any;\r\n tip?: string;\r\n fontSize?:string;\r\n fontWeight?:string;\r\n fontFamily?:string;\r\n darkThemeProps?:string;\r\n labelColor?:string;\r\n borderColor?:string;\r\n height?:string;\r\n}\r\n\r\nexport default function AddressSearchDropdown({\r\n value,\r\n onChange,\r\n width,\r\n label,\r\n tip,\r\n fontSize,\r\n fontWeight,\r\n fontFamily,\r\n darkThemeProps,\r\n labelColor,\r\n borderColor,\r\n height\r\n}: AddressSearchDropdownProps) {\r\n /* Hooks */\r\n let {\r\n value: innerValue,\r\n suggestions: { data },\r\n setValue,\r\n } = usePlacesAutocomplete({\r\n requestOptions: {\r\n componentRestrictions: { country: \"us\" },\r\n },\r\n debounce: 300,\r\n });\r\n\r\n React.useEffect(() => {\r\n let placeName = value?.placeName ? value?.placeName : \"\";\r\n setValue(placeName);\r\n innerValue = placeName;\r\n }, []);\r\n\r\n const selectAddress = React.useCallback(\r\n (address) => {\r\n setValue(address);\r\n const doEffect = async () => {\r\n try {\r\n const
|
|
1
|
+
{"version":3,"file":"AddressSearchDropdown.js","sources":["../../src/components/AddressSearchDropdown.tsx"],"sourcesContent":["import React from \"react\";\r\nimport usePlacesAutocomplete, { getGeocode } from \"use-places-autocomplete\";\r\nimport styled from \"styled-components\";\r\nimport SearchDropdown, { SearchDropdownTypes } from \"./SearchDropdown\";\r\nimport { IconEnum } from \"./Icons\";\r\n\r\ninterface IAddress {\r\n address1?: string;\r\n address2?: string;\r\n city?: string;\r\n state?: string;\r\n zip?: string;\r\n country?: string;\r\n phone?: string;\r\n lat?: number | null;\r\n lng?: number | null;\r\n placeId?: string;\r\n placeName?: string;\r\n timezone?: string;\r\n}\r\n\r\ninterface ISearchDropdownItem {\r\n text: string;\r\n value: any;\r\n}\r\n\r\nconst Container = styled.div`\r\n width: 100%;\r\n z-index: 100000;\r\n`;\r\n\r\nexport type AddressSearchDropdownProps = {\r\n value: IAddress;\r\n onChange: (address: IAddress) => void;\r\n width?: string;\r\n label?:any;\r\n tip?: string;\r\n fontSize?:string;\r\n fontWeight?:string;\r\n fontFamily?:string;\r\n darkThemeProps?:string;\r\n labelColor?:string;\r\n borderColor?:string;\r\n height?:string;\r\n}\r\n\r\nexport default function AddressSearchDropdown({\r\n value,\r\n onChange,\r\n width,\r\n label,\r\n tip,\r\n fontSize,\r\n fontWeight,\r\n fontFamily,\r\n darkThemeProps,\r\n labelColor,\r\n borderColor,\r\n height\r\n}: AddressSearchDropdownProps) {\r\n /* Hooks */\r\n let {\r\n value: innerValue,\r\n suggestions: { data },\r\n setValue,\r\n } = usePlacesAutocomplete({\r\n requestOptions: {\r\n componentRestrictions: { country: \"us\" },\r\n },\r\n debounce: 300,\r\n });\r\n\r\n React.useEffect(() => {\r\n let placeName = value?.placeName ? value?.placeName : \"\";\r\n setValue(placeName);\r\n innerValue = placeName;\r\n }, []);\r\n\r\n const selectAddress = React.useCallback(\r\n (address) => {\r\n console.log(address, \"address\");\r\n\r\n setValue(address);\r\n const doEffect = async () => {\r\n try {\r\n const [result] = await getGeocode({\r\n address,\r\n });\r\n const {\r\n geometry: { location },\r\n } = result;\r\n\r\n const addressObject = {\r\n address1: \"\",\r\n address2: \"\",\r\n city: \"\",\r\n state: \"\",\r\n zip: \"\",\r\n country: \"\",\r\n lat: location.lat(),\r\n lng: location.lng(),\r\n placeId: result.place_id,\r\n placeName: address,\r\n };\r\n result.address_components.forEach((ac: any) => {\r\n if (ac.types.includes(\"street_number\")) {\r\n addressObject.address1 = ac.short_name;\r\n }\r\n if (ac.types.includes(\"route\")) {\r\n addressObject.address1 = `${addressObject.address1} ${ac.short_name}`;\r\n }\r\n if (ac.types.includes(\"subpremise\")) {\r\n addressObject.address2 = ac.short_name;\r\n }\r\n if (\r\n ac.types.includes(\"locality\") &&\r\n ac.types.includes(\"political\")\r\n ) {\r\n addressObject.city = ac.short_name;\r\n }\r\n if (\r\n ac.types.includes(\"administrative_area_level_1\") &&\r\n ac.types.includes(\"political\")\r\n ) {\r\n addressObject.state = ac.short_name;\r\n }\r\n if (\r\n ac.types.includes(\"country\") &&\r\n ac.types.includes(\"political\")\r\n ) {\r\n addressObject.country = ac.short_name;\r\n }\r\n if (ac.types.includes(\"postal_code\")) {\r\n addressObject.zip = ac.short_name;\r\n }\r\n });\r\n onChange(addressObject);\r\n } catch (e) {\r\n // HANDLE ERROR\r\n console.error(e);\r\n }\r\n };\r\n doEffect();\r\n },\r\n [onChange, setValue]\r\n );\r\n\r\n React.useEffect(() => {\r\n let intialAddress: IAddress = {};\r\n if (!innerValue) onChange(intialAddress);\r\n }, [innerValue]);\r\n\r\n /* Render */\r\n let items: ISearchDropdownItem[] = [];\r\n\r\n if (data.length) {\r\n items = data.map(\r\n (suggestion): ISearchDropdownItem => ({\r\n text: suggestion.description,\r\n value: suggestion.description,\r\n })\r\n );\r\n }\r\n\r\n return (\r\n <Container>\r\n <SearchDropdown\r\n type={SearchDropdownTypes.SingleSelect}\r\n icon={IconEnum.MapPinLight}\r\n onChange={selectAddress}\r\n value={innerValue}\r\n searchQuery={innerValue}\r\n setSearchQuery={setValue}\r\n placeholder=\"Search for an address\"\r\n items={items}\r\n width={width}\r\n label={label}\r\n tip={tip}\r\n fontSize={fontSize}\r\n fontWeight={fontWeight}\r\n fontFamily={fontFamily}\r\n darkThemeProps={darkThemeProps}\r\n labelColor={labelColor}\r\n borderColor={borderColor}\r\n height={height}\r\n />\r\n </Container>\r\n );\r\n}\r\n"],"names":[],"mappings":";;;;;;;AA0BA,IAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA,gBAAA,KAAA,gBAAA,GAAA,oBAAA,CAAA,CAAA,wCAAA,CAAA,EAAA,CAAA,wCAG3B,IAAA,CAAC;AAiBsB,SAAA,qBAAqB,CAAC,EAajB,EAAA;IAb7B,IA8IC,KAAA,GAAA,IAAA,CAAA;AA7IC,IAAA,IAAA,KAAK,GAAA,EAAA,CAAA,KAAA,EACL,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,KAAK,GAAA,EAAA,CAAA,KAAA,EACL,KAAK,GAAA,EAAA,CAAA,KAAA,EACL,GAAG,GAAA,EAAA,CAAA,GAAA,EACH,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,UAAU,gBAAA,EACV,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,MAAM,GAAA,EAAA,CAAA,MAAA,CAAA;;IAGF,IAAA,EAAA,GAIA,qBAAqB,CAAC;AACxB,QAAA,cAAc,EAAE;AACd,YAAA,qBAAqB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;AACzC,SAAA;AACD,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,EAAC,uBAAuB,EACnC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,CAAA,CACQ,EACZ;AACJ,CAAC;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sellout/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.397",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"module": "build/index.es.js",
|
|
6
6
|
"files": [
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@fortawesome/pro-solid-svg-icons": "^5.15.4",
|
|
54
54
|
"@fortawesome/react-fontawesome": "^0.1.19",
|
|
55
55
|
"@hapi/joi": "^17.1.1",
|
|
56
|
-
"@sellout/utils": "^0.0.
|
|
56
|
+
"@sellout/utils": "^0.0.397",
|
|
57
57
|
"csvtojson": "^2.0.10",
|
|
58
58
|
"framer-motion": "^2.9.5",
|
|
59
59
|
"polished": "^3.7.2",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"rollup-plugin-url": "^3.0.1",
|
|
63
63
|
"use-places-autocomplete": "^1.11.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "7d6b9121e8dbda9b28be7359eef4294306eb8ba4",
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"react": "16.14.0",
|
|
68
68
|
"react-dom": "16.14.0",
|