@mychoice/mychoice-sdk-modules 2.1.47 → 2.1.48

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 CHANGED
@@ -1912,13 +1912,15 @@ const PageCarQuote = () => {
1912
1912
  const IndicatorsContainer = () => jsxRuntime.jsx(jsxRuntime.Fragment, {});
1913
1913
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1914
1914
  // @ts-ignore
1915
- const SingleValue = ({ children, selectProps, ...props }) => jsxRuntime.jsx(reactSelect.components.SingleValue, { ...props, children: !selectProps.menuIsOpen ? children : '' });
1915
+ const SingleValue = ({ children, selectProps, ...props }) => (
1916
+ // @ts-ignore
1917
+ jsxRuntime.jsx(reactSelect.components.SingleValue, { ...props, children: !selectProps.menuIsOpen ? children : '' }));
1916
1918
  const SectionAddress = () => {
1917
- const { dwellingState: { buildingStructure, heatings }, dispatchDwellingState } = mychoiceSdkStore.useStoreFormHomeDwelling();
1918
- const { appConfigState: { appType, localIndex, insuranceType }, dispatchAppConfigState } = mychoiceSdkStore.useStoreAppConfig();
1919
+ const { dwellingState: { buildingStructure, heatings }, dispatchDwellingState, } = mychoiceSdkStore.useStoreFormHomeDwelling();
1920
+ const { appConfigState: { appType, localIndex, insuranceType }, dispatchAppConfigState, } = mychoiceSdkStore.useStoreAppConfig();
1919
1921
  const { dispatchAppModalState } = mychoiceSdkStore.useStoreAppModal();
1920
- const { getPostal, } = mychoiceSdkStore.useHandlerPostal(insuranceType);
1921
- const { postalState: { item, inValidation }, dispatchPostalState } = mychoiceSdkStore.useStoreFormHomePostal();
1922
+ const { getPostal } = mychoiceSdkStore.useHandlerPostal(insuranceType);
1923
+ const { postalState: { item, inValidation }, dispatchPostalState, } = mychoiceSdkStore.useStoreFormHomePostal();
1922
1924
  const { dispatchApplicantBaseState } = mychoiceSdkStore.useStoreFormHomeApplicantBase();
1923
1925
  const { streetAddress = '', postalCode = '', addressObject, errorMessage, } = item;
1924
1926
  const navigate = reactRouterDom.useNavigate();
@@ -1932,34 +1934,45 @@ const SectionAddress = () => {
1932
1934
  isValid: false,
1933
1935
  },
1934
1936
  });
