@mychoice/mychoice-sdk-modules 2.1.47 → 2.1.49
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/dist/cjs/index.js +47 -22
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +47 -22
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -1902,13 +1902,15 @@ const PageCarQuote = () => {
|
|
|
1902
1902
|
const IndicatorsContainer = () => jsx(Fragment, {});
|
|
1903
1903
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1904
1904
|
// @ts-ignore
|
|
1905
|
-
const SingleValue = ({ children, selectProps, ...props }) =>
|
|
1905
|
+
const SingleValue = ({ children, selectProps, ...props }) => (
|
|
1906
|
+
// @ts-ignore
|
|
1907
|
+
jsx(components.SingleValue, { ...props, children: !selectProps.menuIsOpen ? children : '' }));
|
|
1906
1908
|
const SectionAddress = () => {
|
|
1907
|
-
const { dwellingState: { buildingStructure, heatings }, dispatchDwellingState } = useStoreFormHomeDwelling();
|
|
1908
|
-
const { appConfigState: { appType, localIndex, insuranceType }, dispatchAppConfigState } = useStoreAppConfig();
|
|
1909
|
+
const { dwellingState: { buildingStructure, heatings }, dispatchDwellingState, } = useStoreFormHomeDwelling();
|
|
1910
|
+
const { appConfigState: { appType, localIndex, insuranceType }, dispatchAppConfigState, } = useStoreAppConfig();
|
|
1909
1911
|
const { dispatchAppModalState } = useStoreAppModal();
|
|
1910
|
-
const { getPostal
|
|
1911
|
-
const { postalState: { item, inValidation }, dispatchPostalState } = useStoreFormHomePostal();
|
|
1912
|
+
const { getPostal } = useHandlerPostal(insuranceType);
|
|
1913
|
+
const { postalState: { item, inValidation }, dispatchPostalState, } = useStoreFormHomePostal();
|
|
1912
1914
|
const { dispatchApplicantBaseState } = useStoreFormHomeApplicantBase();
|
|
1913
1915
|
const { streetAddress = '', postalCode = '', addressObject, errorMessage, } = item;
|
|
1914
1916
|
const navigate = useNavigate();
|
|
@@ -1922,34 +1924,45 @@ const SectionAddress = () => {
|
|
|
1922
1924
|
isValid: false,
|
|
1923
1925
|
},
|
|
1924
1926
|
});
|
|
1925
|
-
geocodeByPlaceId(address.value.place_id)
|
|
1926
|
-
|
|
1927
|
-
const
|
|
1928
|
-
const
|
|
1929
|
-
const
|
|
1927
|
+
geocodeByPlaceId(address.value.place_id)
|
|
1928
|
+
.then((results) => {
|
|
1929
|
+
const newPostalCode = results[0].address_components?.find((component) => component.types.includes('postal_code')) || {};
|
|
1930
|
+
const streetNumber = results[0].address_components?.find((component) => component.types.includes('street_number')) || {};
|
|
1931
|
+
const route = results[0].address_components?.find((component) => component.types.includes('route')) || {};
|
|
1932
|
+
const unitNumber = results[0].address_components?.find((component) => component.types.includes('subpremise')) || {};
|
|
1930
1933
|
const newStreetAddress = [
|
|
1931
1934
|
streetNumber?.short_name,
|
|
1932
1935
|
route?.short_name,
|
|
1933
1936
|
unitNumber?.short_name ? `#${unitNumber.short_name}` : undefined,
|
|
1934
|
-
]
|
|
1937
|
+
]
|
|
1938
|
+
.filter((field) => field)
|
|
1939
|
+
.join(' ');
|
|
1940
|
+
console.log('AD: ', newPostalCode);
|
|
1935
1941
|
if (!newPostalCode.short_name) {
|
|
1936
1942
|
dispatchPostalState({
|
|
1937
1943
|
type: StoreFormHomePostalActionTypes.FormHomePostalSet,
|
|
1938
1944
|
payload: {
|
|
1939
1945
|
...item,
|
|
1940
|
-
errorMessage: '
|
|
1941
|
-
addressObject: {
|
|
1946
|
+
errorMessage: 'We couldn’t determine your postal code, please try typing it in manually below',
|
|
1947
|
+
addressObject: {
|
|
1948
|
+
label: address.label,
|
|
1949
|
+
value: { place_id: results[0].place_id },
|
|
1950
|
+
},
|
|
1942
1951
|
},
|
|
1943
1952
|
});
|
|
1944
1953
|
}
|
|
1945
1954
|
else {
|
|
1946
|
-
getPostal(newPostalCode.short_name?.replace(' ', ''))
|
|
1955
|
+
getPostal(newPostalCode.short_name?.replace(' ', ''))
|
|
1956
|
+
.then((res) => {
|
|
1947
1957
|
if (res?.errorMessage) {
|
|
1948
1958
|
dispatchPostalState({
|
|
1949
1959
|
type: StoreFormHomePostalActionTypes.FormHomePostalSet,
|
|
1950
1960
|
payload: {
|
|
1951
1961
|
...item,
|
|
1952
|
-
addressObject: {
|
|
1962
|
+
addressObject: {
|
|
1963
|
+
label: address.label,
|
|
1964
|
+
value: { place_id: results[0].place_id },
|
|
1965
|
+
},
|
|
1953
1966
|
errorMessage: res?.errorMessage,
|
|
1954
1967
|
},
|
|
1955
1968
|
});
|
|
@@ -1961,7 +1974,10 @@ const SectionAddress = () => {
|
|
|
1961
1974
|
...item,
|
|
1962
1975
|
...res?.data,
|
|
1963
1976
|
errorMessage: res?.errorMessage,
|
|
1964
|
-
addressObject: {
|
|
1977
|
+
addressObject: {
|
|
1978
|
+
label: address.label,
|
|
1979
|
+
value: { place_id: results[0].place_id },
|
|
1980
|
+
},
|
|
1965
1981
|
streetAddress: newStreetAddress,
|
|
1966
1982
|
},
|
|
1967
1983
|
});
|
|
@@ -1978,12 +1994,16 @@ const SectionAddress = () => {
|
|
|
1978
1994
|
});
|
|
1979
1995
|
}
|
|
1980
1996
|
}
|
|
1981
|
-
})
|
|
1997
|
+
})
|
|
1998
|
+
.catch((error) => {
|
|
1982
1999
|
dispatchPostalState({
|
|
1983
2000
|
type: StoreFormHomePostalActionTypes.FormHomePostalSet,
|
|
1984
2001
|
payload: {
|
|
1985
2002
|
...item,
|
|
1986
|
-
addressObject: {
|
|
2003
|
+
addressObject: {
|
|
2004
|
+
label: address.label,
|
|
2005
|
+
value: { place_id: results[0].place_id },
|
|
2006
|
+
},
|
|
1987
2007
|
errorMessage: error?.response?.data?.postalCode[0],
|
|
1988
2008
|
},
|
|
1989
2009
|
});
|
|
@@ -1994,7 +2014,7 @@ const SectionAddress = () => {
|
|
|
1994
2014
|
console.error(error);
|
|
1995
2015
|
});
|
|
1996
2016
|
};
|
|
1997
|
-
const handleOwnerTypeChange = ({ value: typeValue }) => {
|
|
2017
|
+
const handleOwnerTypeChange = ({ value: typeValue, }) => {
|
|
1998
2018
|
dispatchDwellingState({
|
|
1999
2019
|
type: StoreFormHomeDwellingActionTypes.FormHomeDwellingClear,
|
|
2000
2020
|
payload: { type: typeValue },
|
|
@@ -2057,7 +2077,7 @@ const SectionAddress = () => {
|
|
|
2057
2077
|
buildingStructureOptions = tenantBuildingStructureOptions;
|
|
2058
2078
|
break;
|
|
2059
2079
|
}
|
|
2060
|
-
if (!
|
|
2080
|
+
if (!buildingStructureOptions.find((option) => option.value === buildingStructure)) {
|
|
2061
2081
|
dispatchDwellingState({
|
|
2062
2082
|
type: StoreFormHomeDwellingActionTypes.FormHomeDwellingBuildingStructureSelect,
|
|
2063
2083
|
payload: { buildingStructure: '' },
|
|
@@ -2083,12 +2103,17 @@ const SectionAddress = () => {
|
|
|
2083
2103
|
styles: {
|
|
2084
2104
|
control: (baseStyles, state) => ({
|
|
2085
2105
|
...baseStyles,
|
|
2086
|
-
borderColor: getErrorMessage(streetAddress && postalCode, inValidation) ||
|
|
2106
|
+
borderColor: getErrorMessage(streetAddress && postalCode, inValidation) ||
|
|
2107
|
+
errorMessage
|
|
2108
|
+
? 'red'
|
|
2109
|
+
: getBorderColor(state.isFocused),
|
|
2087
2110
|
borderRadius: isMychoice ? '0.625rem' : '0.25rem',
|
|
2088
2111
|
boxShadow: 'none',
|
|
2089
2112
|
height: '3.75rem',
|
|
2090
2113
|
':hover': {
|
|
2091
|
-
borderColor: getErrorMessage(streetAddress && postalCode, inValidation) || errorMessage
|
|
2114
|
+
borderColor: getErrorMessage(streetAddress && postalCode, inValidation) || errorMessage
|
|
2115
|
+
? 'red'
|
|
2116
|
+
: '#8ED6DC',
|
|
2092
2117
|
borderWidth: '0.125rem',
|
|
2093
2118
|
cursor: 'pointer',
|
|
2094
2119
|
},
|