1935
- GooglePlacesAutocomplete.geocodeByPlaceId(address.value.place_id).then((results) => {
1936
- const newPostalCode = results[0].address_components?.find(((component) => component.types.includes('postal_code'))) || {};
1937
- const streetNumber = results[0].address_components?.find(((component) => (component.types.includes('street_number')))) || {};
1938
- const route = results[0].address_components?.find(((component) => (component.types.includes('route')))) || {};
1939
- const unitNumber = results[0].address_components?.find(((component) => (component.types.includes('subpremise')))) || {};
1937
+ GooglePlacesAutocomplete.geocodeByPlaceId(address.value.place_id)
1938
+ .then((results) => {
1939
+ const newPostalCode = results[0].address_components?.find((component) => component.types.includes('postal_code')) || {};
1940
+ const streetNumber = results[0].address_components?.find((component) => component.types.includes('street_number')) || {};
1941
+ const route = results[0].address_components?.find((component) => component.types.includes('route')) || {};
1942
+ const unitNumber = results[0].address_components?.find((component) => component.types.includes('subpremise')) || {};
1940
1943
  const newStreetAddress = [
1941
1944
  streetNumber?.short_name,
1942
1945
  route?.short_name,
1943
1946
  unitNumber?.short_name ? `#${unitNumber.short_name}` : undefined,
1944
- ].filter((field) => field).join(' ');
1947
+ ]
1948
+ .filter((field) => field)
1949
+ .join(' ');
1950
+ console.log('AD: ', newPostalCode);
1945
1951
  if (!newPostalCode.short_name) {
1946
1952
  dispatchPostalState({
1947
1953
  type: mychoiceSdkStore.StoreFormHomePostalActionTypes.FormHomePostalSet,
1948
1954
  payload: {
1949
1955
  ...item,
1950
- errorMessage: 'Wrong address format, some parts of format are missed',
1951
- addressObject: { label: address.label, value: { place_id: results[0].place_id } },
1956
+ errorMessage: 'We couldn’t determine your postal code, please try typing it in manually below',
1957
+ addressObject: {
1958
+ label: address.label,
1959
+ value: { place_id: results[0].place_id },
1960
+ },
1952
1961
  },
1953
1962
  });
1954
1963
  }
1955
1964
  else {
1956
- getPostal(newPostalCode.short_name?.replace(' ', '')).then((res) => {
1965
+ getPostal(newPostalCode.short_name?.replace(' ', ''))
1966
+ .then((res) => {
1957
1967
  if (res?.errorMessage) {
1958
1968
  dispatchPostalState({
1959
1969
  type: mychoiceSdkStore.StoreFormHomePostalActionTypes.FormHomePostalSet,
1960
1970
  payload: {
1961
1971
  ...item,
1962
- addressObject: { label: address.label, value: { place_id: results[0].place_id } },
1972
+ addressObject: {
1973
+ label: address.label,
1974
+ value: { place_id: results[0].place_id },
1975
+ },
1963
1976
  errorMessage: res?.errorMessage,
1964
1977
  },
1965
1978
  });
@@ -1971,7 +1984,10 @@ const SectionAddress = () => {
1971
1984
  ...item,
1972
1985
  ...res?.data,
1973
1986
  errorMessage: res?.errorMessage,
1974
- addressObject: { label: address.label, value: { place_id: results[0].place_id } },
1987
+ addressObject: {
1988
+ label: address.label,
1989
+ value: { place_id: results[0].place_id },
1990
+ },
1975
1991
  streetAddress: newStreetAddress,
1976
1992
  },
1977
1993
  });
@@ -1988,12 +2004,16 @@ const SectionAddress = () => {
1988
2004
  });
1989
2005
  }
1990
2006
  }
1991
- }).catch((error) => {
2007
+ })
2008
+ .catch((error) => {
1992
2009
  dispatchPostalState({
1993
2010
  type: mychoiceSdkStore.StoreFormHomePostalActionTypes.FormHomePostalSet,
1994
2011
  payload: {
1995
2012
  ...item,
1996
- addressObject: { label: address.label, value: { place_id: results[0].place_id } },
2013
+ addressObject: {
2014
+ label: address.label,
2015
+ value: { place_id: results[0].place_id },
2016
+ },
1997
2017
  errorMessage: error?.response?.data?.postalCode[0],
1998
2018
  },
1999
2019
  });
@@ -2004,7 +2024,7 @@ const SectionAddress = () => {
2004
2024
  console.error(error);
2005
2025
  });
2006
2026
  };
2007
- const handleOwnerTypeChange = ({ value: typeValue }) => {
2027
+ const handleOwnerTypeChange = ({ value: typeValue, }) => {
2008
2028
  dispatchDwellingState({
2009
2029
  type: mychoiceSdkStore.StoreFormHomeDwellingActionTypes.FormHomeDwellingClear,
2010
2030
  payload: { type: typeValue },
@@ -2067,7 +2087,7 @@ const SectionAddress = () => {
2067
2087
  buildingStructureOptions = mychoiceSdkComponents.tenantBuildingStructureOptions;
2068
2088
  break;
2069
2089
  }
2070
- if (!(buildingStructureOptions.find((option) => option.value === buildingStructure))) {
2090
+ if (!buildingStructureOptions.find((option) => option.value === buildingStructure)) {
2071
2091
  dispatchDwellingState({
2072
2092
  type: mychoiceSdkStore.StoreFormHomeDwellingActionTypes.FormHomeDwellingBuildingStructureSelect,
2073
2093
  payload: { buildingStructure: '' },
@@ -2093,12 +2113,17 @@ const SectionAddress = () => {
2093
2113
  styles: {
2094
2114
  control: (baseStyles, state) => ({
2095
2115
  ...baseStyles,
2096
- borderColor: getErrorMessage(streetAddress && postalCode, inValidation) || errorMessage ? 'red' : getBorderColor(state.isFocused),
2116
+ borderColor: getErrorMessage(streetAddress && postalCode, inValidation) ||
2117
+ errorMessage
2118
+ ? 'red'
2119
+ : getBorderColor(state.isFocused),
2097
2120
  borderRadius: isMychoice ? '0.625rem' : '0.25rem',
2098
2121
  boxShadow: 'none',
2099
2122
  height: '3.75rem',
2100
2123
  ':hover': {
2101
- borderColor: getErrorMessage(streetAddress && postalCode, inValidation) || errorMessage ? 'red' : '#8ED6DC',
2124
+ borderColor: getErrorMessage(streetAddress && postalCode, inValidation) || errorMessage
2125
+ ? 'red'
2126
+ : '#8ED6DC',
2102
2127
  borderWidth: '0.125rem',
2103
2128
  cursor: 'pointer',
2104
2129
  },