@mychoice/mychoice-sdk-store 1.0.0 → 2.0.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.
Files changed (271) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/handlers/dataHandlers/AuthDataHandler/interfaces.d.ts +1 -1
  3. package/dist/cjs/handlers/dataHandlers/ClearFormDataHandler/interfaces.d.ts +1 -1
  4. package/dist/cjs/handlers/dataHandlers/PartnerDataHandler/interfaces.d.ts +1 -1
  5. package/dist/cjs/handlers/dataHandlers/PostalDataHandler/PostalDataHandler.d.ts +1 -1
  6. package/dist/cjs/handlers/dataHandlers/PostalDataHandler/interfaces.d.ts +6 -2
  7. package/dist/cjs/handlers/dataHandlers/QuoteDataHandler/CarQuoteDataHandler.d.ts +2 -0
  8. package/dist/cjs/handlers/dataHandlers/QuoteDataHandler/HomeQuoteDataHandler.d.ts +2 -0
  9. package/dist/cjs/handlers/dataHandlers/QuoteDataHandler/LifeQuoteDataHandler.d.ts +2 -0
  10. package/dist/cjs/handlers/dataHandlers/QuoteDataHandler/index.d.ts +3 -1
  11. package/dist/cjs/handlers/dataHandlers/QuoteDataHandler/interfaces.d.ts +1 -1
  12. package/dist/cjs/handlers/dataHandlers/QuoterEmailDataHandler/QuoterEmailDataHandler.d.ts +3 -1
  13. package/dist/cjs/handlers/dataHandlers/QuoterEmailDataHandler/index.d.ts +1 -1
  14. package/dist/cjs/handlers/dataHandlers/QuoterEmailDataHandler/interfaces.d.ts +1 -1
  15. package/dist/cjs/handlers/dataHandlers/VehicleDataHandlers/interfaces.d.ts +3 -3
  16. package/dist/cjs/handlers/dataHandlers/shared/dataReducer/interfaces.d.ts +3 -3
  17. package/dist/cjs/handlers/validationHandlers/index.d.ts +1 -0
  18. package/dist/cjs/handlers/validationHandlers/insurances/home/interfaces.d.ts +2 -2
  19. package/dist/cjs/handlers/validationHandlers/insurances/life/ApplicantValidationHandler.d.ts +2 -0
  20. package/dist/cjs/handlers/validationHandlers/insurances/life/CoverageValidationHandler.d.ts +2 -0
  21. package/dist/cjs/handlers/validationHandlers/insurances/life/index.d.ts +2 -0
  22. package/dist/cjs/handlers/validationHandlers/insurances/life/interfaces.d.ts +15 -0
  23. package/dist/cjs/index.js +2052 -512
  24. package/dist/cjs/index.js.map +1 -1
  25. package/dist/cjs/services/httpRequest/hoox.d.ts +2 -2
  26. package/dist/cjs/services/httpRequest/interfaces.d.ts +6 -6
  27. package/dist/cjs/states/StoreProvider.d.ts +1 -1
  28. package/dist/cjs/states/reducers/interfaces.d.ts +8 -2
  29. package/dist/cjs/states/reducers/reducers.d.ts +8 -2
  30. package/dist/cjs/states/reducers/states/ConfigState/AppConfigState/interfaces.d.ts +3 -3
  31. package/dist/cjs/states/reducers/states/ConfigState/AppDeviceState/interfaces.d.ts +3 -3
  32. package/dist/cjs/states/reducers/states/ConfigState/AppLoaderState/interfaces.d.ts +2 -2
  33. package/dist/cjs/states/reducers/states/ConfigState/AppModalState/actions.d.ts +1 -0
  34. package/dist/cjs/states/reducers/states/ConfigState/AppModalState/interfaces.d.ts +7 -4
  35. package/dist/cjs/states/reducers/states/GlobalState/ClientState/interfaces.d.ts +2 -2
  36. package/dist/cjs/states/reducers/states/GlobalState/PartnerState/interfaces.d.ts +2 -2
  37. package/dist/cjs/states/reducers/states/formStates/FormCarState/ConfigState/constants.d.ts +5 -0
  38. package/dist/cjs/states/reducers/states/formStates/FormCarState/ConfigState/hoox.d.ts +2 -1
  39. package/dist/cjs/states/reducers/states/formStates/FormCarState/ConfigState/index.d.ts +1 -1
  40. package/dist/cjs/states/reducers/states/formStates/FormCarState/ConfigState/interfaces.d.ts +9 -2
  41. package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/index.d.ts +1 -1
  42. package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts +3 -3
  43. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverAccidentState/interfaces.d.ts +2 -2
  44. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverBaseState/interfaces.d.ts +2 -2
  45. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverCancellationState/interfaces.d.ts +2 -2
  46. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverInfoState/interfaces.d.ts +3 -3
  47. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/interfaces.d.ts +2 -2
  48. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/interfaces.d.ts +3 -3
  49. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverSuspensionState/interfaces.d.ts +2 -2
  50. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/interfaces.d.ts +2 -2
  51. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/helper.d.ts +1 -1
  52. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/interfaces.d.ts +7 -7
  53. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/reducer.d.ts +1 -1
  54. package/dist/cjs/states/reducers/states/formStates/FormCarState/PostalState/interfaces.d.ts +2 -2
  55. package/dist/cjs/states/reducers/states/formStates/FormCarState/QuoteState/actions.d.ts +2 -2
  56. package/dist/cjs/states/reducers/states/formStates/FormCarState/QuoteState/helper.d.ts +2 -2
  57. package/dist/cjs/states/reducers/states/formStates/FormCarState/QuoteState/index.d.ts +1 -1
  58. package/dist/cjs/states/reducers/states/formStates/FormCarState/QuoteState/interfaces.d.ts +6 -6
  59. package/dist/cjs/states/reducers/states/formStates/FormCarState/VehicleState/helper.d.ts +2 -2
  60. package/dist/cjs/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts +3 -3
  61. package/dist/cjs/states/reducers/states/formStates/FormHomeState/AddressState/interfaces.d.ts +1 -1
  62. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantBaseState/interfaces.d.ts +2 -2
  63. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantCancellationState/interfaces.d.ts +2 -2
  64. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantClaimState/interfaces.d.ts +2 -2
  65. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantInfoState/actions.d.ts +0 -2
  66. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantInfoState/interfaces.d.ts +2 -14
  67. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantInsuranceState/actions.d.ts +0 -2
  68. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantInsuranceState/interfaces.d.ts +2 -14
  69. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/index.d.ts +1 -1
  70. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/initialState.d.ts +4 -3
  71. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/interfaces.d.ts +13 -23
  72. package/dist/cjs/states/reducers/states/formStates/FormHomeState/ApplicantState/reducer.d.ts +1 -1
  73. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DiscountState/actions.d.ts +9 -1
  74. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DiscountState/index.d.ts +1 -1
  75. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DiscountState/interfaces.d.ts +66 -3
  76. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DwellingState/actions.d.ts +11 -2
  77. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DwellingState/helper.d.ts +3 -1
  78. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DwellingState/index.d.ts +2 -0
  79. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DwellingState/initialState.d.ts +3 -13
  80. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DwellingState/interfaces.d.ts +74 -16
  81. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DwellingState/localStore.d.ts +2 -0
  82. package/dist/cjs/states/reducers/states/formStates/FormHomeState/PostalState/actions.d.ts +6 -0
  83. package/dist/cjs/states/reducers/states/formStates/FormHomeState/PostalState/helper.d.ts +1 -1
  84. package/dist/cjs/states/reducers/states/formStates/FormHomeState/PostalState/interfaces.d.ts +50 -4
  85. package/dist/cjs/states/reducers/states/formStates/FormHomeState/QuoteState/actions.d.ts +9 -0
  86. package/dist/cjs/states/reducers/states/formStates/FormHomeState/QuoteState/helper.d.ts +2 -0
  87. package/dist/cjs/states/reducers/states/formStates/FormHomeState/QuoteState/hoox.d.ts +2 -0
  88. package/dist/cjs/states/reducers/states/formStates/FormHomeState/QuoteState/index.d.ts +1 -0
  89. package/dist/cjs/states/reducers/states/formStates/FormHomeState/QuoteState/initialState.d.ts +2 -0
  90. package/dist/cjs/states/reducers/states/formStates/FormHomeState/QuoteState/interfaces.d.ts +69 -0
  91. package/dist/cjs/states/reducers/states/formStates/FormHomeState/QuoteState/localStore.d.ts +3 -0
  92. package/dist/cjs/states/reducers/states/formStates/FormHomeState/QuoteState/reducer.d.ts +2 -0
  93. package/dist/cjs/states/reducers/states/formStates/FormHomeState/actions.d.ts +1 -1
  94. package/dist/cjs/states/reducers/states/formStates/FormHomeState/hoox.d.ts +1 -1
  95. package/dist/cjs/states/reducers/states/formStates/FormHomeState/index.d.ts +1 -1
  96. package/dist/cjs/states/reducers/states/formStates/FormHomeState/reducer.d.ts +2 -2
  97. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/actions.d.ts +18 -0
  98. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/hoox.d.ts +2 -0
  99. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/index.d.ts +1 -0
  100. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/initialState.d.ts +2 -0
  101. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/interfaces.d.ts +119 -0
  102. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/localStore.d.ts +4 -0
  103. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/reducer.d.ts +2 -0
  104. package/dist/cjs/states/reducers/states/formStates/FormLifeState/CoverageState/actions.d.ts +9 -0
  105. package/dist/cjs/states/reducers/states/formStates/FormLifeState/CoverageState/hoox.d.ts +2 -0
  106. package/dist/cjs/states/reducers/states/formStates/FormLifeState/CoverageState/index.d.ts +1 -0
  107. package/dist/cjs/states/reducers/states/formStates/FormLifeState/CoverageState/initialState.d.ts +2 -0
  108. package/dist/cjs/states/reducers/states/formStates/FormLifeState/CoverageState/interfaces.d.ts +51 -0
  109. package/dist/cjs/states/reducers/states/formStates/FormLifeState/CoverageState/localStore.d.ts +3 -0
  110. package/dist/cjs/states/reducers/states/formStates/FormLifeState/CoverageState/reducer.d.ts +2 -0
  111. package/dist/cjs/states/reducers/states/formStates/FormLifeState/PostalState/actions.d.ts +5 -0
  112. package/dist/cjs/states/reducers/states/formStates/FormLifeState/PostalState/helper.d.ts +3 -0
  113. package/dist/cjs/states/reducers/states/formStates/FormLifeState/PostalState/hoox.d.ts +2 -0
  114. package/dist/cjs/states/reducers/states/formStates/FormLifeState/PostalState/index.d.ts +1 -0
  115. package/dist/cjs/states/reducers/states/formStates/FormLifeState/PostalState/initialState.d.ts +2 -0
  116. package/dist/cjs/states/reducers/states/formStates/FormLifeState/PostalState/interfaces.d.ts +28 -0
  117. package/dist/cjs/states/reducers/states/formStates/FormLifeState/PostalState/localStore.d.ts +3 -0
  118. package/dist/cjs/states/reducers/states/formStates/FormLifeState/PostalState/reducer.d.ts +2 -0
  119. package/dist/cjs/states/reducers/states/formStates/FormLifeState/QuoteState/actions.d.ts +9 -0
  120. package/dist/cjs/states/reducers/states/formStates/FormLifeState/QuoteState/helper.d.ts +2 -0
  121. package/dist/cjs/states/reducers/states/formStates/FormLifeState/QuoteState/hoox.d.ts +2 -0
  122. package/dist/cjs/states/reducers/states/formStates/FormLifeState/QuoteState/index.d.ts +1 -0
  123. package/dist/cjs/states/reducers/states/formStates/FormLifeState/QuoteState/initialState.d.ts +2 -0
  124. package/dist/cjs/states/reducers/states/formStates/FormLifeState/QuoteState/interfaces.d.ts +68 -0
  125. package/dist/cjs/states/reducers/states/formStates/FormLifeState/QuoteState/localStore.d.ts +3 -0
  126. package/dist/cjs/states/reducers/states/formStates/FormLifeState/QuoteState/reducer.d.ts +2 -0
  127. package/dist/cjs/states/reducers/states/formStates/FormLifeState/actions.d.ts +4 -0
  128. package/dist/cjs/states/reducers/states/formStates/FormLifeState/hoox.d.ts +4 -0
  129. package/dist/cjs/states/reducers/states/formStates/FormLifeState/index.d.ts +5 -0
  130. package/dist/cjs/states/reducers/states/formStates/FormLifeState/reducer.d.ts +6 -0
  131. package/dist/cjs/states/reducers/states/formStates/actions.d.ts +1 -0
  132. package/dist/cjs/states/reducers/states/formStates/hoox.d.ts +1 -0
  133. package/dist/cjs/states/reducers/states/formStates/index.d.ts +1 -0
  134. package/dist/cjs/states/reducers/states/formStates/shared/helpers.d.ts +1 -1
  135. package/dist/cjs/states/store.d.ts +10 -2
  136. package/dist/esm/handlers/dataHandlers/AuthDataHandler/interfaces.d.ts +1 -1
  137. package/dist/esm/handlers/dataHandlers/ClearFormDataHandler/interfaces.d.ts +1 -1
  138. package/dist/esm/handlers/dataHandlers/PartnerDataHandler/interfaces.d.ts +1 -1
  139. package/dist/esm/handlers/dataHandlers/PostalDataHandler/PostalDataHandler.d.ts +1 -1
  140. package/dist/esm/handlers/dataHandlers/PostalDataHandler/interfaces.d.ts +6 -2
  141. package/dist/esm/handlers/dataHandlers/QuoteDataHandler/CarQuoteDataHandler.d.ts +2 -0
  142. package/dist/esm/handlers/dataHandlers/QuoteDataHandler/HomeQuoteDataHandler.d.ts +2 -0
  143. package/dist/esm/handlers/dataHandlers/QuoteDataHandler/LifeQuoteDataHandler.d.ts +2 -0
  144. package/dist/esm/handlers/dataHandlers/QuoteDataHandler/index.d.ts +3 -1
  145. package/dist/esm/handlers/dataHandlers/QuoteDataHandler/interfaces.d.ts +1 -1
  146. package/dist/esm/handlers/dataHandlers/QuoterEmailDataHandler/QuoterEmailDataHandler.d.ts +3 -1
  147. package/dist/esm/handlers/dataHandlers/QuoterEmailDataHandler/index.d.ts +1 -1
  148. package/dist/esm/handlers/dataHandlers/QuoterEmailDataHandler/interfaces.d.ts +1 -1
  149. package/dist/esm/handlers/dataHandlers/VehicleDataHandlers/interfaces.d.ts +3 -3
  150. package/dist/esm/handlers/dataHandlers/shared/dataReducer/interfaces.d.ts +3 -3
  151. package/dist/esm/handlers/validationHandlers/index.d.ts +1 -0
  152. package/dist/esm/handlers/validationHandlers/insurances/home/interfaces.d.ts +2 -2
  153. package/dist/esm/handlers/validationHandlers/insurances/life/ApplicantValidationHandler.d.ts +2 -0
  154. package/dist/esm/handlers/validationHandlers/insurances/life/CoverageValidationHandler.d.ts +2 -0
  155. package/dist/esm/handlers/validationHandlers/insurances/life/index.d.ts +2 -0
  156. package/dist/esm/handlers/validationHandlers/insurances/life/interfaces.d.ts +15 -0
  157. package/dist/esm/index.js +2033 -509
  158. package/dist/esm/index.js.map +1 -1
  159. package/dist/esm/services/httpRequest/hoox.d.ts +2 -2
  160. package/dist/esm/services/httpRequest/interfaces.d.ts +6 -6
  161. package/dist/esm/states/StoreProvider.d.ts +1 -1
  162. package/dist/esm/states/reducers/interfaces.d.ts +8 -2
  163. package/dist/esm/states/reducers/reducers.d.ts +8 -2
  164. package/dist/esm/states/reducers/states/ConfigState/AppConfigState/interfaces.d.ts +3 -3
  165. package/dist/esm/states/reducers/states/ConfigState/AppDeviceState/interfaces.d.ts +3 -3
  166. package/dist/esm/states/reducers/states/ConfigState/AppLoaderState/interfaces.d.ts +2 -2
  167. package/dist/esm/states/reducers/states/ConfigState/AppModalState/actions.d.ts +1 -0
  168. package/dist/esm/states/reducers/states/ConfigState/AppModalState/interfaces.d.ts +7 -4
  169. package/dist/esm/states/reducers/states/GlobalState/ClientState/interfaces.d.ts +2 -2
  170. package/dist/esm/states/reducers/states/GlobalState/PartnerState/interfaces.d.ts +2 -2
  171. package/dist/esm/states/reducers/states/formStates/FormCarState/ConfigState/constants.d.ts +5 -0
  172. package/dist/esm/states/reducers/states/formStates/FormCarState/ConfigState/hoox.d.ts +2 -1
  173. package/dist/esm/states/reducers/states/formStates/FormCarState/ConfigState/index.d.ts +1 -1
  174. package/dist/esm/states/reducers/states/formStates/FormCarState/ConfigState/interfaces.d.ts +9 -2
  175. package/dist/esm/states/reducers/states/formStates/FormCarState/DiscountState/index.d.ts +1 -1
  176. package/dist/esm/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts +3 -3
  177. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverAccidentState/interfaces.d.ts +2 -2
  178. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverBaseState/interfaces.d.ts +2 -2
  179. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverCancellationState/interfaces.d.ts +2 -2
  180. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverInfoState/interfaces.d.ts +3 -3
  181. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/interfaces.d.ts +2 -2
  182. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/interfaces.d.ts +3 -3
  183. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverSuspensionState/interfaces.d.ts +2 -2
  184. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/interfaces.d.ts +2 -2
  185. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/helper.d.ts +1 -1
  186. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/interfaces.d.ts +7 -7
  187. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/reducer.d.ts +1 -1
  188. package/dist/esm/states/reducers/states/formStates/FormCarState/PostalState/interfaces.d.ts +2 -2
  189. package/dist/esm/states/reducers/states/formStates/FormCarState/QuoteState/actions.d.ts +2 -2
  190. package/dist/esm/states/reducers/states/formStates/FormCarState/QuoteState/helper.d.ts +2 -2
  191. package/dist/esm/states/reducers/states/formStates/FormCarState/QuoteState/index.d.ts +1 -1
  192. package/dist/esm/states/reducers/states/formStates/FormCarState/QuoteState/interfaces.d.ts +6 -6
  193. package/dist/esm/states/reducers/states/formStates/FormCarState/VehicleState/helper.d.ts +2 -2
  194. package/dist/esm/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts +3 -3
  195. package/dist/esm/states/reducers/states/formStates/FormHomeState/AddressState/interfaces.d.ts +1 -1
  196. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantBaseState/interfaces.d.ts +2 -2
  197. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantCancellationState/interfaces.d.ts +2 -2
  198. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantClaimState/interfaces.d.ts +2 -2
  199. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantInfoState/actions.d.ts +0 -2
  200. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantInfoState/interfaces.d.ts +2 -14
  201. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantInsuranceState/actions.d.ts +0 -2
  202. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/ApplicantInsuranceState/interfaces.d.ts +2 -14
  203. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/index.d.ts +1 -1
  204. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/initialState.d.ts +4 -3
  205. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/interfaces.d.ts +13 -23
  206. package/dist/esm/states/reducers/states/formStates/FormHomeState/ApplicantState/reducer.d.ts +1 -1
  207. package/dist/esm/states/reducers/states/formStates/FormHomeState/DiscountState/actions.d.ts +9 -1
  208. package/dist/esm/states/reducers/states/formStates/FormHomeState/DiscountState/index.d.ts +1 -1
  209. package/dist/esm/states/reducers/states/formStates/FormHomeState/DiscountState/interfaces.d.ts +66 -3
  210. package/dist/esm/states/reducers/states/formStates/FormHomeState/DwellingState/actions.d.ts +11 -2
  211. package/dist/esm/states/reducers/states/formStates/FormHomeState/DwellingState/helper.d.ts +3 -1
  212. package/dist/esm/states/reducers/states/formStates/FormHomeState/DwellingState/index.d.ts +2 -0
  213. package/dist/esm/states/reducers/states/formStates/FormHomeState/DwellingState/initialState.d.ts +3 -13
  214. package/dist/esm/states/reducers/states/formStates/FormHomeState/DwellingState/interfaces.d.ts +74 -16
  215. package/dist/esm/states/reducers/states/formStates/FormHomeState/DwellingState/localStore.d.ts +2 -0
  216. package/dist/esm/states/reducers/states/formStates/FormHomeState/PostalState/actions.d.ts +6 -0
  217. package/dist/esm/states/reducers/states/formStates/FormHomeState/PostalState/helper.d.ts +1 -1
  218. package/dist/esm/states/reducers/states/formStates/FormHomeState/PostalState/interfaces.d.ts +50 -4
  219. package/dist/esm/states/reducers/states/formStates/FormHomeState/QuoteState/actions.d.ts +9 -0
  220. package/dist/esm/states/reducers/states/formStates/FormHomeState/QuoteState/helper.d.ts +2 -0
  221. package/dist/esm/states/reducers/states/formStates/FormHomeState/QuoteState/hoox.d.ts +2 -0
  222. package/dist/esm/states/reducers/states/formStates/FormHomeState/QuoteState/index.d.ts +1 -0
  223. package/dist/esm/states/reducers/states/formStates/FormHomeState/QuoteState/initialState.d.ts +2 -0
  224. package/dist/esm/states/reducers/states/formStates/FormHomeState/QuoteState/interfaces.d.ts +69 -0
  225. package/dist/esm/states/reducers/states/formStates/FormHomeState/QuoteState/localStore.d.ts +3 -0
  226. package/dist/esm/states/reducers/states/formStates/FormHomeState/QuoteState/reducer.d.ts +2 -0
  227. package/dist/esm/states/reducers/states/formStates/FormHomeState/actions.d.ts +1 -1
  228. package/dist/esm/states/reducers/states/formStates/FormHomeState/hoox.d.ts +1 -1
  229. package/dist/esm/states/reducers/states/formStates/FormHomeState/index.d.ts +1 -1
  230. package/dist/esm/states/reducers/states/formStates/FormHomeState/reducer.d.ts +2 -2
  231. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/actions.d.ts +18 -0
  232. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/hoox.d.ts +2 -0
  233. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/index.d.ts +1 -0
  234. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/initialState.d.ts +2 -0
  235. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/interfaces.d.ts +119 -0
  236. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/localStore.d.ts +4 -0
  237. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/reducer.d.ts +2 -0
  238. package/dist/esm/states/reducers/states/formStates/FormLifeState/CoverageState/actions.d.ts +9 -0
  239. package/dist/esm/states/reducers/states/formStates/FormLifeState/CoverageState/hoox.d.ts +2 -0
  240. package/dist/esm/states/reducers/states/formStates/FormLifeState/CoverageState/index.d.ts +1 -0
  241. package/dist/esm/states/reducers/states/formStates/FormLifeState/CoverageState/initialState.d.ts +2 -0
  242. package/dist/esm/states/reducers/states/formStates/FormLifeState/CoverageState/interfaces.d.ts +51 -0
  243. package/dist/esm/states/reducers/states/formStates/FormLifeState/CoverageState/localStore.d.ts +3 -0
  244. package/dist/esm/states/reducers/states/formStates/FormLifeState/CoverageState/reducer.d.ts +2 -0
  245. package/dist/esm/states/reducers/states/formStates/FormLifeState/PostalState/actions.d.ts +5 -0
  246. package/dist/esm/states/reducers/states/formStates/FormLifeState/PostalState/helper.d.ts +3 -0
  247. package/dist/esm/states/reducers/states/formStates/FormLifeState/PostalState/hoox.d.ts +2 -0
  248. package/dist/esm/states/reducers/states/formStates/FormLifeState/PostalState/index.d.ts +1 -0
  249. package/dist/esm/states/reducers/states/formStates/FormLifeState/PostalState/initialState.d.ts +2 -0
  250. package/dist/esm/states/reducers/states/formStates/FormLifeState/PostalState/interfaces.d.ts +28 -0
  251. package/dist/esm/states/reducers/states/formStates/FormLifeState/PostalState/localStore.d.ts +3 -0
  252. package/dist/esm/states/reducers/states/formStates/FormLifeState/PostalState/reducer.d.ts +2 -0
  253. package/dist/esm/states/reducers/states/formStates/FormLifeState/QuoteState/actions.d.ts +9 -0
  254. package/dist/esm/states/reducers/states/formStates/FormLifeState/QuoteState/helper.d.ts +2 -0
  255. package/dist/esm/states/reducers/states/formStates/FormLifeState/QuoteState/hoox.d.ts +2 -0
  256. package/dist/esm/states/reducers/states/formStates/FormLifeState/QuoteState/index.d.ts +1 -0
  257. package/dist/esm/states/reducers/states/formStates/FormLifeState/QuoteState/initialState.d.ts +2 -0
  258. package/dist/esm/states/reducers/states/formStates/FormLifeState/QuoteState/interfaces.d.ts +68 -0
  259. package/dist/esm/states/reducers/states/formStates/FormLifeState/QuoteState/localStore.d.ts +3 -0
  260. package/dist/esm/states/reducers/states/formStates/FormLifeState/QuoteState/reducer.d.ts +2 -0
  261. package/dist/esm/states/reducers/states/formStates/FormLifeState/actions.d.ts +4 -0
  262. package/dist/esm/states/reducers/states/formStates/FormLifeState/hoox.d.ts +4 -0
  263. package/dist/esm/states/reducers/states/formStates/FormLifeState/index.d.ts +5 -0
  264. package/dist/esm/states/reducers/states/formStates/FormLifeState/reducer.d.ts +6 -0
  265. package/dist/esm/states/reducers/states/formStates/actions.d.ts +1 -0
  266. package/dist/esm/states/reducers/states/formStates/hoox.d.ts +1 -0
  267. package/dist/esm/states/reducers/states/formStates/index.d.ts +1 -0
  268. package/dist/esm/states/reducers/states/formStates/shared/helpers.d.ts +1 -1
  269. package/dist/esm/states/store.d.ts +10 -2
  270. package/dist/index.d.ts +716 -182
  271. package/package.json +3 -3
package/dist/esm/index.js CHANGED
@@ -1,12 +1,11 @@
1
1
  import axios from 'axios';
2
- import { defaultLocalIndex, HttpRequestHeaderTypes, RequestTypes, ModalTypes, DeviceTypes, ScreenBPTypes, DeviceTypeWidthList, ScreenBPList, AppTypes, InsuranceTypes, VehicleConditionTypes, VehiclePrimaryUseTypes, deepClone, CoverageTypes, getFormattedDate, GenderTypes, OccupationTypes, addDaysToDate, compareDates, DriverLicenceTypes, DateTypes, addYearsToDate, subMonthsFromDate, getDifferenceInYears, DriverListTypes, addMonthsToDate, ValidationStatusTypes, DriverPriorityTypes, defaultBrokerPhone, ApplicantListTypes, useEffectOnce, API_AUTH, RequestStatusTypes, PROFILE_API, getDaysOfMonth, getDifferenceInHours, MAX_LOCAL_STORAGE_HOURS, API_APP, API_FORM_CAR, API_FORM_HOME } from '@mychoice/mychoice-sdk-components';
2
+ import { defaultLocalIndex, HttpRequestHeaderTypes, RequestTypes, ModalTypes, DeviceTypes, ScreenBPTypes, DeviceTypeWidthList, ScreenBPList, AppTypes, InsuranceTypes, VehicleConditionTypes, VehiclePrimaryUseTypes, deepClone, CoverageTypes, getFormattedDate, GenderTypes, OccupationTypes, addDaysToDate, compareDates, DriverLicenceTypes, DateTypes, getLicenceMinDate, addYearsToDate, subMonthsFromDate, getDifferenceInYears, DriverListTypes, addMonthsToDate, ValidationStatusTypes, DriverPriorityTypes, defaultBrokerPhone, subYearsFromDate, ApplicantListTypes, useEffectOnce, getInsuranceType as getInsuranceType$2, API_AUTH, RequestStatusTypes, PROFILE_API, getDaysOfMonth, getDifferenceInHours, MAX_LOCAL_STORAGE_HOURS_THEBIG, MAX_LOCAL_STORAGE_HOURS, API_APP, API_FORM_CAR, supportedProvinceCodes, API_FORM_HOME, API_FORM_LIFE } from '@groksmith/mychoice-sdk-components';
3
3
  import { useMemo, useReducer, useState } from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import { Provider, useSelector, useDispatch } from 'react-redux';
6
6
  import { combineReducers, createStore, applyMiddleware } from 'redux';
7
7
  import thunk from 'redux-thunk';
8
8
  import { composeWithDevTools } from '@redux-devtools/extension';
9
- import { getLicenceMinDate } from '@mychoice/mychoice-sdk-modules';
10
9
  import { camelizeKeys, decamelizeKeys } from 'humps';
11
10
  import { useNavigate } from 'react-router-dom';
12
11
 
@@ -110,6 +109,7 @@ var StoreConfigAppModalActionTypes;
110
109
  StoreConfigAppModalActionTypes["AppModalMessageModal"] = "AppModalMessageModal";
111
110
  StoreConfigAppModalActionTypes["AppModalConfirmModal"] = "AppModalConfirmModal";
112
111
  StoreConfigAppModalActionTypes["AppModalPostalModal"] = "AppModalPostalModal";
112
+ StoreConfigAppModalActionTypes["AppModalAddressModal"] = "AppModalAddressModal";
113
113
  StoreConfigAppModalActionTypes["AppModalFinaleModal"] = "AppModalFinaleModal";
114
114
  StoreConfigAppModalActionTypes["AppModalClose"] = "AppModalClose";
115
115
  })(StoreConfigAppModalActionTypes || (StoreConfigAppModalActionTypes = {}));
@@ -137,6 +137,13 @@ const appModalStateReducer = (state = { ...appModalInitialState }, action) => {
137
137
  ...action.payload,
138
138
  modalType: ModalTypes.PostalModal,
139
139
  };
140
+ case StoreConfigAppModalActionTypes.AppModalAddressModal:
141
+ return {
142
+ ...state,
143
+ isOpen: true,
144
+ ...action.payload,
145
+ modalType: ModalTypes.AddressModal,
146
+ };
140
147
  case StoreConfigAppModalActionTypes.AppModalFinaleModal:
141
148
  return {
142
149
  ...state,
@@ -170,8 +177,10 @@ var StoreConfigAppDeviceActionTypes;
170
177
 
171
178
  const detectDeviceType = (width) => {
172
179
  switch (true) {
173
- case (width > DeviceTypeWidthList[1].minWidth):
180
+ case (width >= DeviceTypeWidthList[1].minWidth && width < DeviceTypeWidthList[2].minWidth):
174
181
  return DeviceTypeWidthList[1].type;
182
+ case (width >= DeviceTypeWidthList[2].minWidth):
183
+ return DeviceTypeWidthList[2].type;
175
184
  default:
176
185
  return DeviceTypes.Mobile;
177
186
  }
@@ -559,7 +568,7 @@ const setItemProperty = (state, name, value) => {
559
568
  newState.items[newState.activeIndex][name] = value;
560
569
  return newState;
561
570
  };
562
- const setCoverageProperty = (state, name, coverage, value) => {
571
+ const setCarCoverageProperty = (state, name, coverage, value) => {
563
572
  const newState = deepClone(state);
564
573
  newState.items.map((item) => {
565
574
  const newItem = item;
@@ -585,13 +594,13 @@ const setCoverageProperty = (state, name, coverage, value) => {
585
594
  return newState;
586
595
  };
587
596
 
588
- const localStateName$9 = 'car_vehicles';
597
+ const localStateName$d = 'car_vehicles';
589
598
  const getLocalVehicles = (localIndex = '') => {
590
- const localVehicles = localStorage.getItem(`${localIndex}_${localStateName$9}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$9}`) || '') : null;
599
+ const localVehicles = localStorage.getItem(`${localIndex}_${localStateName$d}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$d}`) || '') : null;
591
600
  return localVehicles || { ...carFormVehicleInitialState };
592
601
  };
593
602
  const setLocalVehicles = (localIndex, state) => {
594
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$9}`, JSON.stringify(state));
603
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$d}`, JSON.stringify(state));
595
604
  return state;
596
605
  };
597
606
 
@@ -644,11 +653,11 @@ const formCarVehicleStateReducer = (state = { ...carFormVehicleInitialState }, a
644
653
  return setLocalVehicles(action.localIndex, setItemProperty(state, 'distanceYearly', action.payload.distanceYearly));
645
654
  // coverage
646
655
  case StoreFormCarVehicleActionTypes.FormCarComprehensiveCoverageSelect:
647
- return setLocalVehicles(action.localIndex, setCoverageProperty(state, 'comprehensive', action.payload.coverage, action.payload.deductible));
656
+ return setLocalVehicles(action.localIndex, setCarCoverageProperty(state, 'comprehensive', action.payload.coverage, action.payload.deductible));
648
657
  case StoreFormCarVehicleActionTypes.FormCarCollisionCoverageSelect:
649
- return setLocalVehicles(action.localIndex, setCoverageProperty(state, 'collision', action.payload.coverage, action.payload.deductible));
658
+ return setLocalVehicles(action.localIndex, setCarCoverageProperty(state, 'collision', action.payload.coverage, action.payload.deductible));
650
659
  case StoreFormCarVehicleActionTypes.FormCarLiabilityCoverageSelect:
651
- return setLocalVehicles(action.localIndex, setCoverageProperty(state, 'liability', action.payload.coverage, action.payload.limit));
660
+ return setLocalVehicles(action.localIndex, setCarCoverageProperty(state, 'liability', action.payload.coverage, action.payload.limit));
652
661
  case StoreFormCarVehicleActionTypes.FormCarVehicleClear:
653
662
  return setLocalVehicles(action.localIndex, { ...carFormVehicleInitialState });
654
663
  default:
@@ -858,13 +867,13 @@ const carFormDriverInitialState = {
858
867
  isValid: false,
859
868
  };
860
869
 
861
- const localStateName$8 = 'car_drivers';
870
+ const localStateName$c = 'car_drivers';
862
871
  const getLocalDrivers = (localIndex = '') => {
863
- const localDrivers = localStorage.getItem(`${localIndex}_${localStateName$8}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$8}`) || '') : null;
872
+ const localDrivers = localStorage.getItem(`${localIndex}_${localStateName$c}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$c}`) || '') : null;
864
873
  return localDrivers || { ...carFormDriverInitialState };
865
874
  };
866
875
  const setLocalDrivers = (localIndex, state) => {
867
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$8}`, JSON.stringify(state));
876
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$c}`, JSON.stringify(state));
868
877
  return state;
869
878
  };
870
879
 
@@ -1473,33 +1482,33 @@ var StoreFormCarPostalActionTypes;
1473
1482
  StoreFormCarPostalActionTypes["FormCarPostalGetLocal"] = "FormCarPostalGetLocal";
1474
1483
  })(StoreFormCarPostalActionTypes || (StoreFormCarPostalActionTypes = {}));
1475
1484
 
1476
- const setPostalStateProperty$1 = (state, name, value) => {
1485
+ const setPostalStateProperty$2 = (state, name, value) => {
1477
1486
  const newState = deepClone(state);
1478
1487
  newState.isReady = true;
1479
1488
  newState[name] = value;
1480
1489
  return newState;
1481
1490
  };
1482
1491
 
1483
- const localStateName$7 = 'car_postal';
1484
- const setLocalPostal$1 = (localIndex, state) => {
1485
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$7}`, JSON.stringify(state));
1492
+ const localStateName$b = 'car_postal';
1493
+ const setLocalPostal$2 = (localIndex, state) => {
1494
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$b}`, JSON.stringify(state));
1486
1495
  return state;
1487
1496
  };
1488
- const getLocalPostal$1 = (localIndex = '') => {
1489
- const localPostal = localStorage.getItem(`${localIndex}_${localStateName$7}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$7}`) || '') : null;
1497
+ const getLocalPostal$2 = (localIndex = '') => {
1498
+ const localPostal = localStorage.getItem(`${localIndex}_${localStateName$b}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$b}`) || '') : null;
1490
1499
  return localPostal || { ...formCarPostalInitialState };
1491
1500
  };
1492
1501
 
1493
1502
  const formCarPostalStateReducer = (state = { ...formCarPostalInitialState }, action) => {
1494
1503
  switch (action.type) {
1495
1504
  case StoreFormCarPostalActionTypes.FormCarPostalSet:
1496
- return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'item', action.payload));
1505
+ return setLocalPostal$2(action.localIndex, setPostalStateProperty$2(state, 'item', action.payload));
1497
1506
  case StoreFormCarPostalActionTypes.FormCarPostalGetLocal:
1498
1507
  return {
1499
- ...getLocalPostal$1(action.localIndex),
1508
+ ...getLocalPostal$2(action.localIndex),
1500
1509
  };
1501
1510
  case StoreFormCarPostalActionTypes.FormCarPostalClear:
1502
- return setLocalPostal$1(action.localIndex, { ...formCarPostalInitialState });
1511
+ return setLocalPostal$2(action.localIndex, { ...formCarPostalInitialState });
1503
1512
  default:
1504
1513
  return state;
1505
1514
  }
@@ -1511,10 +1520,15 @@ var StoreFormCarConfigActionTypes;
1511
1520
  StoreFormCarConfigActionTypes["FormCarConfigClear"] = "FormCarConfigClear";
1512
1521
  })(StoreFormCarConfigActionTypes || (StoreFormCarConfigActionTypes = {}));
1513
1522
 
1523
+ const OntarioCode = 'ON';
1524
+ const AlbertaCode = 'AB';
1525
+ const NovaScotiaCode = 'NS';
1526
+ const NewfoundlandCode = 'NF';
1527
+ const NewBrunswickCode = 'NB';
1514
1528
  const provinceList = [
1515
1529
  {
1516
1530
  name: 'Ontario',
1517
- code: 'ON',
1531
+ code: OntarioCode,
1518
1532
  toolTip: {
1519
1533
  // eslint-disable-next-line max-len
1520
1534
  licenceAge: 'The selection indicates how old the primary driver was when they received their original driver’s licence. It includes motorcycle and commercial licences, too. If you do not remember your age, it is acceptable to provide a best estimate for the purposes of the policy or quote.',
@@ -1561,7 +1575,7 @@ const provinceList = [
1561
1575
  },
1562
1576
  {
1563
1577
  name: 'Alberta',
1564
- code: 'AB',
1578
+ code: AlbertaCode,
1565
1579
  toolTip: {
1566
1580
  // eslint-disable-next-line max-len
1567
1581
  licenceAge: 'Please indicate the age at which this driver first received a driver\'s licence of any type in Alberta. If you don\'t remember the age at which the licence was received, please make your best estimate.',
@@ -1608,7 +1622,7 @@ const provinceList = [
1608
1622
  },
1609
1623
  {
1610
1624
  name: 'Nova Scotia',
1611
- code: 'NS',
1625
+ code: NovaScotiaCode,
1612
1626
  toolTip: {
1613
1627
  // eslint-disable-next-line max-len
1614
1628
  licenceAge: 'The selection indicates how old the primary driver was when they received their original driver’s licence. It includes motorcycle and commercial licences, too. If you do not remember your age, it is acceptable to provide a best estimate for the purposes of the policy or quote.',
@@ -1655,7 +1669,7 @@ const provinceList = [
1655
1669
  },
1656
1670
  {
1657
1671
  name: 'Newfoundland',
1658
- code: 'NF',
1672
+ code: NewfoundlandCode,
1659
1673
  toolTip: {
1660
1674
  // eslint-disable-next-line max-len
1661
1675
  licenceAge: 'The selection indicates how old the primary driver was when they received their original driver’s licence. It includes motorcycle and commercial licences, too. If you do not remember your age, it is acceptable to provide a best estimate for the purposes of the policy or quote.',
@@ -1702,7 +1716,7 @@ const provinceList = [
1702
1716
  },
1703
1717
  {
1704
1718
  name: 'New Brunswick',
1705
- code: 'NB',
1719
+ code: NewBrunswickCode,
1706
1720
  toolTip: {
1707
1721
  // eslint-disable-next-line max-len
1708
1722
  licenceAge: 'The selection indicates how old the primary driver was when they received their original driver’s licence. It includes motorcycle and commercial licences, too. If you do not remember your age, it is acceptable to provide a best estimate for the purposes of the policy or quote.',
@@ -1901,27 +1915,27 @@ const setDiscountQuoterProperty = (state, name, value) => {
1901
1915
  return newState;
1902
1916
  };
1903
1917
 
1904
- const localStateName$6 = 'car_discounts';
1918
+ const localStateName$a = 'car_discounts';
1905
1919
  const getLocalDiscounts$1 = (localIndex = '') => {
1906
- const localDiscounts = localStorage.getItem(`${localIndex}_${localStateName$6}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$6}`) || '') : null;
1920
+ const localDiscounts = localStorage.getItem(`${localIndex}_${localStateName$a}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$a}`) || '') : null;
1907
1921
  return localDiscounts || { ...formCarDiscountStateInitialState };
1908
1922
  };
1909
1923
  const setLocalDiscounts$1 = (localIndex, state) => {
1910
1924
  if (state.emailTo.emailStatus === ValidationStatusTypes.Approved) {
1911
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$6}`, JSON.stringify(state));
1925
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$a}`, JSON.stringify(state));
1912
1926
  return state;
1913
1927
  }
1914
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$6}`, JSON.stringify(state));
1928
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$a}`, JSON.stringify(state));
1915
1929
  return state;
1916
1930
  };
1917
1931
  const setLocalDiscountsEmail$1 = (localIndex, state) => {
1918
1932
  if (state.emailTo.emailStatus === ValidationStatusTypes.Approved) {
1919
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$6}`, JSON.stringify(state));
1933
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$a}`, JSON.stringify(state));
1920
1934
  }
1921
1935
  else {
1922
1936
  const newState = deepClone(state);
1923
1937
  newState.emailTo = { email: '', emailStatus: ValidationStatusTypes.Initial };
1924
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$6}`, JSON.stringify(newState));
1938
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$a}`, JSON.stringify(newState));
1925
1939
  }
1926
1940
  return state;
1927
1941
  };
@@ -1992,47 +2006,47 @@ const formCarQuoteInitialState = {
1992
2006
 
1993
2007
  var StoreFormCarQuoteActionTypes;
1994
2008
  (function (StoreFormCarQuoteActionTypes) {
1995
- StoreFormCarQuoteActionTypes["UpdateQuoteResponse"] = "UpdateQuoteResponse";
2009
+ StoreFormCarQuoteActionTypes["UpdateCarQuoteResponse"] = "UpdateCarQuoteResponse";
1996
2010
  StoreFormCarQuoteActionTypes["FormCarQuoteIsRequestedSet"] = "FormCarQuoteIsRequestedSet";
1997
2011
  StoreFormCarQuoteActionTypes["FormCarQuoteRequestDateSet"] = "FormCarQuoteRequestDateSet";
1998
2012
  StoreFormCarQuoteActionTypes["FormCarQuotesSet"] = "FormCarQuotesSet";
1999
2013
  StoreFormCarQuoteActionTypes["FormCarQuoteGetLocal"] = "FormCarQuoteGetLocal";
2000
2014
  StoreFormCarQuoteActionTypes["FormCarQuoteClear"] = "FormCarQuoteClear";
2001
- StoreFormCarQuoteActionTypes["UpdateCallMessage"] = "UpdateCallMessage";
2015
+ StoreFormCarQuoteActionTypes["UpdateCarCallMessage"] = "UpdateCarCallMessage";
2002
2016
  })(StoreFormCarQuoteActionTypes || (StoreFormCarQuoteActionTypes = {}));
2003
2017
 
2004
- const setQuoteStateProperty = (state, name, value) => {
2018
+ const setQuoteStateProperty$2 = (state, name, value) => {
2005
2019
  const newState = deepClone(state);
2006
2020
  newState[name] = value;
2007
2021
  return newState;
2008
2022
  };
2009
2023
 
2010
- const localStateName$5 = 'car_quotes';
2011
- const setLocalQuotes = (localIndex, state) => {
2012
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$5}`, JSON.stringify(state));
2024
+ const localStateName$9 = 'car_quotes';
2025
+ const setLocalQuotes$2 = (localIndex, state) => {
2026
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$9}`, JSON.stringify(state));
2013
2027
  return state;
2014
2028
  };
2015
- const getLocalQuotes = (localIndex = '') => {
2016
- const localQuotes = localStorage.getItem(`${localIndex}_${localStateName$5}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$5}`) || '') : null;
2029
+ const getLocalQuotes$2 = (localIndex = '') => {
2030
+ const localQuotes = localStorage.getItem(`${localIndex}_${localStateName$9}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$9}`) || '') : null;
2017
2031
  return localQuotes || { ...formCarQuoteInitialState };
2018
2032
  };
2019
2033
 
2020
2034
  const formCarQuoteStateReducer = (state = { ...formCarQuoteInitialState }, action) => {
2021
2035
  switch (action.type) {
2022
2036
  case StoreFormCarQuoteActionTypes.FormCarQuoteIsRequestedSet:
2023
- return setLocalQuotes(action.localIndex, setQuoteStateProperty(state, 'isRequested', action.payload.isRequested));
2037
+ return setLocalQuotes$2(action.localIndex, setQuoteStateProperty$2(state, 'isRequested', action.payload.isRequested));
2024
2038
  case StoreFormCarQuoteActionTypes.FormCarQuotesSet:
2025
- return setLocalQuotes(action.localIndex, setQuoteStateProperty(state, 'items', action.payload.items));
2039
+ return setLocalQuotes$2(action.localIndex, setQuoteStateProperty$2(state, 'items', action.payload.items));
2026
2040
  case StoreFormCarQuoteActionTypes.FormCarQuoteRequestDateSet:
2027
- return setLocalQuotes(action.localIndex, setQuoteStateProperty(state, 'requestDate', action.payload.requestDate));
2041
+ return setLocalQuotes$2(action.localIndex, setQuoteStateProperty$2(state, 'requestDate', action.payload.requestDate));
2028
2042
  case StoreFormCarQuoteActionTypes.FormCarQuoteGetLocal:
2029
2043
  return {
2030
- ...getLocalQuotes(action.localIndex),
2044
+ ...getLocalQuotes$2(action.localIndex),
2031
2045
  };
2032
2046
  case StoreFormCarQuoteActionTypes.FormCarQuoteClear:
2033
- return setLocalQuotes(action.localIndex, { ...formCarQuoteInitialState });
2034
- case StoreFormCarQuoteActionTypes.UpdateCallMessage:
2035
- return setLocalQuotes(action.localIndex, setQuoteStateProperty(state, 'showCallMessage', action.payload.showCallMessage));
2047
+ return setLocalQuotes$2(action.localIndex, { ...formCarQuoteInitialState });
2048
+ case StoreFormCarQuoteActionTypes.UpdateCarCallMessage:
2049
+ return setLocalQuotes$2(action.localIndex, setQuoteStateProperty$2(state, 'showCallMessage', action.payload.showCallMessage));
2036
2050
  default:
2037
2051
  return state;
2038
2052
  }
@@ -2047,27 +2061,202 @@ const formCarReducer = combineReducers({
2047
2061
  quoteState: formCarQuoteStateReducer,
2048
2062
  });
2049
2063
 
2064
+ const dwellingHeatingItemInitialState = {
2065
+ type: 'naturalgas',
2066
+ };
2067
+ const formHomeDwellingInitialState = {
2068
+ type: InsuranceTypes.Home,
2069
+ isCompleted: true,
2070
+ builtDate: '',
2071
+ builtYear: '1952',
2072
+ buildingStructure: 'detached',
2073
+ livingArea: 1149,
2074
+ exteriorFinish: 'brick',
2075
+ constructionType: 'brick',
2076
+ garageType: 'none',
2077
+ basementFinishPercent: 0,
2078
+ storeysCount: 1,
2079
+ roofReplacedDate: '',
2080
+ roofReplacedYear: getFormattedDate(subYearsFromDate('', 10), 'yyyy'),
2081
+ fireHallDistance: '5',
2082
+ fireHydrantDistance: '150',
2083
+ heatings: [
2084
+ { ...dwellingHeatingItemInitialState },
2085
+ { type: 'unknown' },
2086
+ ],
2087
+ replacementCost: 300000,
2088
+ unitsCount: 1,
2089
+ // applicant page
2090
+ familiesCount: '',
2091
+ occupiedDate: '',
2092
+ occupiedYear: '',
2093
+ // discount page
2094
+ burglarAlarm: false,
2095
+ fireAlarm: false,
2096
+ sprinkler: false,
2097
+ deadbolt: false,
2098
+ fireExtinguishersCount: '2',
2099
+ mortgagesCount: '2',
2100
+ // quote page
2101
+ deductible: '1000',
2102
+ liability: '1000000',
2103
+ waterCoverage: true,
2104
+ inValidation: false,
2105
+ isValid: false,
2106
+ // for square one
2107
+ roofType: null,
2108
+ poolType: null,
2109
+ bathroomsCount: null,
2110
+ };
2111
+ const formCondoDwellingInitialState = {
2112
+ type: InsuranceTypes.Condo,
2113
+ isCompleted: false,
2114
+ builtDate: '',
2115
+ builtYear: '',
2116
+ buildingStructure: '',
2117
+ livingArea: 1149,
2118
+ exteriorFinish: 'brick',
2119
+ constructionType: 'brick',
2120
+ garageType: 'none',
2121
+ basementFinishPercent: 0,
2122
+ storeysCount: 1,
2123
+ roofReplacedDate: '',
2124
+ roofReplacedYear: getFormattedDate(subYearsFromDate('', 10), 'yyyy'),
2125
+ fireHallDistance: '5',
2126
+ fireHydrantDistance: '150',
2127
+ heatings: [
2128
+ { ...dwellingHeatingItemInitialState },
2129
+ { type: 'unknown' },
2130
+ ],
2131
+ replacementCost: 150000,
2132
+ unitsCount: 1,
2133
+ pp: '40000',
2134
+ // applicant page
2135
+ familiesCount: '',
2136
+ occupiedDate: '',
2137
+ occupiedYear: '',
2138
+ // discount page
2139
+ burglarAlarm: false,
2140
+ fireAlarm: false,
2141
+ sprinkler: false,
2142
+ deadbolt: false,
2143
+ fireExtinguishersCount: '2',
2144
+ mortgagesCount: '2',
2145
+ // quote page
2146
+ deductible: '1000',
2147
+ liability: '1000000',
2148
+ waterCoverage: true,
2149
+ inValidation: false,
2150
+ isValid: false,
2151
+ // for square one
2152
+ roofType: null,
2153
+ poolType: null,
2154
+ bathroomsCount: null,
2155
+ };
2156
+ const formTenantDwellingInitialState = {
2157
+ type: InsuranceTypes.Tenant,
2158
+ isCompleted: false,
2159
+ builtDate: '',
2160
+ builtYear: '',
2161
+ buildingStructure: '',
2162
+ livingArea: 1149,
2163
+ exteriorFinish: 'brick',
2164
+ constructionType: 'brick',
2165
+ garageType: 'none',
2166
+ basementFinishPercent: 0,
2167
+ storeysCount: 1,
2168
+ roofReplacedDate: '',
2169
+ roofReplacedYear: getFormattedDate(subYearsFromDate('', 10), 'yyyy'),
2170
+ fireHallDistance: '5',
2171
+ fireHydrantDistance: '150',
2172
+ heatings: [
2173
+ { ...dwellingHeatingItemInitialState },
2174
+ { type: 'unknown' },
2175
+ ],
2176
+ replacementCost: 150000,
2177
+ unitsCount: 1,
2178
+ pp: '30000',
2179
+ // applicant page
2180
+ familiesCount: '',
2181
+ occupiedDate: '',
2182
+ occupiedYear: '',
2183
+ // discount page
2184
+ burglarAlarm: false,
2185
+ fireAlarm: false,
2186
+ sprinkler: false,
2187
+ deadbolt: false,
2188
+ fireExtinguishersCount: '2',
2189
+ mortgagesCount: '2',
2190
+ // quote page
2191
+ deductible: '1000',
2192
+ liability: '1000000',
2193
+ waterCoverage: true,
2194
+ inValidation: false,
2195
+ isValid: false,
2196
+ // for square one
2197
+ roofType: null,
2198
+ poolType: null,
2199
+ bathroomsCount: null,
2200
+ };
2201
+
2202
+ // This function isn't used yet
2203
+ const setHomeCoverageProperty = (state, name, value) => {
2204
+ const newState = deepClone(state);
2205
+ newState[name] = value;
2206
+ return newState;
2207
+ };
2208
+ const getDwellingInitialState = (type) => {
2209
+ switch (type) {
2210
+ case InsuranceTypes.Home:
2211
+ return formHomeDwellingInitialState;
2212
+ case InsuranceTypes.Condo:
2213
+ return formCondoDwellingInitialState;
2214
+ case InsuranceTypes.Tenant:
2215
+ return formTenantDwellingInitialState;
2216
+ default:
2217
+ return formHomeDwellingInitialState;
2218
+ }
2219
+ };
2220
+
2050
2221
  const formHomePostalInitialState = {
2051
2222
  isReady: false,
2052
2223
  item: {
2053
2224
  ...postalItemInitialState,
2225
+ errorMessage: '',
2226
+ streetAddress: '',
2227
+ unitNumber: '',
2228
+ addressObject: { label: 'Type in Your Street Address', value: {} }, // sync with search autocomplate package
2054
2229
  },
2230
+ isValid: false,
2231
+ inValidation: false,
2055
2232
  };
2056
2233
 
2057
2234
  var StoreFormHomePostalActionTypes;
2058
2235
  (function (StoreFormHomePostalActionTypes) {
2059
2236
  StoreFormHomePostalActionTypes["FormHomePostalSet"] = "FormHomePostalSet";
2237
+ StoreFormHomePostalActionTypes["FormHomePostalStreetAddressSet"] = "FormHomePostalStreetAddressSet";
2238
+ StoreFormHomePostalActionTypes["FormHomePostalUnitNumberSet"] = "FormHomePostalUnitNumberSet";
2060
2239
  StoreFormHomePostalActionTypes["FormHomePostalCitySet"] = "FormHomePostalCitySet";
2240
+ StoreFormHomePostalActionTypes["FormHomePostalProvinceSet"] = "FormHomePostalProvinceSet";
2061
2241
  StoreFormHomePostalActionTypes["FormHomePostalCodeSet"] = "FormHomePostalCodeSet";
2062
2242
  StoreFormHomePostalActionTypes["FormHomePostalClear"] = "FormHomePostalClear";
2243
+ StoreFormHomePostalActionTypes["FormHomePostalValidate"] = "FormHomePostalValidate";
2244
+ StoreFormHomePostalActionTypes["FormHomePostalValidateSet"] = "FormHomePostalValidateSet";
2245
+ StoreFormHomePostalActionTypes["FormHomePostalErrorMessageSet"] = "FormHomePostalErrorMessageSet";
2063
2246
  StoreFormHomePostalActionTypes["FormHomePostalGetLocal"] = "FormHomePostalGetLocal";
2064
2247
  })(StoreFormHomePostalActionTypes || (StoreFormHomePostalActionTypes = {}));
2065
2248
 
2066
- const setPostalStateProperty = (state, name, value) => {
2249
+ const setPostalStateProperty$1 = (state, name, value) => {
2067
2250
  const newState = deepClone(state);
2068
2251
  newState.isReady = true;
2069
- if (name === 'item') {
2070
- newState[name] = value;
2252
+ newState.isValid = false;
2253
+ if (name === 'item' || name === 'inValidation' || name === 'isValid') {
2254
+ if (typeof value === 'object') {
2255
+ newState[name] = { ...newState[name], ...value };
2256
+ }
2257
+ else {
2258
+ newState[name] = value;
2259
+ }
2071
2260
  }
2072
2261
  else {
2073
2262
  newState.item[name] = value;
@@ -2075,30 +2264,42 @@ const setPostalStateProperty = (state, name, value) => {
2075
2264
  return newState;
2076
2265
  };
2077
2266
 
2078
- const localStateName$4 = 'home_postal';
2079
- const setLocalPostal = (localIndex, state) => {
2080
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$4}`, JSON.stringify(state));
2267
+ const localStateName$8 = 'home_postal';
2268
+ const setLocalPostal$1 = (localIndex, state) => {
2269
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$8}`, JSON.stringify(state));
2081
2270
  return state;
2082
2271
  };
2083
- const getLocalPostal = (localIndex = '') => {
2084
- const localPostal = localStorage.getItem(`${localIndex}_${localStateName$4}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$4}`) || '') : null;
2272
+ const getLocalPostal$1 = (localIndex = '') => {
2273
+ const localPostal = localStorage.getItem(`${localIndex}_${localStateName$8}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$8}`) || '') : null;
2085
2274
  return localPostal || { ...formHomePostalInitialState };
2086
2275
  };
2087
2276
 
2088
2277
  const formHomePostalStateReducer = (state = { ...formHomePostalInitialState }, action) => {
2089
2278
  switch (action.type) {
2279
+ case StoreFormHomePostalActionTypes.FormHomePostalValidate:
2280
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'inValidation', action.payload.inValidation));
2281
+ case StoreFormHomePostalActionTypes.FormHomePostalValidateSet:
2282
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'isValid', action.payload.isValid));
2283
+ case StoreFormHomePostalActionTypes.FormHomePostalErrorMessageSet:
2284
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'errorMessage', action.payload.errorMessage));
2090
2285
  case StoreFormHomePostalActionTypes.FormHomePostalSet:
2091
- return setLocalPostal(action.localIndex, setPostalStateProperty(state, 'item', action.payload));
2286
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'item', action.payload));
2287
+ case StoreFormHomePostalActionTypes.FormHomePostalUnitNumberSet:
2288
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'unitNumber', action.payload.unitNumber));
2289
+ case StoreFormHomePostalActionTypes.FormHomePostalStreetAddressSet:
2290
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'streetAddress', action.payload.streetAddress));
2092
2291
  case StoreFormHomePostalActionTypes.FormHomePostalCitySet:
2093
- return setLocalPostal(action.localIndex, setPostalStateProperty(state, 'city', action.payload.city));
2292
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'city', action.payload.city));
2293
+ case StoreFormHomePostalActionTypes.FormHomePostalProvinceSet:
2294
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'provinceCode', action.payload.province));
2094
2295
  case StoreFormHomePostalActionTypes.FormHomePostalCodeSet:
2095
- return setLocalPostal(action.localIndex, setPostalStateProperty(state, 'postalCode', action.payload.postalCode));
2296
+ return setLocalPostal$1(action.localIndex, setPostalStateProperty$1(state, 'postalCode', action.payload.postalCode));
2096
2297
  case StoreFormHomePostalActionTypes.FormHomePostalGetLocal:
2097
2298
  return {
2098
- ...getLocalPostal(action.localIndex),
2299
+ ...getLocalPostal$1(action.localIndex),
2099
2300
  };
2100
2301
  case StoreFormHomePostalActionTypes.FormHomePostalClear:
2101
- return setLocalPostal(action.localIndex, { ...formHomePostalInitialState });
2302
+ return setLocalPostal$1(action.localIndex, { ...formHomePostalInitialState });
2102
2303
  default:
2103
2304
  return state;
2104
2305
  }
@@ -2106,8 +2307,6 @@ const formHomePostalStateReducer = (state = { ...formHomePostalInitialState }, a
2106
2307
 
2107
2308
  var StoreFormHomeApplicantInsuranceActionTypes;
2108
2309
  (function (StoreFormHomeApplicantInsuranceActionTypes) {
2109
- StoreFormHomeApplicantInsuranceActionTypes["FormHomeApplicantPolicyStartYearSelect"] = "FormHomeApplicantListedYearSelect";
2110
- StoreFormHomeApplicantInsuranceActionTypes["FormHomeApplicantPolicyStartMonthSelect"] = "FormHomeApplicantListedMonthSelect";
2111
2310
  StoreFormHomeApplicantInsuranceActionTypes["FormHomeApplicantInsuredCurrentSelect"] = "FormHomeApplicantInsuredCurrentSelect";
2112
2311
  StoreFormHomeApplicantInsuranceActionTypes["FormHomeApplicantDateInsuredCurrentSelect"] = "FormHomeApplicantDateInsuredCurrentSelect";
2113
2312
  StoreFormHomeApplicantInsuranceActionTypes["FormHomeApplicantDateInsuredSinceSelect"] = "FormHomeApplicantDateInsuredSinceSelect";
@@ -2117,12 +2316,15 @@ var StoreFormHomeApplicantInsuranceActionTypes;
2117
2316
  var StoreFormHomeApplicantInfoActionTypes;
2118
2317
  (function (StoreFormHomeApplicantInfoActionTypes) {
2119
2318
  StoreFormHomeApplicantInfoActionTypes["FormHomeApplicantFirstNameSet"] = "FormHomeApplicantFirstNameSet";
2120
- StoreFormHomeApplicantInfoActionTypes["FormHomeApplicantLastNameSet"] = "FormHomeApplicantLastNameSet";
2121
- StoreFormHomeApplicantInfoActionTypes["FormHomeApplicantPhoneSet"] = "FormHomeApplicantPhoneSet";
2319
+ // FormHomeApplicantLastNameSet = 'FormHomeApplicantLastNameSet',
2320
+ // FormHomeApplicantPhoneSet = 'FormHomeApplicantPhoneSet',
2122
2321
  StoreFormHomeApplicantInfoActionTypes["FormHomeApplicantBirthYearSelect"] = "FormHomeApplicantBirthYearSelect";
2123
2322
  StoreFormHomeApplicantInfoActionTypes["FormHomeApplicantBirthMonthSelect"] = "FormHomeApplicantBirthMonthSelect";
2124
2323
  StoreFormHomeApplicantInfoActionTypes["FormHomeApplicantBirthDaySelect"] = "FormHomeApplicantBirthDaySelect";
2125
2324
  StoreFormHomeApplicantInfoActionTypes["FormHomeApplicantNonsmokerSelect"] = "FormHomeApplicantNonsmokerSelect";
2325
+ // FormHomeUtmCampaignSet = 'FormHomeUtmCampaignSet',
2326
+ // FormHomeUtmSourceSet = 'FormHomeUtmSourceSet',
2327
+ // FormHomeQuoterBrokerInfoSet = 'FormHomeQuoterBrokerInfoSet',
2126
2328
  })(StoreFormHomeApplicantInfoActionTypes || (StoreFormHomeApplicantInfoActionTypes = {}));
2127
2329
 
2128
2330
  var StoreFormHomeApplicantCancellationActionTypes;
@@ -2153,32 +2355,14 @@ var StoreFormHomeApplicantBaseActionTypes;
2153
2355
  StoreFormHomeApplicantBaseActionTypes["FormHomeApplicantInitialList"] = "FormHomeApplicantInitialList";
2154
2356
  })(StoreFormHomeApplicantBaseActionTypes || (StoreFormHomeApplicantBaseActionTypes = {}));
2155
2357
 
2156
- // import {
2157
- // GenderTypes,
2158
- // OccupationTypes,
2159
- // } from '@mychoice/mychoice-sdk-components';
2160
- // export const applicantItemMinMaxDates: ApplicantMinMaxDates = {
2161
- // gMax: '',
2162
- // gMin: '',
2163
- // gBlock: true,
2164
- // gDefault: '',
2165
- // gOneMax: '',
2166
- // gOneMin: '',
2167
- // gOneBlock: true,
2168
- // gOneDefault: '',
2169
- // gTwoMax: '',
2170
- // gTwoMin: '',
2171
- // gTwoBlock: true,
2172
- // gTwoDefault: '',
2173
- // licenceAgeMax: 16,
2174
- // };
2175
2358
  const applicantCancellationItemInitialState = {
2176
- cancellationDate: '',
2359
+ date: '',
2177
2360
  cancellationMonth: '',
2178
2361
  cancellationYear: '',
2179
2362
  };
2180
2363
  const applicantClaimItemInitialState = {
2181
- claimDate: '',
2364
+ date: '',
2365
+ type: '',
2182
2366
  claimMonth: '',
2183
2367
  claimYear: '',
2184
2368
  claimType: '',
@@ -2188,14 +2372,7 @@ const applicantListInitialStates = {
2188
2372
  insuranceClaimList: { ...applicantClaimItemInitialState },
2189
2373
  };
2190
2374
  const homeFormApplicantInitialState = {
2191
- quoterInfo: {
2192
- firstName: '',
2193
- lastName: '',
2194
- phone: '',
2195
- recalculate: false,
2196
- utmCampaign: '',
2197
- utmSource: '',
2198
- },
2375
+ firstName: '',
2199
2376
  insured: {
2200
2377
  birthYear: '',
2201
2378
  birthMonth: '',
@@ -2205,8 +2382,8 @@ const homeFormApplicantInitialState = {
2205
2382
  dateInsuredCurrent: '',
2206
2383
  nonsmoker: true,
2207
2384
  },
2208
- insuredCurrent: null,
2209
- insuredBefore: null,
2385
+ insuredCurrent: undefined,
2386
+ insuredBefore: undefined,
2210
2387
  insuranceClaim: false,
2211
2388
  insuranceClaimList: [{ ...applicantClaimItemInitialState }],
2212
2389
  insuranceCancellation: false,
@@ -2215,22 +2392,25 @@ const homeFormApplicantInitialState = {
2215
2392
  isValid: false,
2216
2393
  };
2217
2394
 
2218
- const localStateName$3 = 'home_applicants';
2395
+ const localStateName$7 = 'home_applicants';
2219
2396
  const getLocalApplicants = (localIndex = '') => {
2220
- const localApplicants = localStorage.getItem(`${localIndex}_${localStateName$3}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$3}`) || '') : null;
2397
+ const localApplicants = localStorage.getItem(`${localIndex}_${localStateName$7}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$7}`) || '') : null;
2221
2398
  return localApplicants || { ...homeFormApplicantInitialState };
2222
2399
  };
2223
2400
  const setLocalApplicants = (localIndex, state) => {
2224
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$3}`, JSON.stringify(state));
2401
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$7}`, JSON.stringify(state));
2225
2402
  return state;
2226
2403
  };
2227
2404
 
2228
2405
  function setStateProperty(state, key, value, objectKey) {
2229
- const newState = deepClone(state);
2406
+ let newState = deepClone(state);
2230
2407
  if (key !== 'isValid' && key !== 'inValidation') {
2231
2408
  newState.isValid = false;
2232
2409
  }
2233
- if (objectKey) {
2410
+ if (key === 'dwelling') {
2411
+ newState = { ...newState, ...value };
2412
+ }
2413
+ else if (objectKey) {
2234
2414
  newState[objectKey][key] = value;
2235
2415
  }
2236
2416
  else {
@@ -2248,11 +2428,59 @@ function setListItemProperty(state, listKey, itemIndex, itemKey, value) {
2248
2428
  const formHomeApplicantInfoStateReducer = (state = { ...homeFormApplicantInitialState }, action) => {
2249
2429
  switch (action.type) {
2250
2430
  case StoreFormHomeApplicantInfoActionTypes.FormHomeApplicantFirstNameSet:
2251
- return setLocalApplicants(action?.localIndex, setStateProperty(state, 'firstName', action.payload.firstName, 'quoterInfo'));
2252
- case StoreFormHomeApplicantInfoActionTypes.FormHomeApplicantLastNameSet:
2253
- return setLocalApplicants(action?.localIndex, setStateProperty(state, 'lastName', action.payload.lastName, 'quoterInfo'));
2254
- case StoreFormHomeApplicantInfoActionTypes.FormHomeApplicantPhoneSet:
2255
- return setLocalApplicants(action?.localIndex, setStateProperty(state, 'phone', action.payload.phone, 'quoterInfo'));
2431
+ return setLocalApplicants(action?.localIndex, setStateProperty(state, 'firstName', action.payload.firstName));
2432
+ // case StoreFormHomeApplicantInfoActionTypes.FormHomeApplicantLastNameSet:
2433
+ // return setLocalApplicants(
2434
+ // action?.localIndex,
2435
+ // setStateProperty(
2436
+ // state,
2437
+ // 'lastName',
2438
+ // action.payload.lastName,
2439
+ // 'quoterInfo',
2440
+ // ),
2441
+ // );
2442
+ //
2443
+ // case StoreFormHomeApplicantInfoActionTypes.FormHomeApplicantPhoneSet:
2444
+ // return setLocalApplicants(
2445
+ // action?.localIndex,
2446
+ // setStateProperty(
2447
+ // state,
2448
+ // 'phone',
2449
+ // action.payload.phone,
2450
+ // 'quoterInfo',
2451
+ // ),
2452
+ // );
2453
+ // case StoreFormHomeApplicantInfoActionTypes.FormHomeUtmCampaignSet:
2454
+ // return setLocalApplicants(
2455
+ // action?.localIndex,
2456
+ // setStateProperty(
2457
+ // state,
2458
+ // 'utmCampaign',
2459
+ // action.payload.utmCampaign,
2460
+ // 'quoterInfo',
2461
+ // ),
2462
+ // );
2463
+ //
2464
+ // case StoreFormHomeApplicantInfoActionTypes.FormHomeUtmSourceSet:
2465
+ // return setLocalApplicants(
2466
+ // action?.localIndex,
2467
+ // setStateProperty(
2468
+ // state,
2469
+ // 'utmSource',
2470
+ // action.payload.utmSource,
2471
+ // 'quoterInfo',
2472
+ // ),
2473
+ // );
2474
+ // case StoreFormHomeApplicantInfoActionTypes.FormHomeQuoterBrokerInfoSet:
2475
+ // return setLocalApplicants(
2476
+ // action?.localIndex,
2477
+ // setStateProperty(
2478
+ // state,
2479
+ // 'brokerInfo',
2480
+ // action.payload.brokerInfo,
2481
+ // 'quoterInfo',
2482
+ // ),
2483
+ // );
2256
2484
  case StoreFormHomeApplicantInfoActionTypes.FormHomeApplicantBirthYearSelect:
2257
2485
  return setLocalApplicants(action?.localIndex, setStateProperty(state, 'birthYear', action.payload.birthYear, 'insured'));
2258
2486
  case StoreFormHomeApplicantInfoActionTypes.FormHomeApplicantBirthMonthSelect:
@@ -2268,10 +2496,6 @@ const formHomeApplicantInfoStateReducer = (state = { ...homeFormApplicantInitial
2268
2496
 
2269
2497
  const formHomeApplicantInsuranceStateReducer = (state = { ...homeFormApplicantInitialState }, action) => {
2270
2498
  switch (action.type) {
2271
- case StoreFormHomeApplicantInsuranceActionTypes.FormHomeApplicantPolicyStartYearSelect:
2272
- return setLocalApplicants(action?.localIndex, setStateProperty(state, 'policyStartYear', action.payload.policyStartYear));
2273
- case StoreFormHomeApplicantInsuranceActionTypes.FormHomeApplicantPolicyStartMonthSelect:
2274
- return setLocalApplicants(action?.localIndex, setStateProperty(state, 'policyStartYear', action.payload.policyStartMonth));
2275
2499
  case StoreFormHomeApplicantInsuranceActionTypes.FormHomeApplicantInsuredCurrentSelect:
2276
2500
  return setLocalApplicants(action?.localIndex, setStateProperty(state, 'insuredCurrent', action.payload.insuredCurrent));
2277
2501
  case StoreFormHomeApplicantInsuranceActionTypes.FormHomeApplicantDateInsuredSinceSelect:
@@ -2396,45 +2620,11 @@ const formHomeApplicantStateReducer = (state = { ...homeFormApplicantInitialStat
2396
2620
  return state;
2397
2621
  };
2398
2622
 
2399
- const dwellingHeatingItemInitialState = {
2400
- type: '',
2401
- };
2402
- const carFormDwellingInitialState = {
2403
- builtDate: '',
2404
- builtYear: '',
2405
- livingArea: '',
2406
- exteriorFinish: '',
2407
- constructionType: '',
2408
- garageType: '',
2409
- basementFinishPercent: 0,
2410
- storeysCount: '',
2411
- roofReplaceDate: '',
2412
- roofReplaceYear: '',
2413
- fireHallDistance: 0,
2414
- fireHydrantDistance: 0,
2415
- heatings: [
2416
- { ...dwellingHeatingItemInitialState },
2417
- { ...dwellingHeatingItemInitialState },
2418
- ],
2419
- buildingStructure: '',
2420
- replacementCost: '',
2421
- // applicant page
2422
- familiesCount: null,
2423
- occupiedDate: '',
2424
- occupiedYear: '',
2425
- // discount page
2426
- burglarAlarm: false,
2427
- fireAlarm: false,
2428
- sprinkler: false,
2429
- deadbolt: false,
2430
- fireExtinguishersCount: 0,
2431
- mortgageCount: 0,
2432
- inValidation: false,
2433
- isValid: false,
2434
- };
2435
-
2436
2623
  var StoreFormHomeDwellingActionTypes;
2437
2624
  (function (StoreFormHomeDwellingActionTypes) {
2625
+ StoreFormHomeDwellingActionTypes["FormHomeDwellingSet"] = "FormHomeDwellingSet";
2626
+ StoreFormHomeDwellingActionTypes["FormHomeDwellingIsCompleted"] = "FormHomeDwellingIsCompleted";
2627
+ StoreFormHomeDwellingActionTypes["FormHomeDwellingInsuranceTypeSelect"] = "FormHomeDwellingInsuranceTypeSelect";
2438
2628
  StoreFormHomeDwellingActionTypes["FormHomeDwellingBuiltYearSelect"] = "FormHomeDwellingBuiltYearSelect";
2439
2629
  StoreFormHomeDwellingActionTypes["FormHomeDwellingLivingAreaSelect"] = "FormHomeDwellingLivingAreaSelect";
2440
2630
  StoreFormHomeDwellingActionTypes["FormHomeDwellingExteriorFinishSelect"] = "FormHomeDwellingExteriorFinishSelect";
@@ -2455,34 +2645,78 @@ var StoreFormHomeDwellingActionTypes;
2455
2645
  StoreFormHomeDwellingActionTypes["FormHomeDwellingSprinklerSelect"] = "FormHomeDwellingSprinklerSelect";
2456
2646
  StoreFormHomeDwellingActionTypes["FormHomeDwellingDeadboltSelect"] = "FormHomeDwellingDeadboltSelect";
2457
2647
  StoreFormHomeDwellingActionTypes["FormHomeDwellingFireExtinguishersCountSelect"] = "FormHomeDwellingFireExtinguishersCountSelect";
2458
- StoreFormHomeDwellingActionTypes["FormHomeDwellingMortgageCountSelect"] = "FormHomeDwellingMortgageCountSelect";
2648
+ StoreFormHomeDwellingActionTypes["FormHomeDwellingMortgagesCountSelect"] = "FormHomeDwellingMortgagesCountSelect";
2649
+ StoreFormHomeDwellingActionTypes["FormHomeDwellingUnitsCountSelect"] = "FormHomeDwellingUnitsCountSelect";
2459
2650
  StoreFormHomeDwellingActionTypes["FormHomeDwellingValidate"] = "FormHomeDwellingValidate";
2460
2651
  StoreFormHomeDwellingActionTypes["FormHomeDwellingValidateSet"] = "FormHomeDwellingValidateSet";
2461
2652
  StoreFormHomeDwellingActionTypes["FormHomeDwellingGetLocal"] = "FormHomeDwellingGetLocal";
2653
+ StoreFormHomeDwellingActionTypes["FormHomeDeductibleCoverageSelect"] = "FormHomeDeductibleCoverageSelect";
2654
+ StoreFormHomeDwellingActionTypes["FormHomeLiabilityCoverageSelect"] = "FormHomeLiabilityCoverageSelect";
2655
+ StoreFormHomeDwellingActionTypes["FormHomePpSelect"] = "FormHomePpSelect";
2656
+ StoreFormHomeDwellingActionTypes["FormHomeWaterCoverageSelect"] = "FormHomeWaterCoverageSelect";
2657
+ StoreFormHomeDwellingActionTypes["FormHomeDwellingClear"] = "FormHomeDwellingClear";
2462
2658
  })(StoreFormHomeDwellingActionTypes || (StoreFormHomeDwellingActionTypes = {}));
2463
2659
 
2464
- const localStateName$2 = 'home_dwellings';
2660
+ const getInsuranceType$1 = () => {
2661
+ const pathParts = window.location.pathname.split('/');
2662
+ if (pathParts.includes('car')) {
2663
+ return InsuranceTypes.Car;
2664
+ }
2665
+ if (pathParts.includes('home')) {
2666
+ return InsuranceTypes.Home;
2667
+ }
2668
+ if (pathParts.includes('condo')) {
2669
+ return InsuranceTypes.Condo;
2670
+ }
2671
+ if (pathParts.includes('tenant')) {
2672
+ return InsuranceTypes.Tenant;
2673
+ }
2674
+ return InsuranceTypes.Car;
2675
+ };
2676
+ const localStateName$6 = `${getInsuranceType$1()}_dwellings`;
2465
2677
  const getLocalDwellings = (localIndex = '') => {
2466
- const localDwellings = localStorage.getItem(`${localIndex}_${localStateName$2}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$2}`) || '') : null;
2467
- return localDwellings || { ...carFormDwellingInitialState };
2678
+ const localDwellings = localStorage.getItem(`${localIndex}_${localStateName$6}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$6}`) || '') : null;
2679
+ return localDwellings || { ...getDwellingInitialState(getInsuranceType$1()) };
2468
2680
  };
2469
2681
  const setLocalDwellings = (localIndex, state) => {
2470
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$2}`, JSON.stringify(state));
2682
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$6}`, JSON.stringify(state));
2471
2683
  return state;
2472
2684
  };
2473
2685
 
2474
- const formHomeDwellingStateReducer = (state = { ...carFormDwellingInitialState }, action) => {
2686
+ const getInsuranceType = () => {
2687
+ const pathParts = window.location.pathname.split('/');
2688
+ if (pathParts.includes('car')) {
2689
+ return InsuranceTypes.Car;
2690
+ }
2691
+ if (pathParts.includes('home')) {
2692
+ return InsuranceTypes.Home;
2693
+ }
2694
+ if (pathParts.includes('condo')) {
2695
+ return InsuranceTypes.Condo;
2696
+ }
2697
+ if (pathParts.includes('tenant')) {
2698
+ return InsuranceTypes.Tenant;
2699
+ }
2700
+ return InsuranceTypes.Car;
2701
+ };
2702
+ const formHomeDwellingStateReducer = (state = { ...getDwellingInitialState(getInsuranceType()) }, action) => {
2475
2703
  switch (action.type) {
2476
2704
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingValidate:
2477
2705
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'inValidation', action.payload.inValidation));
2706
+ case StoreFormHomeDwellingActionTypes.FormHomeDwellingSet:
2707
+ return setLocalDwellings(action.localIndex, setStateProperty(state, 'dwelling', action.payload));
2478
2708
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingValidateSet:
2479
2709
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'isValid', action.payload.isValid));
2480
2710
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingGetLocal:
2481
2711
  return {
2482
2712
  ...getLocalDwellings(action.localIndex),
2483
2713
  };
2714
+ case StoreFormHomeDwellingActionTypes.FormHomeDwellingIsCompleted:
2715
+ return setLocalDwellings(action.localIndex, setStateProperty(state, 'isCompleted', action.payload.isCompleted));
2484
2716
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingBuiltYearSelect:
2485
2717
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'builtYear', action.payload.builtYear));
2718
+ case StoreFormHomeDwellingActionTypes.FormHomeDwellingBuildingStructureSelect:
2719
+ return setLocalDwellings(action.localIndex, setStateProperty(state, 'buildingStructure', action.payload.buildingStructure));
2486
2720
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingLivingAreaSelect:
2487
2721
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'livingArea', action.payload.livingArea));
2488
2722
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingExteriorFinishSelect:
@@ -2496,15 +2730,15 @@ const formHomeDwellingStateReducer = (state = { ...carFormDwellingInitialState }
2496
2730
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingStoreysCountSelect:
2497
2731
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'storeysCount', action.payload.storeysCount));
2498
2732
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingRoofReplaceYearSelect:
2499
- return setLocalDwellings(action.localIndex, setStateProperty(state, 'roofReplaceYear', action.payload.roofReplaceYear));
2733
+ return setLocalDwellings(action.localIndex, setStateProperty(state, 'roofReplacedYear', action.payload.roofReplacedYear));
2500
2734
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingFireHallDistanceSelect:
2501
2735
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'fireHallDistance', action.payload.fireHallDistance));
2502
2736
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingFireHydrantDistanceSelect:
2503
2737
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'fireHydrantDistance', action.payload.fireHydrantDistance));
2504
2738
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingHeatingSelect:
2505
2739
  return setLocalDwellings(action.localIndex, setListItemProperty(state, 'heatings', action.payload.index, 'type', action.payload.type));
2506
- case StoreFormHomeDwellingActionTypes.FormHomeDwellingBuildingStructureSelect:
2507
- return setLocalDwellings(action.localIndex, setStateProperty(state, 'buildingStructure', action.payload.buildingStructure));
2740
+ case StoreFormHomeDwellingActionTypes.FormHomeDwellingUnitsCountSelect:
2741
+ return setLocalDwellings(action.localIndex, setStateProperty(state, 'unitsCount', action.payload.unitsCount));
2508
2742
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingReplacementCostSelect:
2509
2743
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'replacementCost', action.payload.replacementCost));
2510
2744
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingFamiliesCountSelect:
@@ -2521,24 +2755,18 @@ const formHomeDwellingStateReducer = (state = { ...carFormDwellingInitialState }
2521
2755
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'deadbolt', action.payload.deadbolt));
2522
2756
  case StoreFormHomeDwellingActionTypes.FormHomeDwellingFireExtinguishersCountSelect:
2523
2757
  return setLocalDwellings(action.localIndex, setStateProperty(state, 'fireExtinguishersCount', action.payload.fireExtinguishersCount));
2524
- case StoreFormHomeDwellingActionTypes.FormHomeDwellingMortgageCountSelect:
2525
- return setLocalDwellings(action.localIndex, setStateProperty(state, 'mortgageCount', action.payload.mortgageCount));
2526
- // case StoreFormHomeDwellingActionTypes.FormHomeCollisionCoverageSelect:
2527
- // return setLocalDwellings(
2528
- // action.localIndex,
2529
- // setCoverageProperty(state, 'collision', action.payload.coverage, action.payload.deductible),
2530
- // );
2531
- //
2532
- // case StoreFormHomeDwellingActionTypes.FormHomeLiabilityCoverageSelect:
2533
- // return setLocalDwellings(
2534
- // action.localIndex,
2535
- // setCoverageProperty(state, 'liability', action.payload.coverage, action.payload.limit),
2536
- // );
2537
- // case StoreFormHomeDwellingActionTypes.FormHomeDwellingClear:
2538
- // return setLocalDwellings(
2539
- // action.localIndex,
2540
- // { ...carFormDwellingInitialState },
2541
- // );
2758
+ case StoreFormHomeDwellingActionTypes.FormHomeDwellingMortgagesCountSelect:
2759
+ return setLocalDwellings(action.localIndex, setStateProperty(state, 'mortgagesCount', action.payload.mortgagesCount));
2760
+ case StoreFormHomeDwellingActionTypes.FormHomeDeductibleCoverageSelect:
2761
+ return setLocalDwellings(action.localIndex, setHomeCoverageProperty(state, 'deductible', action.payload.deductible));
2762
+ case StoreFormHomeDwellingActionTypes.FormHomeLiabilityCoverageSelect:
2763
+ return setLocalDwellings(action.localIndex, setHomeCoverageProperty(state, 'liability', action.payload.liability));
2764
+ case StoreFormHomeDwellingActionTypes.FormHomePpSelect:
2765
+ return setLocalDwellings(action.localIndex, setHomeCoverageProperty(state, 'pp', action.payload.pp));
2766
+ case StoreFormHomeDwellingActionTypes.FormHomeWaterCoverageSelect:
2767
+ return setLocalDwellings(action.localIndex, setHomeCoverageProperty(state, 'waterCoverage', action.payload.waterCoverage));
2768
+ case StoreFormHomeDwellingActionTypes.FormHomeDwellingClear:
2769
+ return setLocalDwellings(action.localIndex, { ...getDwellingInitialState(action.payload.type) });
2542
2770
  default:
2543
2771
  return state;
2544
2772
  }
@@ -2549,11 +2777,25 @@ const formHomeDiscountStateInitialState = {
2549
2777
  email: '',
2550
2778
  emailStatus: ValidationStatusTypes.Initial,
2551
2779
  },
2780
+ quoterInfo: {
2781
+ firstName: '',
2782
+ lastName: '',
2783
+ phone: '',
2784
+ recalculate: false,
2785
+ utmCampaign: '',
2786
+ utmSource: '',
2787
+ brokerInfo: {
2788
+ phone: defaultBrokerPhone,
2789
+ },
2790
+ splashScreen: false,
2791
+ caslConsent: false,
2792
+ initial: true,
2793
+ },
2552
2794
  multiplePoliciesDiscount: true,
2553
2795
  policyStart: getFormattedDate('', 'yyyy-MM-dd'),
2554
- policyStartDay: getFormattedDate('', 'dd'),
2555
- policyStartMonth: getFormattedDate('', 'MM'),
2556
- policyStartYear: getFormattedDate('', 'yyyy'),
2796
+ policyStartDay: getFormattedDate(addDaysToDate('', 1), 'dd'),
2797
+ policyStartMonth: getFormattedDate(addDaysToDate('', 1), 'MM'),
2798
+ policyStartYear: getFormattedDate(addDaysToDate('', 1), 'yyyy'),
2557
2799
  inValidation: false,
2558
2800
  isValid: false,
2559
2801
  };
@@ -2567,32 +2809,40 @@ var StoreFormHomeDiscountActionTypes;
2567
2809
  StoreFormHomeDiscountActionTypes["FormHomeDiscountMultiplePoliciesSelect"] = "FormHomeDiscountMultiplePoliciesSelect";
2568
2810
  StoreFormHomeDiscountActionTypes["FormHomeDiscountQuoterEmailSet"] = "FormHomeDiscountQuoterEmailSet";
2569
2811
  StoreFormHomeDiscountActionTypes["FormHomeDiscountQuoterEmailStatusSet"] = "FormHomeDiscountQuoterEmailStatusSet";
2812
+ StoreFormHomeDiscountActionTypes["FormHomeDiscountQuoterCaslConsentSet"] = "FormHomeDiscountQuoterCaslConsentSet";
2570
2813
  StoreFormHomeDiscountActionTypes["FormHomeDiscountValidate"] = "FormHomeDiscountValidate";
2571
2814
  StoreFormHomeDiscountActionTypes["FormHomeDiscountValidateSet"] = "FormHomeDiscountValidateSet";
2572
2815
  StoreFormHomeDiscountActionTypes["FormHomeDiscountClear"] = "FormHomeDiscountClear";
2816
+ StoreFormHomeDiscountActionTypes["FormHomeQuoterFirstNameSet"] = "FormHomeQuoterFirstNameSet";
2817
+ StoreFormHomeDiscountActionTypes["FormHomeQuoterLastNameSet"] = "FormHomeQuoterLastNameSet";
2818
+ StoreFormHomeDiscountActionTypes["FormHomeQuoterPhoneSet"] = "FormHomeQuoterPhoneSet";
2819
+ StoreFormHomeDiscountActionTypes["FormHomeUtmCampaignSet"] = "FormHomeUtmCampaignSet";
2820
+ StoreFormHomeDiscountActionTypes["FormHomeUtmSourceSet"] = "FormHomeUtmSourceSet";
2821
+ StoreFormHomeDiscountActionTypes["FormHomeQuoterBrokerInfoSet"] = "FormHomeQuoterBrokerInfoSet";
2822
+ StoreFormHomeDiscountActionTypes["FormHomeDiscountQuoterInitialSet"] = "FormHomeDiscountQuoterInitialSet";
2573
2823
  })(StoreFormHomeDiscountActionTypes || (StoreFormHomeDiscountActionTypes = {}));
2574
2824
 
2575
- const localStateName$1 = 'home_discounts';
2825
+ const localStateName$5 = 'home_discounts';
2576
2826
  const getLocalDiscounts = (localIndex = '') => {
2577
- const localDiscounts = localStorage.getItem(`${localIndex}_${localStateName$1}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$1}`) || '') : null;
2827
+ const localDiscounts = localStorage.getItem(`${localIndex}_${localStateName$5}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$5}`) || '') : null;
2578
2828
  return localDiscounts || { ...formHomeDiscountStateInitialState };
2579
2829
  };
2580
2830
  const setLocalDiscounts = (localIndex, state) => {
2581
2831
  if (state.emailTo.emailStatus === ValidationStatusTypes.Approved) {
2582
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$1}`, JSON.stringify(state));
2832
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$5}`, JSON.stringify(state));
2583
2833
  return state;
2584
2834
  }
2585
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$1}`, JSON.stringify(state));
2835
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$5}`, JSON.stringify(state));
2586
2836
  return state;
2587
2837
  };
2588
2838
  const setLocalDiscountsEmail = (localIndex, state) => {
2589
2839
  if (state.emailTo.emailStatus === ValidationStatusTypes.Approved) {
2590
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$1}`, JSON.stringify(state));
2840
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$5}`, JSON.stringify(state));
2591
2841
  }
2592
2842
  else {
2593
2843
  const newState = deepClone(state);
2594
2844
  newState.emailTo = { email: '', emailStatus: ValidationStatusTypes.Initial };
2595
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$1}`, JSON.stringify(newState));
2845
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$5}`, JSON.stringify(newState));
2596
2846
  }
2597
2847
  return state;
2598
2848
  };
@@ -2617,6 +2867,22 @@ const formHomeDiscountStateReducer = (state = { ...formHomeDiscountStateInitialS
2617
2867
  return setLocalDiscounts(action.localIndex, setStateProperty(state, 'policyStartMonth', action.payload.policyStartMonth));
2618
2868
  case StoreFormHomeDiscountActionTypes.FormHomeDiscountPolicyStartYearSelect:
2619
2869
  return setLocalDiscounts(action.localIndex, setStateProperty(state, 'policyStartYear', action.payload.policyStartYear));
2870
+ case StoreFormHomeDiscountActionTypes.FormHomeDiscountQuoterCaslConsentSet:
2871
+ return setLocalDiscounts(action.localIndex, setStateProperty(state, 'caslConsent', action.payload.caslConsent, 'quoterInfo'));
2872
+ case StoreFormHomeDiscountActionTypes.FormHomeQuoterFirstNameSet:
2873
+ return setLocalDiscounts(action.localIndex, setStateProperty(state, 'firstName', action.payload.firstName, 'quoterInfo'));
2874
+ case StoreFormHomeDiscountActionTypes.FormHomeQuoterLastNameSet:
2875
+ return setLocalDiscounts(action.localIndex, setStateProperty(state, 'lastName', action.payload.lastName, 'quoterInfo'));
2876
+ case StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneSet:
2877
+ return setLocalDiscounts(action.localIndex, setStateProperty(state, 'phone', action.payload.phone, 'quoterInfo'));
2878
+ case StoreFormHomeDiscountActionTypes.FormHomeUtmSourceSet:
2879
+ return setLocalDiscounts(action.localIndex, setStateProperty(state, 'utmSource', action.payload.utmSource, 'quoterInfo'));
2880
+ case StoreFormHomeDiscountActionTypes.FormHomeUtmCampaignSet:
2881
+ return setLocalDiscounts(action.localIndex, setStateProperty(state, 'utmCampaign', action.payload.utmCampaign, 'quoterInfo'));
2882
+ case StoreFormHomeDiscountActionTypes.FormHomeDiscountQuoterInitialSet:
2883
+ return setLocalDiscounts(action.localIndex, setStateProperty(state, 'initial', action.payload.initial, 'quoterInfo'));
2884
+ case StoreFormHomeDiscountActionTypes.FormHomeQuoterBrokerInfoSet:
2885
+ return setLocalDiscounts(action.localIndex, setStateProperty(state, 'brokerInfo', action.payload.brokerInfo, 'quoterInfo'));
2620
2886
  case StoreFormHomeDiscountActionTypes.FormHomeDiscountClear:
2621
2887
  return setLocalDiscounts(action.localIndex, { ...formHomeDiscountStateInitialState });
2622
2888
  default:
@@ -2624,53 +2890,56 @@ const formHomeDiscountStateReducer = (state = { ...formHomeDiscountStateInitialS
2624
2890
  }
2625
2891
  };
2626
2892
 
2627
- const formHomeAddressStateInitialState = {
2628
- type: null,
2629
- addressStreet: '',
2630
- unitApartmentNumber: '',
2631
- inValidation: false,
2632
- isValid: false,
2893
+ const formHomeQuoteInitialState = {
2894
+ items: [],
2895
+ isRequested: false,
2896
+ requestDate: new Date().toISOString(),
2897
+ showCallMessage: false,
2633
2898
  };
2634
2899
 
2635
- var StoreFormHomeAddressActionTypes;
2636
- (function (StoreFormHomeAddressActionTypes) {
2637
- StoreFormHomeAddressActionTypes["FormHomeAddressGetLocal"] = "FormHomeAddressGetLocal";
2638
- StoreFormHomeAddressActionTypes["FormHomeAddressTypeSelect"] = "FormHomeAddressTypeSelect";
2639
- StoreFormHomeAddressActionTypes["FormHomeAddressStreetSet"] = "FormHomeAddressStreetSet";
2640
- StoreFormHomeAddressActionTypes["FormHomeAddressUnitApartmentNumberSet"] = "FormHomeAddressUnitApartmentNumberSet";
2641
- StoreFormHomeAddressActionTypes["FormHomeAddressValidate"] = "FormHomeAddressValidate";
2642
- StoreFormHomeAddressActionTypes["FormHomeAddressValidateSet"] = "FormHomeAddressValidateSet";
2643
- StoreFormHomeAddressActionTypes["FormHomeAddressClear"] = "FormHomeAddressClear";
2644
- })(StoreFormHomeAddressActionTypes || (StoreFormHomeAddressActionTypes = {}));
2900
+ var StoreFormHomeQuoteActionTypes;
2901
+ (function (StoreFormHomeQuoteActionTypes) {
2902
+ StoreFormHomeQuoteActionTypes["UpdateHomeQuoteResponse"] = "UpdateHomeQuoteResponse";
2903
+ StoreFormHomeQuoteActionTypes["FormHomeQuoteIsRequestedSet"] = "FormHomeQuoteIsRequestedSet";
2904
+ StoreFormHomeQuoteActionTypes["FormHomeQuoteRequestDateSet"] = "FormHomeQuoteRequestDateSet";
2905
+ StoreFormHomeQuoteActionTypes["FormHomeQuotesSet"] = "FormHomeQuotesSet";
2906
+ StoreFormHomeQuoteActionTypes["FormHomeQuoteGetLocal"] = "FormHomeQuoteGetLocal";
2907
+ StoreFormHomeQuoteActionTypes["FormHomeQuoteClear"] = "FormHomeQuoteClear";
2908
+ StoreFormHomeQuoteActionTypes["UpdateHomeCallMessage"] = "UpdateHomeCallMessage";
2909
+ })(StoreFormHomeQuoteActionTypes || (StoreFormHomeQuoteActionTypes = {}));
2645
2910
 
2646
- const localStateName = 'home_address';
2647
- const getLocalAddresss = (localIndex = '') => {
2648
- const localAddress = localStorage.getItem(`${localIndex}_${localStateName}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName}`) || '') : null;
2649
- return localAddress || { ...formHomeAddressStateInitialState };
2911
+ const setQuoteStateProperty$1 = (state, name, value) => {
2912
+ const newState = deepClone(state);
2913
+ newState[name] = value;
2914
+ return newState;
2650
2915
  };
2651
- const setLocalAddresss = (localIndex, state) => {
2652
- localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName}`, JSON.stringify(state));
2916
+
2917
+ const localStateName$4 = 'home_quotes';
2918
+ const setLocalQuotes$1 = (localIndex, state) => {
2919
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$4}`, JSON.stringify(state));
2653
2920
  return state;
2654
2921
  };
2922
+ const getLocalQuotes$1 = (localIndex = '') => {
2923
+ const localQuotes = localStorage.getItem(`${localIndex}_${localStateName$4}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$4}`) || '') : null;
2924
+ return localQuotes || { ...formHomeQuoteInitialState };
2925
+ };
2655
2926
 
2656
- const formHomeAddressStateReducer = (state = { ...formHomeAddressStateInitialState }, action) => {
2927
+ const formHomeQuoteStateReducer = (state = { ...formHomeQuoteInitialState }, action) => {
2657
2928
  switch (action.type) {
2658
- case StoreFormHomeAddressActionTypes.FormHomeAddressValidate:
2659
- return setLocalAddresss(action.localIndex, setStateProperty(state, 'inValidation', action.payload.inValidation));
2660
- case StoreFormHomeAddressActionTypes.FormHomeAddressValidateSet:
2661
- return setLocalAddresss(action.localIndex, setStateProperty(state, 'isValid', action.payload.isValid));
2662
- case StoreFormHomeAddressActionTypes.FormHomeAddressGetLocal:
2929
+ case StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet:
2930
+ return setLocalQuotes$1(action.localIndex, setQuoteStateProperty$1(state, 'isRequested', action.payload.isRequested));
2931
+ case StoreFormHomeQuoteActionTypes.FormHomeQuotesSet:
2932
+ return setLocalQuotes$1(action.localIndex, setQuoteStateProperty$1(state, 'items', action.payload.items));
2933
+ case StoreFormHomeQuoteActionTypes.FormHomeQuoteRequestDateSet:
2934
+ return setLocalQuotes$1(action.localIndex, setQuoteStateProperty$1(state, 'requestDate', action.payload.requestDate));
2935
+ case StoreFormHomeQuoteActionTypes.FormHomeQuoteGetLocal:
2663
2936
  return {
2664
- ...getLocalAddresss(action.localIndex),
2937
+ ...getLocalQuotes$1(action.localIndex),
2665
2938
  };
2666
- case StoreFormHomeAddressActionTypes.FormHomeAddressTypeSelect:
2667
- return setLocalAddresss(action.localIndex, setStateProperty(state, 'type', action.payload.type));
2668
- case StoreFormHomeAddressActionTypes.FormHomeAddressStreetSet:
2669
- return setLocalAddresss(action.localIndex, setStateProperty(state, 'addressStreet', action.payload.addressStreet));
2670
- case StoreFormHomeAddressActionTypes.FormHomeAddressUnitApartmentNumberSet:
2671
- return setLocalAddresss(action.localIndex, setStateProperty(state, 'unitApartmentNumber', action.payload.unitApartmentNumber));
2672
- case StoreFormHomeAddressActionTypes.FormHomeAddressClear:
2673
- return setLocalAddresss(action.localIndex, { ...formHomeAddressStateInitialState });
2939
+ case StoreFormHomeQuoteActionTypes.FormHomeQuoteClear:
2940
+ return setLocalQuotes$1(action.localIndex, { ...formHomeQuoteInitialState });
2941
+ case StoreFormHomeQuoteActionTypes.UpdateHomeCallMessage:
2942
+ return setLocalQuotes$1(action.localIndex, setQuoteStateProperty$1(state, 'showCallMessage', action.payload.showCallMessage));
2674
2943
  default:
2675
2944
  return state;
2676
2945
  }
@@ -2678,48 +2947,301 @@ const formHomeAddressStateReducer = (state = { ...formHomeAddressStateInitialSta
2678
2947
 
2679
2948
  const formHomeReducer = combineReducers({
2680
2949
  postalState: formHomePostalStateReducer,
2681
- addressState: formHomeAddressStateReducer,
2682
2950
  applicantState: formHomeApplicantStateReducer,
2683
2951
  dwellingState: formHomeDwellingStateReducer,
2684
2952
  discountState: formHomeDiscountStateReducer,
2685
- // quoteState: formHomeQuoteStateReducer,
2953
+ quoteState: formHomeQuoteStateReducer,
2686
2954
  });
2687
2955
 
2688
- const reducers = combineReducers({
2689
- globalState: globalStateReducer,
2690
- configState: configStateReducer,
2691
- formCarState: formCarReducer,
2692
- formHomeState: formHomeReducer,
2693
- });
2956
+ const formLifeCoverageStateInitialState = {
2957
+ province: '',
2958
+ type: '',
2959
+ coverage: '',
2960
+ inValidation: false,
2961
+ isValid: false,
2962
+ };
2694
2963
 
2695
- const store = createStore(reducers, composeWithDevTools(applyMiddleware(thunk)));
2964
+ var StoreFormLifeCoverageActionTypes;
2965
+ (function (StoreFormLifeCoverageActionTypes) {
2966
+ StoreFormLifeCoverageActionTypes["FormLifeCoverageGetLocal"] = "FormLifeCoverageGetLocal";
2967
+ StoreFormLifeCoverageActionTypes["FormLifeProvinceSelect"] = "FormLifeProvinceSelect";
2968
+ StoreFormLifeCoverageActionTypes["FormLifeCoverageTypeSelect"] = "FormLifeCoverageTypeSelect";
2969
+ StoreFormLifeCoverageActionTypes["FormLifeCoverageSelect"] = "FormLifeCoverageSelect";
2970
+ StoreFormLifeCoverageActionTypes["FormLifeCoverageValidate"] = "FormLifeCoverageValidate";
2971
+ StoreFormLifeCoverageActionTypes["FormLifeCoverageValidateSet"] = "FormLifeCoverageValidateSet";
2972
+ StoreFormLifeCoverageActionTypes["FormLifeCoverageClear"] = "FormLifeCoverageClear";
2973
+ })(StoreFormLifeCoverageActionTypes || (StoreFormLifeCoverageActionTypes = {}));
2696
2974
 
2697
- const StoreProvider = ({ children }) => (jsx(Provider, { store: store, children: children
2698
- && children }));
2975
+ const localStateName$3 = 'life_coverage';
2976
+ const getLocalCoverages = (localIndex = '') => {
2977
+ const localCoverage = localStorage.getItem(`${localIndex}_${localStateName$3}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$3}`) || '') : null;
2978
+ return localCoverage || { ...formLifeCoverageStateInitialState };
2979
+ };
2980
+ const setLocalCoverages = (localIndex, state) => {
2981
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$3}`, JSON.stringify(state));
2982
+ return state;
2983
+ };
2699
2984
 
2700
- const useTypedSelector = useSelector;
2985
+ const formLifeCoverageStateReducer = (state = { ...formLifeCoverageStateInitialState }, action) => {
2986
+ switch (action.type) {
2987
+ case StoreFormLifeCoverageActionTypes.FormLifeCoverageValidate:
2988
+ return setLocalCoverages(action.localIndex, setStateProperty(state, 'inValidation', action.payload.inValidation));
2989
+ case StoreFormLifeCoverageActionTypes.FormLifeCoverageValidateSet:
2990
+ return setLocalCoverages(action.localIndex, setStateProperty(state, 'isValid', action.payload.isValid));
2991
+ case StoreFormLifeCoverageActionTypes.FormLifeCoverageGetLocal:
2992
+ return {
2993
+ ...getLocalCoverages(action.localIndex),
2994
+ };
2995
+ case StoreFormLifeCoverageActionTypes.FormLifeProvinceSelect:
2996
+ return setLocalCoverages(action.localIndex, setStateProperty(state, 'province', action.payload.province));
2997
+ case StoreFormLifeCoverageActionTypes.FormLifeCoverageTypeSelect:
2998
+ return setLocalCoverages(action.localIndex, setStateProperty(state, 'type', action.payload.type));
2999
+ case StoreFormLifeCoverageActionTypes.FormLifeCoverageSelect:
3000
+ return setLocalCoverages(action.localIndex, setStateProperty(state, 'coverage', action.payload.coverage));
3001
+ case StoreFormLifeCoverageActionTypes.FormLifeCoverageClear:
3002
+ return setLocalCoverages(action.localIndex, { ...formLifeCoverageStateInitialState });
3003
+ default:
3004
+ return state;
3005
+ }
3006
+ };
2701
3007
 
2702
- const useStoreAppConfig = () => {
2703
- const { appConfigState } = useTypedSelector((state) => state).configState;
2704
- const dispatch = useDispatch();
2705
- return {
2706
- appConfigState,
2707
- dispatchAppConfigState: dispatch,
2708
- };
3008
+ const lifeFormApplicantInitialState = {
3009
+ birthYear: '',
3010
+ birthMonth: '',
3011
+ birthDay: '',
3012
+ gender: GenderTypes.Male,
3013
+ smoker: false,
3014
+ emailTo: {
3015
+ email: '',
3016
+ emailStatus: ValidationStatusTypes.Initial,
3017
+ },
3018
+ quoterInfo: {
3019
+ firstName: '',
3020
+ lastName: '',
3021
+ phone: '',
3022
+ recalculate: false,
3023
+ utmCampaign: '',
3024
+ utmSource: '',
3025
+ },
3026
+ inValidation: false,
3027
+ isValid: false,
2709
3028
  };
2710
3029
 
2711
- const useStoreClient = () => {
2712
- const { appConfigState } = useStoreAppConfig();
2713
- const { clientState } = useTypedSelector((state) => state).globalState;
2714
- const dispatch = useDispatch();
2715
- const dispatchClientState = useMemo(() => (props) => {
2716
- dispatch({
2717
- ...props,
2718
- payload: props.payload,
2719
- index: appConfigState.localIndex,
2720
- });
2721
- }, [appConfigState.localIndex]);
2722
- return {
3030
+ const localStateName$2 = 'life_applicants';
3031
+ const getLocalApplicant = (localIndex = '') => {
3032
+ const localApplicants = localStorage.getItem(`${localIndex}_${localStateName$2}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$2}`) || '') : null;
3033
+ return localApplicants || { ...lifeFormApplicantInitialState };
3034
+ };
3035
+ const setLocalApplicant = (localIndex, state) => {
3036
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$2}`, JSON.stringify(state));
3037
+ return state;
3038
+ };
3039
+
3040
+ var StoreFormLifeApplicantActionTypes;
3041
+ (function (StoreFormLifeApplicantActionTypes) {
3042
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantGetLocal"] = "FormLifeApplicantGetLocal";
3043
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantValidate"] = "FormLifeApplicantValidate";
3044
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantValidateSet"] = "FormLifeApplicantValidateSet";
3045
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantClear"] = "FormLifeApplicantClear";
3046
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantGenderSelect"] = "FormLifeApplicantGenderSelect";
3047
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantBirthYearSelect"] = "FormLifeApplicantBirthYearSelect";
3048
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantBirthMonthSelect"] = "FormLifeApplicantBirthMonthSelect";
3049
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantBirthDaySelect"] = "FormLifeApplicantBirthDaySelect";
3050
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantSmokerSelect"] = "FormLifeApplicantSmokerSelect";
3051
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantEmailSet"] = "FormLifeApplicantEmailSet";
3052
+ StoreFormLifeApplicantActionTypes["FormLifeApplicantEmailStatusSet"] = "FormLifeApplicantEmailStatusSet";
3053
+ // Quoter info
3054
+ StoreFormLifeApplicantActionTypes["FormLifeQuoterFirstNameSet"] = "FormLifeQuoterFirstNameSet";
3055
+ StoreFormLifeApplicantActionTypes["FormLifeQuoterLastNameSet"] = "FormLifeQuoterLastNameSet";
3056
+ StoreFormLifeApplicantActionTypes["FormLifeQuoterPhoneSet"] = "FormLifeQuoterPhoneSet";
3057
+ StoreFormLifeApplicantActionTypes["FormLifeUtmCampaignSet"] = "FormLifeUtmCampaignSet";
3058
+ StoreFormLifeApplicantActionTypes["FormLifeUtmSourceSet"] = "FormLifeUtmSourceSet";
3059
+ })(StoreFormLifeApplicantActionTypes || (StoreFormLifeApplicantActionTypes = {}));
3060
+
3061
+ const formLifeApplicantStateReducer = (state = { ...lifeFormApplicantInitialState }, action) => {
3062
+ switch (action.type) {
3063
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantValidate:
3064
+ return setLocalApplicant(action.localIndex, setStateProperty(state, 'inValidation', action.payload.inValidation));
3065
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantValidateSet:
3066
+ return setLocalApplicant(action.localIndex, setStateProperty(state, 'isValid', action.payload.isValid));
3067
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantGetLocal:
3068
+ return {
3069
+ ...getLocalApplicant(action?.localIndex),
3070
+ };
3071
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantClear:
3072
+ return setLocalApplicant(action.localIndex, { ...lifeFormApplicantInitialState });
3073
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantGenderSelect:
3074
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'gender', action.payload.gender));
3075
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantBirthYearSelect:
3076
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'birthYear', action.payload.birthYear));
3077
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantBirthMonthSelect:
3078
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'birthMonth', action.payload.birthMonth));
3079
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantBirthDaySelect:
3080
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'birthDay', action.payload.birthDay));
3081
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantSmokerSelect:
3082
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'nonsmoker', action.payload.smoker));
3083
+ case StoreFormLifeApplicantActionTypes.FormLifeApplicantEmailSet:
3084
+ return setLocalApplicant(action.localIndex, setStateProperty(state, 'emailTo', action.payload));
3085
+ // quoter info
3086
+ case StoreFormLifeApplicantActionTypes.FormLifeQuoterFirstNameSet:
3087
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'firstName', action.payload.firstName, 'quoterInfo'));
3088
+ case StoreFormLifeApplicantActionTypes.FormLifeQuoterLastNameSet:
3089
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'lastName', action.payload.lastName, 'quoterInfo'));
3090
+ case StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneSet:
3091
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'phone', action.payload.phone, 'quoterInfo'));
3092
+ case StoreFormLifeApplicantActionTypes.FormLifeUtmSourceSet:
3093
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'utmSource', action.payload.utmSource, 'quoterInfo'));
3094
+ case StoreFormLifeApplicantActionTypes.FormLifeUtmCampaignSet:
3095
+ return setLocalApplicant(action?.localIndex, setStateProperty(state, 'utmCampaign', action.payload.utmCampaign, 'quoterInfo'));
3096
+ default:
3097
+ return state;
3098
+ }
3099
+ };
3100
+
3101
+ const formLifeQuoteInitialState = {
3102
+ items: [],
3103
+ isRequested: false,
3104
+ requestDate: new Date().toISOString(),
3105
+ showCallMessage: false,
3106
+ };
3107
+
3108
+ var StoreFormLifeQuoteActionTypes;
3109
+ (function (StoreFormLifeQuoteActionTypes) {
3110
+ StoreFormLifeQuoteActionTypes["UpdateLifeQuoteResponse"] = "UpdateLifeQuoteResponse";
3111
+ StoreFormLifeQuoteActionTypes["FormLifeQuoteIsRequestedSet"] = "FormLifeQuoteIsRequestedSet";
3112
+ StoreFormLifeQuoteActionTypes["FormLifeQuoteRequestDateSet"] = "FormLifeQuoteRequestDateSet";
3113
+ StoreFormLifeQuoteActionTypes["FormLifeQuotesSet"] = "FormLifeQuotesSet";
3114
+ StoreFormLifeQuoteActionTypes["FormLifeQuoteGetLocal"] = "FormLifeQuoteGetLocal";
3115
+ StoreFormLifeQuoteActionTypes["FormLifeQuoteClear"] = "FormLifeQuoteClear";
3116
+ StoreFormLifeQuoteActionTypes["UpdateLifeCallMessage"] = "UpdateLifeCallMessage";
3117
+ })(StoreFormLifeQuoteActionTypes || (StoreFormLifeQuoteActionTypes = {}));
3118
+
3119
+ const setQuoteStateProperty = (state, name, value) => {
3120
+ const newState = deepClone(state);
3121
+ newState[name] = value;
3122
+ return newState;
3123
+ };
3124
+
3125
+ const localStateName$1 = 'life_quotes';
3126
+ const setLocalQuotes = (localIndex, state) => {
3127
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$1}`, JSON.stringify(state));
3128
+ return state;
3129
+ };
3130
+ const getLocalQuotes = (localIndex = '') => {
3131
+ const localQuotes = localStorage.getItem(`${localIndex}_${localStateName$1}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$1}`) || '') : null;
3132
+ return localQuotes || { ...formLifeQuoteInitialState };
3133
+ };
3134
+
3135
+ const formLifeQuoteStateReducer = (state = { ...formLifeQuoteInitialState }, action) => {
3136
+ switch (action.type) {
3137
+ case StoreFormLifeQuoteActionTypes.FormLifeQuoteIsRequestedSet:
3138
+ return setLocalQuotes(action.localIndex, setQuoteStateProperty(state, 'isRequested', action.payload.isRequested));
3139
+ case StoreFormLifeQuoteActionTypes.FormLifeQuotesSet:
3140
+ return setLocalQuotes(action.localIndex, setQuoteStateProperty(state, 'items', action.payload.items));
3141
+ case StoreFormLifeQuoteActionTypes.FormLifeQuoteRequestDateSet:
3142
+ return setLocalQuotes(action.localIndex, setQuoteStateProperty(state, 'requestDate', action.payload.requestDate));
3143
+ case StoreFormLifeQuoteActionTypes.FormLifeQuoteGetLocal:
3144
+ return {
3145
+ ...getLocalQuotes(action.localIndex),
3146
+ };
3147
+ case StoreFormLifeQuoteActionTypes.FormLifeQuoteClear:
3148
+ return setLocalQuotes(action.localIndex, { ...formLifeQuoteInitialState });
3149
+ case StoreFormLifeQuoteActionTypes.UpdateLifeCallMessage:
3150
+ return setLocalQuotes(action.localIndex, setQuoteStateProperty(state, 'showCallMessage', action.payload.showCallMessage));
3151
+ default:
3152
+ return state;
3153
+ }
3154
+ };
3155
+
3156
+ const formLifePostalInitialState = {
3157
+ isReady: false,
3158
+ item: {
3159
+ ...postalItemInitialState,
3160
+ },
3161
+ };
3162
+
3163
+ var StoreFormLifePostalActionTypes;
3164
+ (function (StoreFormLifePostalActionTypes) {
3165
+ StoreFormLifePostalActionTypes["FormLifePostalSet"] = "FormLifePostalSet";
3166
+ StoreFormLifePostalActionTypes["FormLifePostalClear"] = "FormLifePostalClear";
3167
+ StoreFormLifePostalActionTypes["FormLifePostalGetLocal"] = "FormLifePostalGetLocal";
3168
+ })(StoreFormLifePostalActionTypes || (StoreFormLifePostalActionTypes = {}));
3169
+
3170
+ const setPostalStateProperty = (state, name, value) => {
3171
+ const newState = deepClone(state);
3172
+ newState.isReady = true;
3173
+ newState[name] = value;
3174
+ return newState;
3175
+ };
3176
+
3177
+ const localStateName = 'life_postal';
3178
+ const setLocalPostal = (localIndex, state) => {
3179
+ localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName}`, JSON.stringify(state));
3180
+ return state;
3181
+ };
3182
+ const getLocalPostal = (localIndex = '') => {
3183
+ const localPostal = localStorage.getItem(`${localIndex}_${localStateName}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName}`) || '') : null;
3184
+ return localPostal || { ...formLifePostalInitialState };
3185
+ };
3186
+
3187
+ const formLifePostalStateReducer = (state = { ...formLifePostalInitialState }, action) => {
3188
+ switch (action.type) {
3189
+ case StoreFormLifePostalActionTypes.FormLifePostalSet:
3190
+ return setLocalPostal(action.localIndex, setPostalStateProperty(state, 'item', action.payload));
3191
+ case StoreFormLifePostalActionTypes.FormLifePostalGetLocal:
3192
+ return {
3193
+ ...getLocalPostal(action.localIndex),
3194
+ };
3195
+ case StoreFormLifePostalActionTypes.FormLifePostalClear:
3196
+ return setLocalPostal(action.localIndex, { ...formLifePostalInitialState });
3197
+ default:
3198
+ return state;
3199
+ }
3200
+ };
3201
+
3202
+ const formLifeReducer = combineReducers({
3203
+ postalState: formLifePostalStateReducer,
3204
+ coverageState: formLifeCoverageStateReducer,
3205
+ applicantState: formLifeApplicantStateReducer,
3206
+ quoteState: formLifeQuoteStateReducer,
3207
+ });
3208
+
3209
+ const reducers = combineReducers({
3210
+ globalState: globalStateReducer,
3211
+ configState: configStateReducer,
3212
+ formCarState: formCarReducer,
3213
+ formHomeState: formHomeReducer,
3214
+ formLifeState: formLifeReducer,
3215
+ });
3216
+
3217
+ const store = createStore(reducers, composeWithDevTools(applyMiddleware(thunk)));
3218
+
3219
+ const StoreProvider = ({ children }) => (jsx(Provider, { store: store, children: children
3220
+ && children }));
3221
+
3222
+ const useTypedSelector = useSelector;
3223
+
3224
+ const useStoreAppConfig = () => {
3225
+ const { appConfigState } = useTypedSelector((state) => state).configState;
3226
+ const dispatch = useDispatch();
3227
+ return {
3228
+ appConfigState,
3229
+ dispatchAppConfigState: dispatch,
3230
+ };
3231
+ };
3232
+
3233
+ const useStoreClient = () => {
3234
+ const { appConfigState } = useStoreAppConfig();
3235
+ const { clientState } = useTypedSelector((state) => state).globalState;
3236
+ const dispatch = useDispatch();
3237
+ const dispatchClientState = useMemo(() => (props) => {
3238
+ dispatch({
3239
+ ...props,
3240
+ payload: props.payload,
3241
+ index: appConfigState.localIndex,
3242
+ });
3243
+ }, [appConfigState.localIndex]);
3244
+ return {
2723
3245
  clientState,
2724
3246
  dispatchClientState,
2725
3247
  };
@@ -3067,7 +3589,9 @@ const useStoreFormCarDiscount = () => {
3067
3589
  const dispatch = useDispatch();
3068
3590
  const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormCarQuote();
3069
3591
  const dispatchDiscountState = useMemo(() => (props) => {
3070
- if (isRequested) {
3592
+ if (isRequested
3593
+ && props.type !== StoreFormCarDiscountActionTypes.FormCarDiscountValidate
3594
+ && props.type !== StoreFormCarDiscountActionTypes.FormCarDiscountValidateSet) {
3071
3595
  dispatchQuoteState({
3072
3596
  type: StoreFormCarQuoteActionTypes.FormCarQuoteIsRequestedSet,
3073
3597
  payload: { isRequested: false },
@@ -3124,12 +3648,22 @@ const useStoreFormCarConfig = () => {
3124
3648
  dispatchConfigState,
3125
3649
  };
3126
3650
  };
3651
+ const useProvince = () => {
3652
+ const { configState: { code } } = useStoreFormCarConfig();
3653
+ return {
3654
+ isAlbertaProvince: code === AlbertaCode,
3655
+ isNewBrunswickProvince: code === NewBrunswickCode,
3656
+ isNovaScotiaProvince: code === NovaScotiaCode,
3657
+ isNewfoundlandProvince: code === NewfoundlandCode,
3658
+ isOntarioProvince: code === OntarioCode,
3659
+ };
3660
+ };
3127
3661
 
3128
- const useStoreFormHomePostal = () => {
3662
+ const useStoreFormHomeQuote = () => {
3129
3663
  const { appConfigState } = useStoreAppConfig();
3130
- const { postalState } = useTypedSelector((state) => state).formHomeState;
3664
+ const { quoteState } = useTypedSelector((state) => state).formHomeState;
3131
3665
  const dispatch = useDispatch();
3132
- const dispatchPostalState = useMemo(() => (props) => {
3666
+ const dispatchQuoteState = useMemo(() => (props) => {
3133
3667
  dispatch({
3134
3668
  ...props,
3135
3669
  payload: {
@@ -3139,53 +3673,50 @@ const useStoreFormHomePostal = () => {
3139
3673
  });
3140
3674
  }, [appConfigState.localIndex]);
3141
3675
  return {
3142
- postalState,
3143
- dispatchPostalState,
3676
+ quoteState,
3677
+ dispatchQuoteState,
3144
3678
  };
3145
3679
  };
3146
3680
 
3147
- // import { useStoreFormHomeQuote } from '../QuoteState/hoox';
3148
- // import { StoreFormHomeQuoteActionTypes } from '../QuoteState/actions';
3149
- const useStoreFormHomeAddress = () => {
3681
+ const useStoreFormHomePostal = () => {
3150
3682
  const { appConfigState } = useStoreAppConfig();
3151
- const { addressState } = useTypedSelector((state) => state).formHomeState;
3683
+ const { postalState } = useTypedSelector((state) => state).formHomeState;
3152
3684
  const dispatch = useDispatch();
3153
- // const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3154
- const dispatchAddressState = (props) => {
3155
- // if (isRequested) {
3156
- // dispatchQuoteState({
3157
- // type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3158
- // payload: { isRequested: false },
3159
- // });
3160
- // }
3685
+ const { quoteState, dispatchQuoteState } = useStoreFormHomeQuote();
3686
+ const dispatchPostalState = useMemo(() => (props) => {
3687
+ if (quoteState.isRequested) {
3688
+ dispatchQuoteState({
3689
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3690
+ payload: { isRequested: false },
3691
+ });
3692
+ }
3161
3693
  dispatch({
3162
3694
  ...props,
3163
3695
  payload: {
3696
+ isValid: false,
3164
3697
  ...props.payload,
3165
3698
  },
3166
3699
  localIndex: appConfigState.localIndex,
3167
3700
  });
3168
- };
3701
+ }, [appConfigState.localIndex]);
3169
3702
  return {
3170
- addressState,
3171
- dispatchAddressState,
3703
+ postalState,
3704
+ dispatchPostalState,
3172
3705
  };
3173
3706
  };
3174
3707
 
3175
- // import { useStoreFormHomeQuote } from '../../QuoteState/hoox';
3176
- // import { StoreFormHomeQuoteActionTypes } from '../../QuoteState/actions';
3177
3708
  const useStoreFormHomeApplicantInsurance = () => {
3178
3709
  const { appConfigState } = useStoreAppConfig();
3179
3710
  const { applicantState } = useTypedSelector((state) => state).formHomeState;
3180
3711
  const dispatch = useDispatch();
3181
- // const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3712
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3182
3713
  const dispatchApplicantInsuranceState = useMemo(() => (props) => {
3183
- // if (isRequested) {
3184
- // dispatchQuoteState({
3185
- // type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3186
- // payload: { isRequested: false },
3187
- // });
3188
- // }
3714
+ if (isRequested) {
3715
+ dispatchQuoteState({
3716
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3717
+ payload: { isRequested: false },
3718
+ });
3719
+ }
3189
3720
  dispatch({
3190
3721
  ...props,
3191
3722
  payload: {
@@ -3193,27 +3724,25 @@ const useStoreFormHomeApplicantInsurance = () => {
3193
3724
  },
3194
3725
  localIndex: appConfigState.localIndex,
3195
3726
  });
3196
- }, [appConfigState.localIndex]);
3727
+ }, [isRequested, appConfigState.localIndex]);
3197
3728
  return {
3198
3729
  applicantState,
3199
3730
  dispatchApplicantInsuranceState,
3200
3731
  };
3201
3732
  };
3202
3733
 
3203
- // import { useStoreFormHomeQuote } from '../../QuoteState/hoox';
3204
- // import { StoreFormHomeQuoteActionTypes } from '../../QuoteState/actions';
3205
3734
  const useStoreFormHomeApplicantInfo = () => {
3206
3735
  const { appConfigState } = useStoreAppConfig();
3207
3736
  const { applicantState } = useTypedSelector((state) => state).formHomeState;
3208
3737
  const dispatch = useDispatch();
3209
- // const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3738
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3210
3739
  const dispatchApplicantInfoState = useMemo(() => (props) => {
3211
- // if (isRequested) {
3212
- // dispatchQuoteState({
3213
- // type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3214
- // payload: { isRequested: false },
3215
- // });
3216
- // }
3740
+ if (isRequested) {
3741
+ dispatchQuoteState({
3742
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3743
+ payload: { isRequested: false },
3744
+ });
3745
+ }
3217
3746
  dispatch({
3218
3747
  ...props,
3219
3748
  payload: {
@@ -3221,27 +3750,25 @@ const useStoreFormHomeApplicantInfo = () => {
3221
3750
  },
3222
3751
  localIndex: appConfigState.localIndex,
3223
3752
  });
3224
- }, [appConfigState.localIndex]);
3753
+ }, [isRequested, appConfigState.localIndex]);
3225
3754
  return {
3226
3755
  applicantState,
3227
3756
  dispatchApplicantInfoState,
3228
3757
  };
3229
3758
  };
3230
3759
 
3231
- // import { useStoreFormHomeQuote } from '../../QuoteState/hoox';
3232
- // import { StoreFormHomeQuoteActionTypes } from '../../QuoteState/actions';
3233
3760
  const useStoreFormHomeApplicantCancellation = () => {
3234
3761
  const { appConfigState } = useStoreAppConfig();
3235
3762
  const { applicantState } = useTypedSelector((state) => state).formHomeState;
3236
3763
  const dispatch = useDispatch();
3237
- // const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3764
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3238
3765
  const dispatchApplicantCancellationState = useMemo(() => (props) => {
3239
- // if (isRequested) {
3240
- // dispatchQuoteState({
3241
- // type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3242
- // payload: { isRequested: false },
3243
- // });
3244
- // }
3766
+ if (isRequested) {
3767
+ dispatchQuoteState({
3768
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3769
+ payload: { isRequested: false },
3770
+ });
3771
+ }
3245
3772
  dispatch({
3246
3773
  ...props,
3247
3774
  payload: {
@@ -3249,27 +3776,25 @@ const useStoreFormHomeApplicantCancellation = () => {
3249
3776
  },
3250
3777
  localIndex: appConfigState.localIndex,
3251
3778
  });
3252
- }, [appConfigState.localIndex]);
3779
+ }, [isRequested, appConfigState.localIndex]);
3253
3780
  return {
3254
3781
  applicantState,
3255
3782
  dispatchApplicantCancellationState,
3256
3783
  };
3257
3784
  };
3258
3785
 
3259
- // import { useStoreFormHomeQuote } from '../../QuoteState/hoox';
3260
- // import { StoreFormHomeQuoteActionTypes } from '../../QuoteState/actions';
3261
3786
  const useStoreFormHomeApplicantClaim = () => {
3262
3787
  const { appConfigState } = useStoreAppConfig();
3263
3788
  const { applicantState } = useTypedSelector((state) => state).formHomeState;
3264
3789
  const dispatch = useDispatch();
3265
- // const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3790
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3266
3791
  const dispatchApplicantClaimState = useMemo(() => (props) => {
3267
- // if (isRequested) {
3268
- // dispatchQuoteState({
3269
- // type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3270
- // payload: { isRequested: false },
3271
- // });
3272
- // }
3792
+ if (isRequested) {
3793
+ dispatchQuoteState({
3794
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3795
+ payload: { isRequested: false },
3796
+ });
3797
+ }
3273
3798
  dispatch({
3274
3799
  ...props,
3275
3800
  payload: {
@@ -3277,28 +3802,25 @@ const useStoreFormHomeApplicantClaim = () => {
3277
3802
  },
3278
3803
  localIndex: appConfigState.localIndex,
3279
3804
  });
3280
- }, [appConfigState.localIndex]);
3805
+ }, [isRequested, appConfigState.localIndex]);
3281
3806
  return {
3282
3807
  applicantState,
3283
3808
  dispatchApplicantClaimState,
3284
3809
  };
3285
3810
  };
3286
3811
 
3287
- // import { StoreFormHomeQuoteActionTypes } from '../../QuoteState/actions';
3288
- // import { useStoreFormHomeQuote } from '../../QuoteState/hoox';
3289
- // import { StoreFormHomeApplicantBaseActionTypes } from './actions';
3290
3812
  const useStoreFormHomeApplicantBase = () => {
3291
3813
  const { appConfigState } = useStoreAppConfig();
3292
3814
  const { applicantState } = useTypedSelector((state) => state).formHomeState;
3293
3815
  const dispatch = useDispatch();
3294
- // const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3816
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3295
3817
  const dispatchApplicantBaseState = useMemo(() => (props) => {
3296
- // if (isRequested && (props.type !== StoreFormHomeApplicantBaseActionTypes.FormHomeApplicantSelect)) {
3297
- // dispatchQuoteState({
3298
- // type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3299
- // payload: { isRequested: false },
3300
- // });
3301
- // }
3818
+ if (isRequested) {
3819
+ dispatchQuoteState({
3820
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3821
+ payload: { isRequested: false },
3822
+ });
3823
+ }
3302
3824
  dispatch({
3303
3825
  ...props,
3304
3826
  payload: {
@@ -3306,28 +3828,25 @@ const useStoreFormHomeApplicantBase = () => {
3306
3828
  },
3307
3829
  localIndex: appConfigState.localIndex,
3308
3830
  });
3309
- }, [appConfigState.localIndex]);
3831
+ }, [isRequested, appConfigState.localIndex]);
3310
3832
  return {
3311
3833
  applicantState,
3312
3834
  dispatchApplicantBaseState,
3313
3835
  };
3314
3836
  };
3315
3837
 
3316
- // import { StoreFormHomeQuoteActionTypes } from '../QuoteState/actions';
3317
- // import { useStoreFormHomeQuote } from '../QuoteState/hoox';
3318
- // import { StoreFormHomeDwellingActionTypes } from './actions';
3319
3838
  const useStoreFormHomeDwelling = () => {
3320
3839
  const { appConfigState } = useStoreAppConfig();
3321
3840
  const { dwellingState } = useTypedSelector((state) => state).formHomeState;
3322
3841
  const dispatch = useDispatch();
3323
- // const { quoteState, dispatchQuoteState } = useStoreFormHomeQuote();
3842
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3324
3843
  const dispatchDwellingState = useMemo(() => (props) => {
3325
- // if (quoteState.isRequested && (props.type !== StoreFormHomeDwellingActionTypes.FormHomeDwellingSelect)) {
3326
- // dispatchQuoteState({
3327
- // type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3328
- // payload: { isRequested: false },
3329
- // });
3330
- // }
3844
+ if (isRequested) {
3845
+ dispatchQuoteState({
3846
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3847
+ payload: { isRequested: false },
3848
+ });
3849
+ }
3331
3850
  dispatch({
3332
3851
  ...props,
3333
3852
  payload: {
@@ -3336,27 +3855,27 @@ const useStoreFormHomeDwelling = () => {
3336
3855
  },
3337
3856
  localIndex: appConfigState.localIndex,
3338
3857
  });
3339
- }, []);
3858
+ }, [isRequested, appConfigState.localIndex]);
3340
3859
  return {
3341
3860
  dwellingState,
3342
3861
  dispatchDwellingState,
3343
3862
  };
3344
3863
  };
3345
3864
 
3346
- // import { useStoreFormHomeQuote } from '../QuoteState/hoox';
3347
- // import { StoreFormHomeQuoteActionTypes } from '../QuoteState/actions';
3348
3865
  const useStoreFormHomeDiscount = () => {
3349
3866
  const { appConfigState } = useStoreAppConfig();
3350
3867
  const { discountState } = useTypedSelector((state) => state).formHomeState;
3351
3868
  const dispatch = useDispatch();
3352
- // const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3353
- const dispatchDiscountState = (props) => {
3354
- // if (isRequested) {
3355
- // dispatchQuoteState({
3356
- // type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3357
- // payload: { isRequested: false },
3358
- // });
3359
- // }
3869
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormHomeQuote();
3870
+ const dispatchDiscountState = useMemo(() => (props) => {
3871
+ if (isRequested
3872
+ && props.type !== StoreFormHomeDiscountActionTypes.FormHomeDiscountValidate
3873
+ && props.type !== StoreFormHomeDiscountActionTypes.FormHomeDiscountValidateSet) {
3874
+ dispatchQuoteState({
3875
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
3876
+ payload: { isRequested: false },
3877
+ });
3878
+ }
3360
3879
  dispatch({
3361
3880
  ...props,
3362
3881
  payload: {
@@ -3364,36 +3883,127 @@ const useStoreFormHomeDiscount = () => {
3364
3883
  },
3365
3884
  localIndex: appConfigState.localIndex,
3366
3885
  });
3367
- };
3886
+ }, [isRequested, appConfigState.localIndex]);
3368
3887
  return {
3369
3888
  discountState,
3370
3889
  dispatchDiscountState,
3371
3890
  };
3372
3891
  };
3373
3892
 
3374
- const useCancelToken = () => {
3375
- // const { dispatchAppLoaderState } = useStoreAppLoader();
3376
- const cancelToken = axios.CancelToken.source();
3377
- useEffectOnce(() => () => {
3378
- // dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
3379
- cancelToken.cancel();
3380
- });
3893
+ const useStoreFormLifePostal = () => {
3894
+ const { appConfigState } = useStoreAppConfig();
3895
+ const { postalState } = useTypedSelector((state) => state).formLifeState;
3896
+ const dispatch = useDispatch();
3897
+ const dispatchPostalState = useMemo(() => (props) => {
3898
+ dispatch({
3899
+ ...props,
3900
+ payload: {
3901
+ ...props.payload,
3902
+ },
3903
+ localIndex: appConfigState.localIndex,
3904
+ });
3905
+ }, [appConfigState.localIndex]);
3381
3906
  return {
3382
- cancelToken: cancelToken.token,
3907
+ postalState,
3908
+ dispatchPostalState,
3383
3909
  };
3384
3910
  };
3385
3911
 
3386
- const initHttpResponse = () => {
3387
- axios.interceptors.response.use((response) => {
3388
- if (response.data
3389
- && response.headers['content-type'] === 'application/json') {
3390
- response.data = camelizeKeys(response.data);
3912
+ const useStoreFormLifeQuote = () => {
3913
+ const { appConfigState } = useStoreAppConfig();
3914
+ const { quoteState } = useTypedSelector((state) => state).formLifeState;
3915
+ const dispatch = useDispatch();
3916
+ const dispatchQuoteState = useMemo(() => (props) => {
3917
+ dispatch({
3918
+ ...props,
3919
+ payload: {
3920
+ ...props.payload,
3921
+ },
3922
+ localIndex: appConfigState.localIndex,
3923
+ });
3924
+ }, [appConfigState.localIndex]);
3925
+ return {
3926
+ quoteState,
3927
+ dispatchQuoteState,
3928
+ };
3929
+ };
3930
+
3931
+ const useStoreFormLifeCoverage = () => {
3932
+ const { appConfigState } = useStoreAppConfig();
3933
+ const { coverageState } = useTypedSelector((state) => state).formLifeState;
3934
+ const dispatch = useDispatch();
3935
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormLifeQuote();
3936
+ const dispatchCoverageState = (props) => {
3937
+ if (isRequested) {
3938
+ dispatchQuoteState({
3939
+ type: StoreFormLifeQuoteActionTypes.FormLifeQuoteIsRequestedSet,
3940
+ payload: { isRequested: false },
3941
+ });
3391
3942
  }
3392
- return response;
3393
- }, (error) => {
3394
- const originalRequest = error.config;
3395
- if (!error || !error?.response) {
3396
- return { message: 'cancel request' };
3943
+ dispatch({
3944
+ ...props,
3945
+ payload: {
3946
+ ...props.payload,
3947
+ },
3948
+ localIndex: appConfigState.localIndex,
3949
+ });
3950
+ };
3951
+ return {
3952
+ coverageState,
3953
+ dispatchCoverageState,
3954
+ };
3955
+ };
3956
+
3957
+ const useStoreFormLifeApplicant = () => {
3958
+ const { appConfigState } = useStoreAppConfig();
3959
+ const { applicantState } = useTypedSelector((state) => state).formLifeState;
3960
+ const dispatch = useDispatch();
3961
+ const { quoteState: { isRequested }, dispatchQuoteState } = useStoreFormLifeQuote();
3962
+ const dispatchApplicantState = useMemo(() => (props) => {
3963
+ if (isRequested) {
3964
+ dispatchQuoteState({
3965
+ type: StoreFormLifeQuoteActionTypes.FormLifeQuoteIsRequestedSet,
3966
+ payload: { isRequested: false },
3967
+ });
3968
+ }
3969
+ dispatch({
3970
+ ...props,
3971
+ payload: {
3972
+ ...props.payload,
3973
+ },
3974
+ localIndex: appConfigState.localIndex,
3975
+ });
3976
+ }, [appConfigState.localIndex]);
3977
+ return {
3978
+ applicantState,
3979
+ dispatchApplicantState,
3980
+ };
3981
+ };
3982
+
3983
+ const useCancelToken = () => {
3984
+ // const { dispatchAppLoaderState } = useStoreAppLoader();
3985
+ const cancelToken = axios.CancelToken.source();
3986
+ useEffectOnce(() => () => {
3987
+ // dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
3988
+ cancelToken.cancel();
3989
+ });
3990
+ return {
3991
+ cancelToken: cancelToken.token,
3992
+ };
3993
+ };
3994
+
3995
+ const initHttpResponse = () => {
3996
+ const type = getInsuranceType$2();
3997
+ axios.interceptors.response.use((response) => {
3998
+ if (response.data
3999
+ && response.headers['content-type'] === 'application/json') {
4000
+ response.data = camelizeKeys(response.data);
4001
+ }
4002
+ return response;
4003
+ }, (error) => {
4004
+ const originalRequest = error.config;
4005
+ if (!error || !error?.response) {
4006
+ return { message: 'cancel request' };
3397
4007
  }
3398
4008
  if (error?.response?.status === 404) {
3399
4009
  return { message: error.response.data.detail };
@@ -3436,7 +4046,7 @@ const initHttpResponse = () => {
3436
4046
  newConfig.params = decamelizeKeys(config.params);
3437
4047
  }
3438
4048
  if (config.data) {
3439
- newConfig.data = decamelizeKeys(config.data, { separator: '_' });
4049
+ newConfig.data = type !== InsuranceTypes.Life ? decamelizeKeys(config.data, { separator: '_' }) : config.data;
3440
4050
  newConfig.paramsSerializer = () => JSON.stringify(decamelizeKeys(config.params || {}));
3441
4051
  }
3442
4052
  return newConfig;
@@ -3588,27 +4198,69 @@ const addDayToDate = (value, days) => {
3588
4198
  const differenceInHoursFromNow = (date) => getDifferenceInHours('', date);
3589
4199
 
3590
4200
  const ClearFormDataHandler = () => {
4201
+ // car insurance states
4202
+ const { dispatchPostalState: dispatchCarPostalState } = useStoreFormCarPostal();
3591
4203
  const { dispatchVehicleState } = useStoreFormCarVehicle();
3592
4204
  const { dispatchDriverBaseState } = useStoreFormCarDriverBase();
3593
- const { dispatchDiscountState } = useStoreFormCarDiscount();
3594
- const { quoteState, dispatchQuoteState } = useStoreFormCarQuote();
3595
- const { dispatchPostalState } = useStoreFormCarPostal();
4205
+ const { dispatchDiscountState: dispatchCarDiscountState } = useStoreFormCarDiscount();
4206
+ const { quoteState: carQuoteState, dispatchQuoteState: dispatchCarQuoteState } = useStoreFormCarQuote();
4207
+ // home insurance states
4208
+ const { dispatchPostalState: dispatchHomePostalState } = useStoreFormHomePostal();
4209
+ const { dispatchApplicantBaseState } = useStoreFormHomeApplicantBase();
4210
+ const { dispatchDwellingState } = useStoreFormHomeDwelling();
4211
+ const { dispatchDiscountState: dispatchHomeDiscountState } = useStoreFormHomeDiscount();
4212
+ const { quoteState: homeQuoteState, dispatchQuoteState: dispatchHomeQuoteState } = useStoreFormHomeQuote();
4213
+ // life insurance states
4214
+ const { dispatchCoverageState } = useStoreFormLifeCoverage();
4215
+ const { dispatchApplicantState } = useStoreFormLifeApplicant();
4216
+ const { quoteState: lifeQuoteState, dispatchQuoteState: dispatchLifeQuoteState } = useStoreFormLifeQuote();
3596
4217
  const { dispatchAppModalState } = useStoreAppModal();
3597
- const { appConfigState } = useStoreAppConfig();
4218
+ const { appConfigState: { localIndex, insuranceType, appType } } = useStoreAppConfig();
3598
4219
  const navigate = useNavigate();
3599
- const inactiveHours = differenceInHoursFromNow(quoteState.requestDate);
4220
+ const isThebig = appType === AppTypes.TheBig;
4221
+ const maxHours = isThebig ? MAX_LOCAL_STORAGE_HOURS_THEBIG : MAX_LOCAL_STORAGE_HOURS;
3600
4222
  const clearFormData = () => {
3601
- dispatchQuoteState({ type: StoreFormCarQuoteActionTypes.FormCarQuoteClear });
3602
- dispatchDiscountState({ type: StoreFormCarDiscountActionTypes.FormCarDiscountClear });
3603
- dispatchDriverBaseState({ type: StoreFormCarDriverBaseActionTypes.FormCarDriverClear });
3604
- dispatchVehicleState({ type: StoreFormCarVehicleActionTypes.FormCarVehicleClear });
3605
- dispatchPostalState({ type: StoreFormCarPostalActionTypes.FormCarPostalClear });
4223
+ if (insuranceType === InsuranceTypes.Car) {
4224
+ dispatchCarQuoteState({ type: StoreFormCarQuoteActionTypes.FormCarQuoteClear });
4225
+ dispatchCarDiscountState({ type: StoreFormCarDiscountActionTypes.FormCarDiscountClear });
4226
+ dispatchDriverBaseState({ type: StoreFormCarDriverBaseActionTypes.FormCarDriverClear });
4227
+ dispatchVehicleState({ type: StoreFormCarVehicleActionTypes.FormCarVehicleClear });
4228
+ dispatchCarPostalState({ type: StoreFormCarPostalActionTypes.FormCarPostalClear });
4229
+ }
4230
+ if (insuranceType === InsuranceTypes.Home || insuranceType === InsuranceTypes.Condo || insuranceType === InsuranceTypes.Tenant) {
4231
+ dispatchHomeQuoteState({ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteClear });
4232
+ dispatchHomeDiscountState({ type: StoreFormHomeDiscountActionTypes.FormHomeDiscountClear });
4233
+ dispatchDwellingState({ type: StoreFormHomeDwellingActionTypes.FormHomeDwellingClear, payload: { type: insuranceType } });
4234
+ dispatchApplicantBaseState({ type: StoreFormHomeApplicantBaseActionTypes.FormHomeApplicantClear });
4235
+ dispatchHomePostalState({ type: StoreFormHomePostalActionTypes.FormHomePostalClear });
4236
+ }
4237
+ if (insuranceType === InsuranceTypes.Life) {
4238
+ dispatchLifeQuoteState({ type: StoreFormLifeQuoteActionTypes.FormLifeQuoteClear });
4239
+ dispatchApplicantState({ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantClear });
4240
+ dispatchCoverageState({ type: StoreFormLifeCoverageActionTypes.FormLifeCoverageClear });
4241
+ }
3606
4242
  };
3607
4243
  const checkIsExpiredWithClear = () => {
3608
- if (quoteState.isRequested && (inactiveHours > (MAX_LOCAL_STORAGE_HOURS - 1))) {
3609
- dispatchPostalState({ type: StoreFormCarPostalActionTypes.FormCarPostalClear });
3610
- clearFormData();
3611
- navigate(`/${appConfigState.localIndex}/${appConfigState.insuranceType}/car`);
4244
+ if (insuranceType === InsuranceTypes.Car) {
4245
+ const inactiveHours = differenceInHoursFromNow(carQuoteState.requestDate);
4246
+ if (carQuoteState.isRequested && (inactiveHours > (maxHours - 1))) {
4247
+ clearFormData();
4248
+ navigate(`/${localIndex}/${insuranceType}/`);
4249
+ }
4250
+ }
4251
+ if (insuranceType === InsuranceTypes.Home || insuranceType === InsuranceTypes.Condo || insuranceType === InsuranceTypes.Tenant) {
4252
+ const inactiveHours = differenceInHoursFromNow(homeQuoteState.requestDate);
4253
+ if (homeQuoteState.isRequested && (inactiveHours > (maxHours - 1))) {
4254
+ clearFormData();
4255
+ navigate(`/${localIndex}/${insuranceType}/`);
4256
+ }
4257
+ }
4258
+ if (insuranceType === InsuranceTypes.Life) {
4259
+ const inactiveHours = differenceInHoursFromNow(lifeQuoteState.requestDate);
4260
+ if (lifeQuoteState.isRequested && (inactiveHours > (maxHours - 1))) {
4261
+ clearFormData();
4262
+ navigate(`/${localIndex}/${insuranceType}/`);
4263
+ }
3612
4264
  }
3613
4265
  };
3614
4266
  const checkIsExpiredWithModal = () => {
@@ -3621,7 +4273,21 @@ const ClearFormDataHandler = () => {
3621
4273
  });
3622
4274
  checkIsExpiredWithClear();
3623
4275
  };
3624
- const checkIsExpired = () => (quoteState.isRequested && (inactiveHours > (MAX_LOCAL_STORAGE_HOURS - 1)));
4276
+ const checkIsExpired = () => {
4277
+ if (insuranceType === InsuranceTypes.Car) {
4278
+ const inactiveHours = differenceInHoursFromNow(carQuoteState.requestDate);
4279
+ return carQuoteState.isRequested && (inactiveHours > (maxHours - 1));
4280
+ }
4281
+ if (insuranceType === InsuranceTypes.Home || insuranceType === InsuranceTypes.Condo || insuranceType === InsuranceTypes.Tenant) {
4282
+ const inactiveHours = differenceInHoursFromNow(homeQuoteState.requestDate);
4283
+ return homeQuoteState.isRequested && (inactiveHours > (maxHours - 1));
4284
+ }
4285
+ if (insuranceType === InsuranceTypes.Life) {
4286
+ const inactiveHours = differenceInHoursFromNow(lifeQuoteState.requestDate);
4287
+ return lifeQuoteState.isRequested && (inactiveHours > (maxHours - 1));
4288
+ }
4289
+ return false;
4290
+ };
3625
4291
  return {
3626
4292
  checkIsExpiredWithClear,
3627
4293
  checkIsExpiredWithModal,
@@ -3683,6 +4349,8 @@ const useHandlerPartner = () => {
3683
4349
  const useHandlerPostal = (insuranceType) => {
3684
4350
  const { dispatchPostalState: dispatchCarPostalState } = useStoreFormCarPostal();
3685
4351
  const { dispatchPostalState: dispatchHomePostalState } = useStoreFormHomePostal();
4352
+ // const { dispatchPostalState: dispatchLifePostalState } = useStoreFormLifePostal();
4353
+ const { dwellingState, dispatchDwellingState } = useStoreFormHomeDwelling();
3686
4354
  const { dispatchConfigState: dispatchCarConfigState } = useStoreFormCarConfig();
3687
4355
  const { dispatchAppModalState } = useStoreAppModal();
3688
4356
  const [requestState, setRequestState] = useReducer(dataHandlerReducer, { ...initialHandlerRequestState });
@@ -3698,44 +4366,156 @@ const useHandlerPostal = (insuranceType) => {
3698
4366
  withoutToken: true,
3699
4367
  cancelToken,
3700
4368
  });
3701
- dispatchCarPostalState({
3702
- type: StoreFormCarPostalActionTypes.FormCarPostalSet,
3703
- payload: { ...response.data },
3704
- });
3705
- setRequestState({ type: DataHandlerActionTypes.SetSuccess, payload: response.data });
3706
- if (response.data?.postalCode) {
3707
- dispatchCarConfigState({ type: StoreFormCarConfigActionTypes.FormCarConfigSet, payload: { province: response.data.provinceCode } });
3708
- dispatchAppModalState({ type: StoreConfigAppModalActionTypes.AppModalClose });
3709
- setRequestState({ type: DataHandlerActionTypes.SetSuccess, payload: response.data });
3710
- }
3711
- else {
4369
+ if (supportedProvinceCodes.includes(response.data.provinceCode)) {
4370
+ if (response.data?.postalCode) {
4371
+ dispatchCarPostalState({
4372
+ type: StoreFormCarPostalActionTypes.FormCarPostalSet,
4373
+ payload: { ...response.data },
4374
+ });
4375
+ dispatchCarConfigState({
4376
+ type: StoreFormCarConfigActionTypes.FormCarConfigSet,
4377
+ payload: { province: response.data.provinceCode },
4378
+ });
4379
+ dispatchAppModalState({ type: StoreConfigAppModalActionTypes.AppModalClose });
4380
+ setRequestState({ type: DataHandlerActionTypes.SetSuccess, payload: response.data });
4381
+ return { errorMessage: '' };
4382
+ }
3712
4383
  setRequestState({
3713
4384
  type: DataHandlerActionTypes.SetError,
3714
4385
  payload: 'Something went wrong! Please try again.',
3715
4386
  });
4387
+ return { errorMessage: 'Something went wrong! Please try again.' };
3716
4388
  }
4389
+ setRequestState({
4390
+ type: DataHandlerActionTypes.SetError,
4391
+ payload: 'Postal Code Is Not Supported',
4392
+ });
4393
+ return { errorMessage: 'Postal Code Is Not Supported' };
3717
4394
  }
3718
- if (insuranceType === InsuranceTypes.Home) {
4395
+ if (insuranceType === InsuranceTypes.Home || insuranceType === InsuranceTypes.Condo || insuranceType === InsuranceTypes.Tenant) {
3719
4396
  const response = await httpRequest({
3720
4397
  url: `${API_FORM_HOME.GET_POSTAL}?postal_code=${postalCode}`,
3721
4398
  method: RequestTypes.Get,
3722
4399
  withoutToken: true,
3723
4400
  cancelToken,
3724
4401
  });
4402
+ if (supportedProvinceCodes.includes(response.data.provinceCode)) {
4403
+ if (response.data?.postalCode) {
4404
+ dispatchHomePostalState({
4405
+ type: StoreFormHomePostalActionTypes.FormHomePostalSet,
4406
+ payload: { ...response.data },
4407
+ });
4408
+ dispatchAppModalState({ type: StoreConfigAppModalActionTypes.AppModalClose });
4409
+ setRequestState({ type: DataHandlerActionTypes.SetSuccess, payload: response.data });
4410
+ return { errorMessage: '', data: response.data };
4411
+ }
4412
+ dispatchHomePostalState({
4413
+ type: StoreFormHomePostalActionTypes.FormHomePostalErrorMessageSet,
4414
+ payload: { errorMessage: 'Something went wrong! Please try again.' },
4415
+ });
4416
+ return { errorMessage: 'Something went wrong! Please try again.' };
4417
+ }
3725
4418
  dispatchHomePostalState({
3726
- type: StoreFormHomePostalActionTypes.FormHomePostalSet,
3727
- payload: { ...response.data },
4419
+ type: StoreFormHomePostalActionTypes.FormHomePostalErrorMessageSet,
4420
+ payload: { errorMessage: 'Postal Code Is Not Supported' },
3728
4421
  });
3729
- if (response.data?.postalCode) {
3730
- dispatchAppModalState({ type: StoreConfigAppModalActionTypes.AppModalClose });
3731
- setRequestState({ type: DataHandlerActionTypes.SetSuccess, payload: response.data });
4422
+ return { errorMessage: 'Postal Code Is Not Supported', data: response.data };
4423
+ }
4424
+ // if (insuranceType === InsuranceTypes.Life) {
4425
+ // const response = await httpRequest({
4426
+ // url: `${API_FORM_LIFE.GET_POSTAL}?postal_code=${postalCode}`,
4427
+ // method: RequestTypes.Get,
4428
+ // withoutToken: true,
4429
+ // cancelToken,
4430
+ // });
4431
+ //
4432
+ // if (supportedProvinceCodes.includes(response.data.provinceCode)) {
4433
+ // if (response.data?.postalCode) {
4434
+ // dispatchLifePostalState({
4435
+ // type: StoreFormLifePostalActionTypes.FormLifePostalSet,
4436
+ // payload: { ...response.data },
4437
+ // });
4438
+ // dispatchAppModalState({ type: StoreConfigAppModalActionTypes.AppModalClose });
4439
+ // setRequestState({ type: DataHandlerActionTypes.SetSuccess, payload: response.data });
4440
+ // return { errorMessage: '' };
4441
+ // }
4442
+ // setRequestState({
4443
+ // type: DataHandlerActionTypes.SetError,
4444
+ // payload: 'Something went wrong! Please try again.',
4445
+ // });
4446
+ // return { errorMessage: 'Something went wrong! Please try again.' };
4447
+ // }
4448
+ // setRequestState({
4449
+ // type: DataHandlerActionTypes.SetError,
4450
+ // payload: 'Postal Code Is Not Supported',
4451
+ // });
4452
+ // return { errorMessage: 'Postal Code Is Not Supported' };
4453
+ // }
4454
+ return { errorMessage: 'No Selected Insurance' };
4455
+ }
4456
+ catch (error) {
4457
+ const requestError = error;
4458
+ if (insuranceType === InsuranceTypes.Home) {
4459
+ dispatchHomePostalState({
4460
+ type: StoreFormHomePostalActionTypes.FormHomePostalErrorMessageSet,
4461
+ payload: { errorMessage: requestError.response?.data?.postalCode[0] },
4462
+ });
4463
+ }
4464
+ setRequestState({
4465
+ type: DataHandlerActionTypes.SetError,
4466
+ payload: requestError.response?.data?.postalCode[0],
4467
+ });
4468
+ return { errorMessage: requestError.response?.data?.postalCode[0] };
4469
+ }
4470
+ };
4471
+ const getPlaceByAddress = async (streetAddress, city, postalCode, province) => {
4472
+ setRequestState({ type: DataHandlerActionTypes.SetLoading, payload: true });
4473
+ try {
4474
+ if (insuranceType === InsuranceTypes.Home) {
4475
+ const response = await httpRequest({
4476
+ url: `${API_FORM_HOME.GET_PLACE}`,
4477
+ method: RequestTypes.Post,
4478
+ data: {
4479
+ streetAddress, city, postalCode, province,
4480
+ },
4481
+ withoutToken: true,
4482
+ cancelToken,
4483
+ });
4484
+ console.log('dwelling', response?.data);
4485
+ const { auxiliaryHeating, basementFinishPercent: dataBasementFinishPercent, buildingStructure: dataBuildingStructure, builtDate: dataBuiltDate, exteriorFinish: dataExteriorFinish, garageType: dataGarageType, livingArea: dataLivingArea, primaryHeating, replacementCost: dataReplacementCost, storeysCount: dataStoreysCount, roofType: dataRoofType, poolType: dataPoolType, bathroomsCount: dataBathroomsCount, } = response.data;
4486
+ const { basementFinishPercent, buildingStructure, builtYear, exteriorFinish, garageType, livingArea, heatings, replacementCost, storeysCount, roofReplacedYear, roofType, poolType, bathroomsCount, } = getDwellingInitialState(getInsuranceType$2());
4487
+ let roofYear = roofReplacedYear;
4488
+ if (dataBuiltDate && (Number(dataBuiltDate) > Number(roofReplacedYear))) {
4489
+ roofYear = dataBuiltDate;
4490
+ }
4491
+ const dwellingInfoUpdatedState = {
4492
+ basementFinishPercent: dataBasementFinishPercent || basementFinishPercent,
4493
+ buildingStructure: dataBuildingStructure || buildingStructure,
4494
+ builtYear: dataBuiltDate || builtYear,
4495
+ exteriorFinish: dataExteriorFinish || exteriorFinish,
4496
+ garageType: dataGarageType || garageType,
4497
+ livingArea: dataLivingArea || livingArea,
4498
+ heatings: [{ type: primaryHeating || heatings[0].type }, { type: auxiliaryHeating || heatings[1].type }],
4499
+ replacementCost: dataReplacementCost || replacementCost,
4500
+ storeysCount: +dataStoreysCount || storeysCount,
4501
+ roofReplacedYear: roofYear,
4502
+ roofType: dataRoofType || roofType,
4503
+ poolType: dataPoolType || poolType,
4504
+ bathroomsCount: dataBathroomsCount || bathroomsCount,
4505
+ };
4506
+ if (!response.data.primaryHeating) {
4507
+ dispatchDwellingState({
4508
+ type: StoreFormHomeDwellingActionTypes.FormHomeDwellingSet,
4509
+ payload: { ...dwellingState, ...dwellingInfoUpdatedState, isCompleted: false },
4510
+ });
3732
4511
  }
3733
4512
  else {
3734
- setRequestState({
3735
- type: DataHandlerActionTypes.SetError,
3736
- payload: 'Something went wrong! Please try again.',
4513
+ dispatchDwellingState({
4514
+ type: StoreFormHomeDwellingActionTypes.FormHomeDwellingSet,
4515
+ payload: { ...dwellingState, ...dwellingInfoUpdatedState },
3737
4516
  });
3738
4517
  }
4518
+ setRequestState({ type: DataHandlerActionTypes.SetSuccess, payload: response.data });
3739
4519
  }
3740
4520
  }
3741
4521
  catch (error) {
@@ -3749,6 +4529,7 @@ const useHandlerPostal = (insuranceType) => {
3749
4529
  return {
3750
4530
  status,
3751
4531
  getPostal,
4532
+ getPlaceByAddress,
3752
4533
  successMessage,
3753
4534
  responseData,
3754
4535
  errorMessage,
@@ -3832,7 +4613,7 @@ const useHandlerCarModel = () => {
3832
4613
  };
3833
4614
  };
3834
4615
 
3835
- const useHandlerQuoterEmail = () => {
4616
+ const useHandlerCarQuoterEmail = () => {
3836
4617
  const [requestState, setRequestState] = useReducer(dataHandlerReducer, {
3837
4618
  ...initialHandlerRequestState,
3838
4619
  });
@@ -3908,8 +4689,160 @@ const useHandlerQuoterEmail = () => {
3908
4689
  responseError,
3909
4690
  };
3910
4691
  };
4692
+ const useHandlerHomeQuoterEmail = () => {
4693
+ const [requestState, setRequestState] = useReducer(dataHandlerReducer, {
4694
+ ...initialHandlerRequestState,
4695
+ });
4696
+ const { dispatchDiscountState } = useStoreFormHomeDiscount();
4697
+ const { cancelToken } = useCancelToken();
4698
+ const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
4699
+ const validateEmail = async (email) => {
4700
+ dispatchDiscountState({
4701
+ type: StoreFormHomeDiscountActionTypes.FormHomeDiscountQuoterEmailSet,
4702
+ payload: {
4703
+ email,
4704
+ emailStatus: ValidationStatusTypes.Loading,
4705
+ },
4706
+ });
4707
+ if (email) {
4708
+ try {
4709
+ const response = await httpRequest({
4710
+ url: API_AUTH.POST_EMAIL_VALIDATION,
4711
+ method: RequestTypes.Post,
4712
+ data: { email },
4713
+ withoutToken: true,
4714
+ cancelToken,
4715
+ });
4716
+ if (response.data.valid) {
4717
+ dispatchDiscountState({
4718
+ type: StoreFormHomeDiscountActionTypes.FormHomeDiscountQuoterEmailSet,
4719
+ payload: {
4720
+ email,
4721
+ emailStatus: ValidationStatusTypes.Approved,
4722
+ },
4723
+ });
4724
+ }
4725
+ else {
4726
+ dispatchDiscountState({
4727
+ type: StoreFormHomeDiscountActionTypes.FormHomeDiscountQuoterEmailSet,
4728
+ payload: {
4729
+ email,
4730
+ emailStatus: ValidationStatusTypes.Declined,
4731
+ },
4732
+ });
4733
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid email address.' });
4734
+ }
4735
+ }
4736
+ catch (error) {
4737
+ dispatchDiscountState({
4738
+ type: StoreFormHomeDiscountActionTypes.FormHomeDiscountQuoterEmailSet,
4739
+ payload: {
4740
+ email,
4741
+ emailStatus: ValidationStatusTypes.Declined,
4742
+ },
4743
+ });
4744
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid email address.' });
4745
+ }
4746
+ }
4747
+ else {
4748
+ dispatchDiscountState({
4749
+ type: StoreFormHomeDiscountActionTypes.FormHomeDiscountQuoterEmailSet,
4750
+ payload: {
4751
+ email,
4752
+ emailStatus: ValidationStatusTypes.Declined,
4753
+ },
4754
+ });
4755
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'This field may not be blank.' });
4756
+ }
4757
+ };
4758
+ return {
4759
+ status,
4760
+ validateEmail,
4761
+ successMessage,
4762
+ responseData,
4763
+ errorMessage,
4764
+ isFirstRequest,
4765
+ responseError,
4766
+ };
4767
+ };
4768
+ const useHandlerLifeQuoterEmail = () => {
4769
+ const [requestState, setRequestState] = useReducer(dataHandlerReducer, {
4770
+ ...initialHandlerRequestState,
4771
+ });
4772
+ const { dispatchApplicantState } = useStoreFormLifeApplicant();
4773
+ const { cancelToken } = useCancelToken();
4774
+ const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
4775
+ const validateEmail = async (email) => {
4776
+ dispatchApplicantState({
4777
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantEmailSet,
4778
+ payload: {
4779
+ email,
4780
+ emailStatus: ValidationStatusTypes.Loading,
4781
+ },
4782
+ });
4783
+ if (email) {
4784
+ try {
4785
+ const response = await httpRequest({
4786
+ url: API_AUTH.POST_EMAIL_VALIDATION,
4787
+ method: RequestTypes.Post,
4788
+ data: { email },
4789
+ withoutToken: true,
4790
+ cancelToken,
4791
+ });
4792
+ if (response.data.valid) {
4793
+ dispatchApplicantState({
4794
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantEmailSet,
4795
+ payload: {
4796
+ email,
4797
+ emailStatus: ValidationStatusTypes.Approved,
4798
+ },
4799
+ });
4800
+ }
4801
+ else {
4802
+ dispatchApplicantState({
4803
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantEmailSet,
4804
+ payload: {
4805
+ email,
4806
+ emailStatus: ValidationStatusTypes.Declined,
4807
+ },
4808
+ });
4809
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid email address.' });
4810
+ }
4811
+ }
4812
+ catch (error) {
4813
+ dispatchApplicantState({
4814
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantEmailSet,
4815
+ payload: {
4816
+ email,
4817
+ emailStatus: ValidationStatusTypes.Declined,
4818
+ },
4819
+ });
4820
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid email address.' });
4821
+ }
4822
+ }
4823
+ else {
4824
+ dispatchApplicantState({
4825
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantEmailSet,
4826
+ payload: {
4827
+ email,
4828
+ emailStatus: ValidationStatusTypes.Declined,
4829
+ },
4830
+ });
4831
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'This field may not be blank.' });
4832
+ }
4833
+ };
4834
+ return {
4835
+ status,
4836
+ validateEmail,
4837
+ successMessage,
4838
+ responseData,
4839
+ errorMessage,
4840
+ isFirstRequest,
4841
+ responseError,
4842
+ };
4843
+ };
3911
4844
 
3912
- const QuoteDataHandler = () => {
4845
+ const CarQuoteDataHandler = () => {
3913
4846
  const { configState } = useStoreFormCarConfig();
3914
4847
  const { vehicleState } = useStoreFormCarVehicle();
3915
4848
  const { driverState } = useStoreFormCarDriverBase();
@@ -3940,13 +4873,13 @@ const QuoteDataHandler = () => {
3940
4873
  // updateViewLoader({ type: viewLoaderActionTypes.UpdateLoader, payload: false });
3941
4874
  // updateLocalState({ type: DataManagerActionTypes.RequestState, payload: requestStatusTypes.Error });
3942
4875
  // }
3943
- const constructRequestBody = async (isRecalc) => {
4876
+ const constructRequestBody = (isRecalc) => {
3944
4877
  const vehicles = deepClone(vehicleState).items;
3945
4878
  const drivers = deepClone(driverState).items;
3946
4879
  const postal = deepClone(postalState).item;
3947
4880
  const discount = deepClone(discountState);
3948
4881
  const { policyStartYear, policyStartMonth, policyStartDay } = discountState;
3949
- // dispatchQuoteState({ type: StoreFormCarQuoteActionTypes.UpdateCallMessage, payload: { showCallMessage: false } });
4882
+ // dispatchQuoteState({ type: StoreFormCarQuoteActionTypes.UpdateCarCallMessage, payload: { showCallMessage: false } });
3950
4883
  if (policyStartYear && policyStartMonth && policyStartDay) {
3951
4884
  discount.policyStart = `${policyStartYear}-${policyStartMonth}-${policyStartDay}`;
3952
4885
  delete discount.policyStartYear;
@@ -4013,7 +4946,7 @@ const QuoteDataHandler = () => {
4013
4946
  // || driver.licenceInfo.licenceType === DriverLicenceTypes.G2
4014
4947
  // || (driver.insuranceCancellation && insuranceNonPaymentList.length > 1)) {
4015
4948
  // dispatchQuoteState({
4016
- // type: StoreFormCarQuoteActionTypes.UpdateCallMessage,
4949
+ // type: StoreFormCarQuoteActionTypes.UpdateCarCallMessage,
4017
4950
  // payload: { showCallMessage: true },
4018
4951
  // });
4019
4952
  // discount.quoterInfo.splashScreen = true;
@@ -4182,7 +5115,7 @@ const QuoteDataHandler = () => {
4182
5115
  if (isLoader) {
4183
5116
  openLoader('Please wait for getting redirect url.');
4184
5117
  }
4185
- const requestBody = await constructRequestBody(true);
5118
+ const requestBody = constructRequestBody(true);
4186
5119
  if (requestBody) {
4187
5120
  const response = await httpRequest({
4188
5121
  url: API_FORM_CAR.POST_QUOTE_ONLIA_URL,
@@ -4195,69 +5128,460 @@ const QuoteDataHandler = () => {
4195
5128
  if (response.status === 200 || response.status === 201) {
4196
5129
  const url = response.data.redirectUrl || redirectUrl;
4197
5130
  dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
4198
- window.location.href = url;
5131
+ window.location.href = url;
5132
+ }
5133
+ else {
5134
+ setRequestState({
5135
+ type: DataHandlerActionTypes.SetError,
5136
+ payload: `Axios request error: ${response}`,
5137
+ });
5138
+ }
5139
+ }
5140
+ }
5141
+ };
5142
+ const postRequestQuote = async (isRecalc = false) => {
5143
+ const quoteLocalState = JSON.parse(localStorage.getItem('insurance_car_quotes') || '{}');
5144
+ const { isRequested } = quoteLocalState;
5145
+ // if (appConfigState.appType === AppTypes.TheBig) {
5146
+ // driverState.items.forEach((item) => {
5147
+ // const nonPayList = item.insuranceCancellationList?.filter((cancellation) => (cancellation.reason === 'NonPay')) || [];
5148
+ // if (nonPayList.length > 1 || (item.licenceInfo.licenceType === DriverLicenceTypes.G2) || !item.listed) {
5149
+ // isSplashScreen = true;
5150
+ // }
5151
+ // });
5152
+ // }
5153
+ if (checkIsExpired()) {
5154
+ checkIsExpiredWithModal();
5155
+ }
5156
+ else if (!isRequested) {
5157
+ if (!isRecalc) {
5158
+ if (appConfigState.appType === AppTypes.TheBig) {
5159
+ openLoader('Please wait while we fetch your lowest rates from our insurance partners.');
5160
+ }
5161
+ else {
5162
+ openLoader('Please note: As insurance premiums are based on the information you provide it is important that it be 100% accurate and up to date. If you are not sure it is best to check and edit your information in the next step.');
5163
+ }
5164
+ }
5165
+ else {
5166
+ openLoader('Please wait while we fetch your lowest rates from our insurance partners.');
5167
+ }
5168
+ const requestBody = constructRequestBody(quoteState.isRequested || isRecalc);
5169
+ if (requestBody) {
5170
+ try {
5171
+ const response = await httpRequest({
5172
+ url: API_FORM_CAR.POST_QUOTE_DATA,
5173
+ method: RequestTypes.Post,
5174
+ data: requestBody,
5175
+ withoutToken: true,
5176
+ cancelToken,
5177
+ });
5178
+ if (discountState.quoterInfo.initial) {
5179
+ dispatchDiscountState({
5180
+ type: StoreFormCarDiscountActionTypes.FormCarDiscountQuoterInitialSet,
5181
+ payload: { initial: false },
5182
+ });
5183
+ }
5184
+ if (!quoteState.isRequested) {
5185
+ dispatchQuoteState({
5186
+ type: StoreFormCarQuoteActionTypes.FormCarQuoteIsRequestedSet,
5187
+ payload: { isRequested: true },
5188
+ });
5189
+ }
5190
+ dispatchQuoteState({
5191
+ type: StoreFormCarQuoteActionTypes.FormCarQuoteRequestDateSet,
5192
+ payload: { requestDate: new Date().toISOString() },
5193
+ });
5194
+ dispatchQuoteState({
5195
+ type: StoreFormCarQuoteActionTypes.FormCarQuotesSet,
5196
+ payload: { items: response.data },
5197
+ });
5198
+ setRequestState({
5199
+ type: DataHandlerActionTypes.SetSuccess,
5200
+ });
5201
+ dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
5202
+ if (!isRecalc) {
5203
+ navigate(`/${appConfigState.localIndex}/car/quotes`);
5204
+ }
5205
+ }
5206
+ catch (error) {
5207
+ setRequestState({
5208
+ type: DataHandlerActionTypes.SetError,
5209
+ payload: 'Axios request error',
5210
+ });
5211
+ dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
5212
+ }
5213
+ }
5214
+ }
5215
+ };
5216
+ return ({
5217
+ status,
5218
+ successMessage,
5219
+ responseData,
5220
+ errorMessage,
5221
+ isFirstRequest,
5222
+ responseError,
5223
+ postRequestQuoteOnliaUrl,
5224
+ postRequestQuote,
5225
+ });
5226
+ };
5227
+
5228
+ const HomeQuoteDataHandler = () => {
5229
+ const { postalState } = useStoreFormHomePostal();
5230
+ const { applicantState } = useStoreFormHomeApplicantBase();
5231
+ const { dwellingState } = useStoreFormHomeDwelling();
5232
+ const { discountState, dispatchDiscountState } = useStoreFormHomeDiscount();
5233
+ const { quoteState, dispatchQuoteState } = useStoreFormHomeQuote();
5234
+ const { dispatchAppLoaderState } = useStoreAppLoader();
5235
+ const { appConfigState } = useStoreAppConfig();
5236
+ const { insuranceType } = appConfigState;
5237
+ const navigate = useNavigate();
5238
+ const { checkIsExpired, checkIsExpiredWithModal } = ClearFormDataHandler();
5239
+ const [requestState, setRequestState] = useReducer(dataHandlerReducer, { ...initialHandlerRequestState });
5240
+ const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
5241
+ const { cancelToken } = useCancelToken();
5242
+ const openLoader = (loaderDescription = '') => {
5243
+ dispatchAppLoaderState({
5244
+ type: StoreConfigAppLoaderActionTypes.AppLoaderOpen,
5245
+ payload: {
5246
+ description: loaderDescription,
5247
+ },
5248
+ });
5249
+ };
5250
+ const constructRequestBody = (isRecalc) => {
5251
+ const postal = deepClone(postalState).item;
5252
+ const applicant = deepClone(applicantState);
5253
+ const dwelling = deepClone(dwellingState);
5254
+ const discount = deepClone(discountState);
5255
+ const { policyStartYear, policyStartMonth, policyStartDay } = discountState;
5256
+ const { builtYear, roofReplacedYear, occupiedYear, } = dwellingState;
5257
+ const { insured: { dateInsuredCurrent, dateInsuredSince, birthMonth, birthDay, birthYear, nonsmoker, }, insuranceClaimList, insuranceCancellationList, } = applicant;
5258
+ const lists = {
5259
+ claims: insuranceClaimList?.map((item) => ({
5260
+ date: addDayToDate(`${item.claimYear}-${item.claimMonth}`, 1),
5261
+ type: item.claimType,
5262
+ })),
5263
+ cancellations: insuranceCancellationList?.map((item) => ({
5264
+ date: addDayToDate(`${item.cancellationYear}-${item.cancellationMonth}`, 1),
5265
+ })),
5266
+ };
5267
+ if (!applicant.insuredCurrent && !applicant.insuredBefore) {
5268
+ delete lists.claims;
5269
+ delete lists.cancellations;
5270
+ }
5271
+ else {
5272
+ if (!applicant.insuranceCancellation) {
5273
+ delete lists.cancellations;
5274
+ }
5275
+ if (!applicant.insuranceClaim) {
5276
+ delete lists.claims;
5277
+ }
5278
+ }
5279
+ dwelling.type = insuranceType || InsuranceTypes.Home;
5280
+ dwelling.builtDate = `${builtYear}-01-01`;
5281
+ dwelling.roofReplacedDate = `${roofReplacedYear}-01-01`;
5282
+ dwelling.occupiedDate = `${occupiedYear}-${birthMonth}-${birthDay}`;
5283
+ dwelling.familiesCount = Number(dwelling.familiesCount);
5284
+ dwelling.basementFinishPercent = Number(dwelling.basementFinishPercent);
5285
+ dwelling.mortgagesCount = Number(dwelling.mortgagesCount) - 1;
5286
+ dwelling.deductible = Number(dwelling.deductible);
5287
+ dwelling.liability = Number(dwelling.liability);
5288
+ dwelling.fireHydrantDistance = Number(dwelling.fireHydrantDistance);
5289
+ dwelling.fireHallDistance = Number(dwelling.fireHallDistance);
5290
+ if ((insuranceType !== InsuranceTypes.Home) && dwelling.pp) {
5291
+ dwelling.replacementCost = Number(dwelling.pp);
5292
+ }
5293
+ const heatingExpectedDate = subYearsFromDate('', 20);
5294
+ const heatingDate = compareDates(dwelling.builtDate, heatingExpectedDate) >= 0 ? dwelling.builtDate : heatingExpectedDate;
5295
+ if (dwelling.heatings.length) {
5296
+ dwelling.heatings = dwelling.heatings.map((heating) => ({ type: heating.type, date: heatingDate }));
5297
+ }
5298
+ if (dwelling.pp) {
5299
+ dwelling.pp = Number(dwelling.pp);
5300
+ }
5301
+ else {
5302
+ delete dwelling.pp;
5303
+ }
5304
+ if (dwelling.unitsCount) {
5305
+ dwelling.unitsCount = Number(dwelling.unitsCount);
5306
+ }
5307
+ else {
5308
+ delete dwelling.unitsCount;
5309
+ }
5310
+ if (dwelling.fireExtinguishersCount) {
5311
+ dwelling.fireExtinguishersCount = Number(dwelling.fireExtinguishersCount) - 1;
5312
+ }
5313
+ else {
5314
+ delete dwelling.fireExtinguishersCount;
5315
+ }
5316
+ delete dwelling.isCompleted;
5317
+ delete dwelling.builtYear;
5318
+ delete dwelling.roofReplacedYear;
5319
+ delete dwelling.occupiedYear;
5320
+ delete dwelling.isValid;
5321
+ delete dwelling.inValidation;
5322
+ delete discount.isValid;
5323
+ delete discount.inValidation;
5324
+ // dispatchQuoteState({ type: StoreFormHomeQuoteActionTypes.UpdateHomeCallMessage, payload: { showCallMessage: false } });
5325
+ if (policyStartYear && policyStartMonth && policyStartDay) {
5326
+ discount.policyStart = `${policyStartYear}-${policyStartMonth}-${policyStartDay}`;
5327
+ delete discount.policyStartYear;
5328
+ delete discount.policyStartMonth;
5329
+ delete discount.policyStartDay;
5330
+ }
5331
+ const requestBody = {
5332
+ dwellings: [{
5333
+ ...dwelling,
5334
+ postalCode: postal.postalCode,
5335
+ locationIndex: postal.locationIndex,
5336
+ city: postal.city,
5337
+ streetAddress: postal.streetAddress,
5338
+ ...lists,
5339
+ }],
5340
+ ...discount,
5341
+ insured: {
5342
+ dateOfBirth: `${birthYear}-${birthMonth}-${birthDay}`,
5343
+ dateInsuredCurrent,
5344
+ dateInsuredSince,
5345
+ nonsmoker,
5346
+ },
5347
+ policyStart: discountState.policyStart,
5348
+ multiplePoliciesDiscount: discountState.multiplePoliciesDiscount,
5349
+ emailTo: discountState.emailTo.email,
5350
+ provinceCode: postal.provinceCode,
5351
+ quoterInfo: discount.quoterInfo || {},
5352
+ };
5353
+ requestBody.quoterInfo.recalculate = isRecalc;
5354
+ if (requestBody.quoterInfo?.utmSource === '') {
5355
+ delete requestBody.quoterInfo.utmSource;
5356
+ }
5357
+ if (requestBody.quoterInfo?.utmCampaign === '') {
5358
+ delete requestBody.quoterInfo.utmCampaign;
5359
+ }
5360
+ if (!applicant.insuredCurrent) {
5361
+ delete requestBody.insured.dateInsuredCurrent;
5362
+ delete requestBody.insured.dateInsuredSince;
5363
+ }
5364
+ else {
5365
+ requestBody.insured.dateInsuredCurrent = subYearsFromDate('', Number(requestBody.insured.dateInsuredCurrent));
5366
+ requestBody.insured.dateInsuredSince = subYearsFromDate('', Number(requestBody.insured.dateInsuredSince));
5367
+ }
5368
+ // ==================================
5369
+ // thebig additional properties
5370
+ if (appConfigState.appType !== AppTypes.TheBig) {
5371
+ delete requestBody.quoterInfo.brokerInfo;
5372
+ delete requestBody.quoterInfo.splashScreen;
5373
+ delete requestBody.quoterInfo.caslConsent;
5374
+ }
5375
+ // ===================================
5376
+ return {
5377
+ ...requestBody,
5378
+ };
5379
+ };
5380
+ const postRequestQuoteOnliaUrl = async (isLoader, redirectUrl) => {
5381
+ if (isLoader) {
5382
+ openLoader('Please wait for getting redirect url.');
5383
+ }
5384
+ const requestBody = constructRequestBody(true);
5385
+ if (requestBody) {
5386
+ const response = await httpRequest({
5387
+ url: API_FORM_CAR.POST_QUOTE_ONLIA_URL,
5388
+ method: RequestTypes.Post,
5389
+ data: requestBody,
5390
+ withoutToken: true,
5391
+ cancelToken,
5392
+ });
5393
+ if (response) {
5394
+ if (response.status === 200 || response.status === 201) {
5395
+ const url = response.data.redirectUrl || redirectUrl;
5396
+ dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
5397
+ window.location.href = url;
5398
+ }
5399
+ else {
5400
+ setRequestState({
5401
+ type: DataHandlerActionTypes.SetError,
5402
+ payload: `Axios request error: ${response}`,
5403
+ });
5404
+ }
5405
+ }
5406
+ }
5407
+ };
5408
+ const postRequestQuote = async (isRecalc = false) => {
5409
+ const quoteLocalState = JSON.parse(localStorage.getItem('insurance_home_quotes') || '{}');
5410
+ const { isRequested } = quoteLocalState;
5411
+ if (checkIsExpired()) {
5412
+ checkIsExpiredWithModal();
5413
+ }
5414
+ else if (!isRequested) {
5415
+ if (!isRecalc) {
5416
+ if (appConfigState.appType === AppTypes.TheBig) {
5417
+ openLoader('Please wait while we fetch your lowest rates from our insurance partners.');
5418
+ }
5419
+ else {
5420
+ openLoader('Please note: As insurance premiums are based on the information you provide it is important that it be 100% accurate and up to date. If you are not sure it is best to check and edit your information in the next step.');
5421
+ }
5422
+ }
5423
+ else {
5424
+ openLoader('Please wait while we fetch your lowest rates from our insurance partners.');
5425
+ }
5426
+ const requestBody = constructRequestBody(quoteState.isRequested || isRecalc);
5427
+ if (requestBody) {
5428
+ try {
5429
+ const response = await httpRequest({
5430
+ url: API_FORM_HOME.POST_QUOTE_DATA,
5431
+ method: RequestTypes.Post,
5432
+ data: requestBody,
5433
+ withoutToken: true,
5434
+ cancelToken,
5435
+ });
5436
+ if (discountState.quoterInfo?.initial) {
5437
+ dispatchDiscountState({
5438
+ type: StoreFormHomeDiscountActionTypes.FormHomeDiscountQuoterInitialSet,
5439
+ payload: { initial: false },
5440
+ });
5441
+ }
5442
+ if (!quoteState.isRequested) {
5443
+ dispatchQuoteState({
5444
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteIsRequestedSet,
5445
+ payload: { isRequested: true },
5446
+ });
5447
+ }
5448
+ dispatchQuoteState({
5449
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuoteRequestDateSet,
5450
+ payload: { requestDate: new Date().toISOString() },
5451
+ });
5452
+ dispatchQuoteState({
5453
+ type: StoreFormHomeQuoteActionTypes.FormHomeQuotesSet,
5454
+ payload: { items: response.data },
5455
+ });
5456
+ setRequestState({
5457
+ type: DataHandlerActionTypes.SetSuccess,
5458
+ });
5459
+ dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
5460
+ if (!isRecalc) {
5461
+ navigate(`/${appConfigState.localIndex}/${insuranceType}/quotes`);
5462
+ }
4199
5463
  }
4200
- else {
5464
+ catch (error) {
4201
5465
  setRequestState({
4202
5466
  type: DataHandlerActionTypes.SetError,
4203
- payload: `Axios request error: ${response}`,
5467
+ payload: 'Axios request error',
4204
5468
  });
5469
+ dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
4205
5470
  }
4206
5471
  }
4207
5472
  }
4208
5473
  };
5474
+ return ({
5475
+ status,
5476
+ successMessage,
5477
+ responseData,
5478
+ errorMessage,
5479
+ isFirstRequest,
5480
+ responseError,
5481
+ postRequestQuoteOnliaUrl,
5482
+ postRequestQuote,
5483
+ });
5484
+ };
5485
+
5486
+ const LifeQuoteDataHandler = () => {
5487
+ const { coverageState } = useStoreFormLifeCoverage();
5488
+ const { applicantState } = useStoreFormLifeApplicant();
5489
+ const { quoteState, dispatchQuoteState } = useStoreFormLifeQuote();
5490
+ const { dispatchAppLoaderState } = useStoreAppLoader();
5491
+ const { appConfigState } = useStoreAppConfig();
5492
+ const navigate = useNavigate();
5493
+ const { checkIsExpired, checkIsExpiredWithModal } = ClearFormDataHandler();
5494
+ const [requestState, setRequestState] = useReducer(dataHandlerReducer, { ...initialHandlerRequestState });
5495
+ const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
5496
+ const { cancelToken } = useCancelToken();
5497
+ const openLoader = (loaderDescription = '') => {
5498
+ dispatchAppLoaderState({
5499
+ type: StoreConfigAppLoaderActionTypes.AppLoaderOpen,
5500
+ payload: {
5501
+ description: loaderDescription,
5502
+ },
5503
+ });
5504
+ };
5505
+ const constructRequestBody = () => {
5506
+ const coverage = deepClone(coverageState);
5507
+ const applicant = deepClone(applicantState);
5508
+ delete coverage.isValid;
5509
+ delete coverage.inValidation;
5510
+ delete applicant.isValid;
5511
+ delete applicant.inValidation;
5512
+ // In life insurance we haven't mapping from backend,
5513
+ // and structure ob request body in this step will be
5514
+ // the same as endpoint body,
5515
+ // and we will ignore axios.interceptors formatting
5516
+ const requestBody = {
5517
+ State: coverage.province,
5518
+ BirthMonth: Number(applicant.birthMonth).toString(),
5519
+ Birthday: Number(applicant.birthDay).toString(),
5520
+ BirthYear: Number(applicant.birthYear).toString(),
5521
+ Sex: applicant.gender,
5522
+ Smoker: applicant.smoker ? 'Y' : 'N',
5523
+ Health: 'PP',
5524
+ NewCategory: coverage.type,
5525
+ FaceAmount: Number(coverage.coverage),
5526
+ ModeUsed: 'M',
5527
+ email_to: applicant.emailTo.email,
5528
+ quoter_info: {
5529
+ first_name: applicant.quoterInfo?.firstName,
5530
+ last_name: applicant.quoterInfo?.lastName,
5531
+ phone: Number(applicant.quoterInfo?.phone),
5532
+ recalculate: false,
5533
+ utm_source: applicant.quoterInfo?.utmSource,
5534
+ utm_campaign: applicant.quoterInfo?.utmCampaign,
5535
+ },
5536
+ };
5537
+ if (requestBody.quoter_info?.utm_source === '') {
5538
+ delete requestBody.quoter_info.utm_source;
5539
+ }
5540
+ if (requestBody.quoter_info?.utm_campaign === '') {
5541
+ delete requestBody.quoter_info.utm_campaign;
5542
+ }
5543
+ if (requestBody.Sex === GenderTypes.Other) {
5544
+ requestBody.Sex = GenderTypes.Male;
5545
+ }
5546
+ return {
5547
+ ...requestBody,
5548
+ };
5549
+ };
4209
5550
  const postRequestQuote = async (isRecalc) => {
4210
- // if (appConfigState.appType === AppTypes.TheBig) {
4211
- // driverState.items.forEach((item) => {
4212
- // const nonPayList = item.insuranceCancellationList?.filter((cancellation) => (cancellation.reason === 'NonPay')) || [];
4213
- // if (nonPayList.length > 1 || (item.licenceInfo.licenceType === DriverLicenceTypes.G2) || !item.listed) {
4214
- // isSplashScreen = true;
4215
- // }
4216
- // });
4217
- // }
5551
+ const quoteLocalState = JSON.parse(localStorage.getItem('insurance_life_quotes') || '{}');
5552
+ const { isRequested } = quoteLocalState;
4218
5553
  if (checkIsExpired()) {
4219
5554
  checkIsExpiredWithModal();
4220
5555
  }
4221
- else if (!quoteState.isRequested) {
5556
+ else if (!isRequested) {
4222
5557
  if (!isRecalc) {
4223
- if (appConfigState.appType === AppTypes.TheBig) {
4224
- openLoader('Please wait while we fetch your lowest rates from our insurance partners.');
4225
- }
4226
- else {
4227
- openLoader('Please note: As insurance premiums are based on the information you provide it is important that it be 100% accurate and up to date. If you are not sure it is best to check and edit your information in the next step.');
4228
- }
5558
+ openLoader('Please note: As insurance premiums are based on the information you provide it is important that it be 100% accurate and up to date. If you are not sure it is best to check and edit your information in the next step.');
4229
5559
  }
4230
5560
  else {
4231
5561
  openLoader('Please wait while we fetch your lowest rates from our insurance partners.');
4232
5562
  }
4233
- const requestBody = await constructRequestBody(quoteState.isRequested || isRecalc);
5563
+ const requestBody = constructRequestBody(); // isRecalc is removed in life insurance
4234
5564
  if (requestBody) {
4235
5565
  try {
4236
5566
  const response = await httpRequest({
4237
- url: API_FORM_CAR.POST_QUOTE_DATA,
5567
+ url: API_FORM_LIFE.POST_QUOTE_DATA,
4238
5568
  method: RequestTypes.Post,
4239
5569
  data: requestBody,
4240
5570
  withoutToken: true,
4241
5571
  cancelToken,
4242
5572
  });
4243
- if (discountState.quoterInfo.initial) {
4244
- dispatchDiscountState({
4245
- type: StoreFormCarDiscountActionTypes.FormCarDiscountQuoterInitialSet,
4246
- payload: { initial: false },
4247
- });
4248
- }
4249
5573
  if (!quoteState.isRequested) {
4250
5574
  dispatchQuoteState({
4251
- type: StoreFormCarQuoteActionTypes.FormCarQuoteIsRequestedSet,
5575
+ type: StoreFormLifeQuoteActionTypes.FormLifeQuoteIsRequestedSet,
4252
5576
  payload: { isRequested: true },
4253
5577
  });
4254
5578
  }
4255
5579
  dispatchQuoteState({
4256
- type: StoreFormCarQuoteActionTypes.FormCarQuoteRequestDateSet,
5580
+ type: StoreFormLifeQuoteActionTypes.FormLifeQuoteRequestDateSet,
4257
5581
  payload: { requestDate: new Date().toISOString() },
4258
5582
  });
4259
5583
  dispatchQuoteState({
4260
- type: StoreFormCarQuoteActionTypes.FormCarQuotesSet,
5584
+ type: StoreFormLifeQuoteActionTypes.FormLifeQuotesSet,
4261
5585
  payload: { items: response.data },
4262
5586
  });
4263
5587
  setRequestState({
@@ -4265,7 +5589,7 @@ const QuoteDataHandler = () => {
4265
5589
  });
4266
5590
  dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
4267
5591
  if (!isRecalc) {
4268
- navigate(`/${appConfigState.localIndex}/car/quotes`);
5592
+ navigate(`/${appConfigState.localIndex}/life/quotes`);
4269
5593
  }
4270
5594
  }
4271
5595
  catch (error) {
@@ -4285,8 +5609,8 @@ const QuoteDataHandler = () => {
4285
5609
  errorMessage,
4286
5610
  isFirstRequest,
4287
5611
  responseError,
4288
- postRequestQuoteOnliaUrl,
4289
5612
  postRequestQuote,
5613
+ postRequestQuoteOnliaUrl: () => { },
4290
5614
  });
4291
5615
  };
4292
5616
 
@@ -4543,9 +5867,6 @@ const useValidationCarDiscount = () => {
4543
5867
  }
4544
5868
  });
4545
5869
  if (!errors.length) {
4546
- if (requestFn) {
4547
- requestFn();
4548
- }
4549
5870
  dispatchDiscountState({
4550
5871
  type: StoreFormCarDiscountActionTypes.FormCarDiscountValidate,
4551
5872
  payload: { inValidation: false },
@@ -4555,6 +5876,9 @@ const useValidationCarDiscount = () => {
4555
5876
  payload: { isValid: true },
4556
5877
  });
4557
5878
  formIsValid = true;
5879
+ if (requestFn) {
5880
+ requestFn();
5881
+ }
4558
5882
  }
4559
5883
  else {
4560
5884
  const element = document.getElementsByName(errors[0])[0];
@@ -4582,60 +5906,93 @@ const useValidationCarDiscount = () => {
4582
5906
  };
4583
5907
  };
4584
5908
 
4585
- // import { useHandlerPostal } from '../../../dataHandlers';
4586
5909
  const useValidationAddress = () => {
4587
- // const {
4588
- // // getPostal, status,
4589
- // } = useHandlerPostal(InsuranceTypes.Home);
4590
- const { addressState, dispatchAddressState } = useStoreFormHomeAddress();
4591
- const { postalState } = useStoreFormHomePostal();
4592
- const { inValidation = false, isValid = false, } = addressState;
4593
- const { appConfigState } = useStoreAppConfig();
5910
+ const { dwellingState } = useStoreFormHomeDwelling();
5911
+ const { dispatchAppLoaderState } = useStoreAppLoader();
5912
+ const { postalState, dispatchPostalState } = useStoreFormHomePostal();
5913
+ const { getPlaceByAddress } = useHandlerPostal(InsuranceTypes.Home);
5914
+ const { inValidation = false, isValid = false, item: { streetAddress, city, postalCode, provinceCode, }, } = postalState;
5915
+ const { appConfigState: { localIndex, insuranceType } } = useStoreAppConfig();
4594
5916
  const { dispatchAppModalState } = useStoreAppModal();
4595
5917
  const navigate = useNavigate();
4596
- const addressFormValidate = (isRedirect = true) => {
5918
+ const isHomeOwner = insuranceType === InsuranceTypes.Home;
5919
+ const addressFormValidate = async (isRedirect = true) => {
4597
5920
  let formIsValid = false;
4598
- // getPostal(postalCodeFormat(postalState.item.postalCode as string));
4599
5921
  const postalKeys = [
5922
+ 'errorMessage',
5923
+ 'streetAddress',
4600
5924
  'city',
4601
5925
  'postalCode',
4602
5926
  'provinceCode',
4603
5927
  ];
4604
- const addressKeys = [
5928
+ const dwellingKeys = [
4605
5929
  'type',
4606
- 'addressStreet',
4607
5930
  ];
4608
5931
  const errors = [];
4609
- dispatchAddressState({
4610
- type: StoreFormHomeAddressActionTypes.FormHomeAddressValidate,
5932
+ dispatchPostalState({
5933
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidate,
4611
5934
  payload: { inValidation: true },
4612
5935
  });
4613
- Object.keys(addressState).forEach((key) => {
4614
- if (addressKeys.includes(key) && !addressState[key]) {
4615
- errors.push(key);
4616
- }
4617
- // if (key === 'postalCode' && (status === RequestStatusTypes.Error) && addressState[key]) {
4618
- // errors.push(key);
4619
- // }
4620
- if (key === 'addressStreet' && !/\b\s+\b/.test(addressState[key])) {
5936
+ Object.keys(dwellingState).forEach((key) => {
5937
+ if (dwellingKeys.includes(key) && !dwellingState[key]) {
4621
5938
  errors.push(key);
4622
5939
  }
4623
5940
  });
4624
5941
  Object.keys(postalState.item).forEach((key) => {
4625
- if (postalKeys.includes(key) && !postalState.item[key]) {
5942
+ if (postalKeys.includes(key) && !postalState.item[key] && key !== 'errorMessage') {
5943
+ errors.push(key);
5944
+ }
5945
+ if ((key === 'errorMessage') && postalState.item[key]) {
4626
5946
  errors.push(key);
4627
5947
  }
4628
5948
  });
4629
5949
  if (!errors.length) {
4630
- dispatchAddressState({
4631
- type: StoreFormHomeAddressActionTypes.FormHomeAddressValidate,
4632
- payload: { inValidation: false },
4633
- });
4634
- dispatchAddressState({
4635
- type: StoreFormHomeAddressActionTypes.FormHomeAddressValidateSet,
4636
- payload: { isValid: true },
4637
- });
4638
- formIsValid = true;
5950
+ if (isHomeOwner) {
5951
+ try {
5952
+ dispatchAppLoaderState({
5953
+ type: StoreConfigAppLoaderActionTypes.AppLoaderOpen,
5954
+ payload: {
5955
+ description: '',
5956
+ },
5957
+ });
5958
+ await getPlaceByAddress(streetAddress, city, postalCode, provinceCode);
5959
+ dispatchPostalState({
5960
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidate,
5961
+ payload: { inValidation: false },
5962
+ });
5963
+ dispatchPostalState({
5964
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
5965
+ payload: { isValid: true },
5966
+ });
5967
+ formIsValid = true;
5968
+ dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
5969
+ }
5970
+ catch (e) {
5971
+ console.log('dwelling get error:', e);
5972
+ dispatchPostalState({
5973
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidate,
5974
+ payload: { inValidation: false },
5975
+ });
5976
+ dispatchPostalState({
5977
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
5978
+ payload: { isValid: true },
5979
+ });
5980
+ formIsValid = true;
5981
+ dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
5982
+ }
5983
+ }
5984
+ else {
5985
+ dispatchPostalState({
5986
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidate,
5987
+ payload: { inValidation: false },
5988
+ });
5989
+ dispatchPostalState({
5990
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
5991
+ payload: { isValid: true },
5992
+ });
5993
+ formIsValid = true;
5994
+ dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
5995
+ }
4639
5996
  }
4640
5997
  else {
4641
5998
  const element = document.getElementsByName(errors[0])[0];
@@ -4646,13 +6003,13 @@ const useValidationAddress = () => {
4646
6003
  title: 'Please enter missing values of required fields',
4647
6004
  },
4648
6005
  });
4649
- dispatchAddressState({
4650
- type: StoreFormHomeAddressActionTypes.FormHomeAddressValidateSet,
6006
+ dispatchPostalState({
6007
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
4651
6008
  payload: { isValid: false },
4652
6009
  });
4653
6010
  }
4654
6011
  if (errors.length && isRedirect) {
4655
- navigate(`/${appConfigState.localIndex || defaultLocalIndex}/home/address`);
6012
+ navigate(`/${localIndex || defaultLocalIndex}/${insuranceType}`);
4656
6013
  }
4657
6014
  return formIsValid;
4658
6015
  };
@@ -4668,8 +6025,9 @@ const useValidationApplicant = () => {
4668
6025
  const { discountState } = useStoreFormHomeDiscount();
4669
6026
  const { dwellingState } = useStoreFormHomeDwelling();
4670
6027
  const { inValidation: applicantFormIsInValidation = false, isValid: applicantFormIsValid = false, } = applicantState;
4671
- const { appConfigState } = useStoreAppConfig();
6028
+ const { appConfigState: { localIndex, insuranceType } } = useStoreAppConfig();
4672
6029
  const { dispatchAppModalState } = useStoreAppModal();
6030
+ // const flowIsPaused: boolean = insuranceClaimList?.length > 2 || insuranceCancellationList?.length > 2;
4673
6031
  const navigate = useNavigate();
4674
6032
  const applicantFormValidate = (isRedirect = true) => {
4675
6033
  let formIsValid = false;
@@ -4682,13 +6040,14 @@ const useValidationApplicant = () => {
4682
6040
  'policyStartMonth',
4683
6041
  'policyStartYear',
4684
6042
  ];
6043
+ const applicantKeys = [
6044
+ 'firstName',
6045
+ 'insuredCurrent',
6046
+ 'insuredBefore',
6047
+ ];
4685
6048
  const objectKeys = [
4686
- 'quoterInfo',
4687
6049
  'insured',
4688
6050
  ];
4689
- const quoterInfoKeys = [
4690
- 'firstName',
4691
- ];
4692
6051
  const insuredKeys = [
4693
6052
  'birthDay',
4694
6053
  'birthMonth',
@@ -4707,6 +6066,27 @@ const useValidationApplicant = () => {
4707
6066
  });
4708
6067
  // === check errors in applicant state ===
4709
6068
  Object.keys(applicantState).forEach((key) => {
6069
+ if (applicantKeys.includes(key)) {
6070
+ if (key === 'insuredCurrent') {
6071
+ if (applicantState[key] === undefined) {
6072
+ errors.push(key);
6073
+ }
6074
+ else if (applicantState[key]) { // insuredCurrent: true
6075
+ if (!applicantState.insured.dateInsuredCurrent) {
6076
+ errors.push('dateInsuredCurrent');
6077
+ }
6078
+ if (!applicantState.insured.dateInsuredSince) {
6079
+ errors.push('dateInsuredSince');
6080
+ }
6081
+ }
6082
+ else if (applicantState.insuredBefore === undefined) {
6083
+ errors.push('insuredBefore');
6084
+ }
6085
+ }
6086
+ if (key === 'firstName' && !applicantState[key]) {
6087
+ errors.push(key);
6088
+ }
6089
+ }
4710
6090
  if (objectKeys.includes(key)) {
4711
6091
  Object.keys(applicantState[key]).forEach((objectKey) => {
4712
6092
  if (!applicantState[key][objectKey]) {
@@ -4715,23 +6095,23 @@ const useValidationApplicant = () => {
4715
6095
  errors.push(objectKey);
4716
6096
  }
4717
6097
  }
4718
- if (quoterInfoKeys.includes(objectKey)) {
4719
- errors.push(objectKey);
4720
- }
4721
6098
  }
4722
6099
  });
4723
6100
  }
4724
- if (arrayKeys.includes(key)) {
4725
- applicantState[key].forEach((listItem, listItemIndex) => {
4726
- Object.keys(listItem).forEach((objectKey) => {
4727
- if (!listItem[objectKey] && objectKey.indexOf('Date') === -1) {
4728
- if (!((!applicantState.insuranceCancellation && key === 'insuranceCancellationList')
4729
- || (!applicantState.insuranceClaim && key === 'insuranceClaimList'))) {
4730
- errors.push(`${objectKey}-${listItemIndex}`);
6101
+ if (applicantState.insuredCurrent || applicantState.insuredBefore) {
6102
+ if (arrayKeys.includes(key)) {
6103
+ applicantState[key].forEach((listItem, listItemIndex) => {
6104
+ Object.keys(listItem).forEach((objectKey) => {
6105
+ const canSkipFields = ['date', 'type'].includes(objectKey);
6106
+ if (!listItem[objectKey] && objectKey.indexOf('Date') === -1 && !canSkipFields) {
6107
+ if (!((!applicantState.insuranceCancellation && key === 'insuranceCancellationList')
6108
+ || (!applicantState.insuranceClaim && key === 'insuranceClaimList'))) {
6109
+ errors.push(`${objectKey}-${listItemIndex}`);
6110
+ }
4731
6111
  }
4732
- }
6112
+ });
4733
6113
  });
4734
- });
6114
+ }
4735
6115
  }
4736
6116
  });
4737
6117
  // === check errors in discount state ===
@@ -4772,7 +6152,7 @@ const useValidationApplicant = () => {
4772
6152
  });
4773
6153
  }
4774
6154
  if (errors.length && isRedirect) {
4775
- navigate(`/${appConfigState.localIndex || defaultLocalIndex}/home/applicant`);
6155
+ navigate(`/${localIndex || defaultLocalIndex}/${insuranceType}/applicant`);
4776
6156
  }
4777
6157
  return formIsValid;
4778
6158
  };
@@ -4786,7 +6166,7 @@ const useValidationApplicant = () => {
4786
6166
  const useValidationDwelling = () => {
4787
6167
  const { dwellingState, dispatchDwellingState } = useStoreFormHomeDwelling();
4788
6168
  const { inValidation: dwellingFormIsInValidation = false, isValid: dwellingFormIsValid = false, } = dwellingState;
4789
- const { appConfigState } = useStoreAppConfig();
6169
+ const { appConfigState: { localIndex, insuranceType } } = useStoreAppConfig();
4790
6170
  const { dispatchAppModalState } = useStoreAppModal();
4791
6171
  const navigate = useNavigate();
4792
6172
  const dwellingFormValidate = (isRedirect = true) => {
@@ -4794,7 +6174,7 @@ const useValidationDwelling = () => {
4794
6174
  const keys = [
4795
6175
  'builtYear',
4796
6176
  'livingArea',
4797
- 'roofReplaceYear',
6177
+ 'roofReplacedYear',
4798
6178
  'fireHallDistance',
4799
6179
  'fireHydrantDistance',
4800
6180
  'buildingStructure',
@@ -4831,7 +6211,7 @@ const useValidationDwelling = () => {
4831
6211
  }
4832
6212
  else {
4833
6213
  if (isRedirect) {
4834
- navigate(`/${appConfigState.localIndex || defaultLocalIndex}/home/property`);
6214
+ navigate(`/${localIndex || defaultLocalIndex}/${insuranceType}/property`);
4835
6215
  }
4836
6216
  const element = document.getElementsByName(errors[0])[0];
4837
6217
  element?.scrollIntoView({ block: 'center', behavior: 'smooth' });
@@ -4857,18 +6237,17 @@ const useValidationDwelling = () => {
4857
6237
 
4858
6238
  const useValidationHomeDiscount = () => {
4859
6239
  const { discountState, dispatchDiscountState } = useStoreFormHomeDiscount();
4860
- const { applicantState } = useStoreFormHomeApplicantBase();
4861
6240
  const { dwellingState } = useStoreFormHomeDwelling();
4862
- const { inValidation = false, isValid = false, } = discountState;
4863
- const { appConfigState } = useStoreAppConfig();
6241
+ const { inValidation = false, isValid = false, quoterInfo, } = discountState;
6242
+ const { appConfigState: { localIndex, insuranceType } } = useStoreAppConfig();
4864
6243
  const { dispatchAppModalState } = useStoreAppModal();
4865
6244
  const navigate = useNavigate();
4866
- const homeDiscountFormValidate = (isRedirect = true) => {
6245
+ const homeDiscountFormValidate = (isRedirect = true, requestFn) => {
4867
6246
  let formIsValid = false;
4868
6247
  // const dwellingKeys = [
4869
- // 'mortgageCount',
6248
+ // 'mortgagesCount',
4870
6249
  // ];
4871
- const applicantKeys = [
6250
+ const discountKeys = [
4872
6251
  'firstName',
4873
6252
  'lastName',
4874
6253
  'phone',
@@ -4878,12 +6257,15 @@ const useValidationHomeDiscount = () => {
4878
6257
  type: StoreFormHomeDiscountActionTypes.FormHomeDiscountValidate,
4879
6258
  payload: { inValidation: true },
4880
6259
  });
4881
- if (!dwellingState.mortgageCount) {
4882
- errors.push('mortgageCount');
6260
+ if (!dwellingState.mortgagesCount) {
6261
+ errors.push('mortgagesCount');
6262
+ }
6263
+ if (!dwellingState.fireExtinguishersCount) {
6264
+ errors.push('fireExtinguishersCount');
4883
6265
  }
4884
- if (applicantState.quoterInfo) {
4885
- Object.keys(applicantState.quoterInfo).forEach((key) => {
4886
- if (applicantKeys.includes(key) && !applicantState.quoterInfo?.[key]) {
6266
+ if (quoterInfo) {
6267
+ Object.keys(quoterInfo).forEach((key) => {
6268
+ if (discountKeys.includes(key) && !quoterInfo?.[key]) {
4887
6269
  errors.push(key);
4888
6270
  }
4889
6271
  });
@@ -4900,6 +6282,9 @@ const useValidationHomeDiscount = () => {
4900
6282
  type: StoreFormHomeDiscountActionTypes.FormHomeDiscountValidateSet,
4901
6283
  payload: { isValid: true },
4902
6284
  });
6285
+ if (requestFn) {
6286
+ requestFn();
6287
+ }
4903
6288
  formIsValid = true;
4904
6289
  }
4905
6290
  else {
@@ -4916,8 +6301,8 @@ const useValidationHomeDiscount = () => {
4916
6301
  payload: { isValid: false },
4917
6302
  });
4918
6303
  }
4919
- if (errors.length && isRedirect) {
4920
- navigate(`/${appConfigState.localIndex || defaultLocalIndex}/home/discount`);
6304
+ if (errors.length && isRedirect && (window.location.pathname !== `/${localIndex || defaultLocalIndex}/${insuranceType}/discount`)) {
6305
+ navigate(`/${localIndex || defaultLocalIndex}/${insuranceType}/discount`);
4921
6306
  }
4922
6307
  return formIsValid;
4923
6308
  };
@@ -4928,5 +6313,144 @@ const useValidationHomeDiscount = () => {
4928
6313
  };
4929
6314
  };
4930
6315
 
4931
- export { ClearFormDataHandler, QuoteDataHandler, StoreClientActionTypes, StoreConfigAppConfigActionTypes, StoreConfigAppDeviceActionTypes, StoreConfigAppLoaderActionTypes, StoreConfigAppModalActionTypes, StoreFormCarConfigActionTypes, StoreFormCarDiscountActionTypes, StoreFormCarDriverAccidentActionTypes, StoreFormCarDriverBaseActionTypes, StoreFormCarDriverCancellationActionTypes, StoreFormCarDriverInfoActionTypes, StoreFormCarDriverInsuranceActionTypes, StoreFormCarDriverLicenceActionTypes, StoreFormCarDriverSuspensionActionTypes, StoreFormCarDriverTicketActionTypes, StoreFormCarPostalActionTypes, StoreFormCarQuoteActionTypes, StoreFormCarVehicleActionTypes, StoreFormHomeAddressActionTypes, StoreFormHomeApplicantBaseActionTypes, StoreFormHomeApplicantCancellationActionTypes, StoreFormHomeApplicantClaimActionTypes, StoreFormHomeApplicantInfoActionTypes, StoreFormHomeApplicantInsuranceActionTypes, StoreFormHomeDiscountActionTypes, StoreFormHomeDwellingActionTypes, StoreFormHomePostalActionTypes, StorePartnerActionTypes, StoreProvider, addDayToDate, configStateReducer, differenceInHoursFromNow, formCarReducer, formHomeReducer, globalStateReducer, initHttpResponse, reducers, default_1 as token, useHandlerAuth, useHandlerCarMake, useHandlerCarModel, useHandlerPartner, useHandlerPostal, useHandlerQuoterEmail, useStoreAppConfig, useStoreAppDevice, useStoreAppLoader, useStoreAppModal, useStoreClient, useStoreClientLoggedIn, useStoreClientProfile, useStoreClientToken, useStoreDeviceBP, useStoreDeviceType, useStoreFormCarConfig, useStoreFormCarDiscount, useStoreFormCarDriverAccident, useStoreFormCarDriverBase, useStoreFormCarDriverCancellation, useStoreFormCarDriverInfo, useStoreFormCarDriverInsurance, useStoreFormCarDriverLicence, useStoreFormCarDriverSuspension, useStoreFormCarDriverTicket, useStoreFormCarPostal, useStoreFormCarQuote, useStoreFormCarVehicle, useStoreFormHomeAddress, useStoreFormHomeApplicantBase, useStoreFormHomeApplicantCancellation, useStoreFormHomeApplicantClaim, useStoreFormHomeApplicantInfo, useStoreFormHomeApplicantInsurance, useStoreFormHomeDiscount, useStoreFormHomeDwelling, useStoreFormHomePostal, useStorePartner, useValidationAddress, useValidationApplicant, useValidationCarDiscount, useValidationDriver, useValidationDwelling, useValidationHomeDiscount, useValidationVehicle };
6316
+ const useValidationCoverage = () => {
6317
+ const { coverageState, dispatchCoverageState } = useStoreFormLifeCoverage();
6318
+ const { inValidation = false, isValid = false, } = coverageState;
6319
+ const { appConfigState } = useStoreAppConfig();
6320
+ const { dispatchAppModalState } = useStoreAppModal();
6321
+ const navigate = useNavigate();
6322
+ const coverageFormValidate = (isRedirect = true) => {
6323
+ let formIsValid = false;
6324
+ const keys = [
6325
+ 'province',
6326
+ 'type',
6327
+ 'coverage',
6328
+ ];
6329
+ const errors = [];
6330
+ dispatchCoverageState({
6331
+ type: StoreFormLifeCoverageActionTypes.FormLifeCoverageValidate,
6332
+ payload: { inValidation: true },
6333
+ });
6334
+ Object.keys(coverageState).forEach((key) => {
6335
+ if (keys.includes(key) && !coverageState[key]) {
6336
+ errors.push(key);
6337
+ }
6338
+ });
6339
+ if (!errors.length) {
6340
+ dispatchCoverageState({
6341
+ type: StoreFormLifeCoverageActionTypes.FormLifeCoverageValidate,
6342
+ payload: { inValidation: false },
6343
+ });
6344
+ dispatchCoverageState({
6345
+ type: StoreFormLifeCoverageActionTypes.FormLifeCoverageValidateSet,
6346
+ payload: { isValid: true },
6347
+ });
6348
+ formIsValid = true;
6349
+ }
6350
+ else {
6351
+ const element = document.getElementsByName(errors[0])[0];
6352
+ element?.scrollIntoView({ block: 'center', behavior: 'smooth' });
6353
+ dispatchAppModalState({
6354
+ type: StoreConfigAppModalActionTypes.AppModalMessageModal,
6355
+ payload: {
6356
+ title: 'Please enter missing values of required fields',
6357
+ },
6358
+ });
6359
+ dispatchCoverageState({
6360
+ type: StoreFormLifeCoverageActionTypes.FormLifeCoverageValidateSet,
6361
+ payload: { isValid: false },
6362
+ });
6363
+ }
6364
+ if (errors.length && isRedirect) {
6365
+ navigate(`/${appConfigState.localIndex || defaultLocalIndex}/life/coverage`);
6366
+ }
6367
+ return formIsValid;
6368
+ };
6369
+ return {
6370
+ coverageFormValidate,
6371
+ coverageFormIsInValidation: inValidation,
6372
+ coverageFormIsValid: isValid,
6373
+ };
6374
+ };
6375
+
6376
+ const useValidationLifeApplicant = () => {
6377
+ const { applicantState, dispatchApplicantState } = useStoreFormLifeApplicant();
6378
+ const { quoterInfo, inValidation: applicantFormIsInValidation = false, isValid: applicantFormIsValid = false, } = applicantState;
6379
+ const { appConfigState } = useStoreAppConfig();
6380
+ const { dispatchAppModalState } = useStoreAppModal();
6381
+ const navigate = useNavigate();
6382
+ const applicantFormValidate = (isRedirect = true, requestFn) => {
6383
+ let formIsValid = false;
6384
+ const keys = [
6385
+ 'birthDay',
6386
+ 'birthMonth',
6387
+ 'birthYear',
6388
+ 'gender',
6389
+ ];
6390
+ const quoterInfoKeys = [
6391
+ 'firstName',
6392
+ 'lastName',
6393
+ 'phone',
6394
+ ];
6395
+ const errors = [];
6396
+ dispatchApplicantState({
6397
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantValidate,
6398
+ payload: { inValidation: true },
6399
+ });
6400
+ Object.keys(applicantState).forEach((key) => {
6401
+ if (keys.includes(key) && !applicantState[key]) {
6402
+ errors.push(key);
6403
+ }
6404
+ });
6405
+ if (applicantState.emailTo.emailStatus !== ValidationStatusTypes.Approved) {
6406
+ errors.push('email');
6407
+ }
6408
+ if (quoterInfo) {
6409
+ Object.keys(quoterInfo).forEach((key) => {
6410
+ if (quoterInfoKeys.includes(key) && !quoterInfo?.[key]) {
6411
+ errors.push(key);
6412
+ }
6413
+ });
6414
+ }
6415
+ if (!errors.length) {
6416
+ dispatchApplicantState({
6417
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantValidateSet,
6418
+ payload: { isValid: true },
6419
+ });
6420
+ dispatchApplicantState({
6421
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantValidate,
6422
+ payload: { inValidation: false },
6423
+ });
6424
+ if (requestFn) {
6425
+ requestFn();
6426
+ }
6427
+ formIsValid = true;
6428
+ }
6429
+ else {
6430
+ const element = document.getElementsByName(errors[0])[0];
6431
+ element?.scrollIntoView({ block: 'center', behavior: 'smooth' });
6432
+ dispatchAppModalState({
6433
+ type: StoreConfigAppModalActionTypes.AppModalMessageModal,
6434
+ payload: {
6435
+ title: 'Please enter missing values of required fields',
6436
+ },
6437
+ });
6438
+ dispatchApplicantState({
6439
+ type: StoreFormLifeApplicantActionTypes.FormLifeApplicantValidateSet,
6440
+ payload: { isValid: false },
6441
+ });
6442
+ }
6443
+ if (errors.length && isRedirect) {
6444
+ navigate(`/${appConfigState.localIndex || defaultLocalIndex}/life/applicant`);
6445
+ }
6446
+ return formIsValid;
6447
+ };
6448
+ return {
6449
+ applicantFormValidate,
6450
+ applicantFormIsInValidation,
6451
+ applicantFormIsValid,
6452
+ };
6453
+ };
6454
+
6455
+ export { CarQuoteDataHandler, ClearFormDataHandler, HomeQuoteDataHandler, LifeQuoteDataHandler, StoreClientActionTypes, StoreConfigAppConfigActionTypes, StoreConfigAppDeviceActionTypes, StoreConfigAppLoaderActionTypes, StoreConfigAppModalActionTypes, StoreFormCarConfigActionTypes, StoreFormCarDiscountActionTypes, StoreFormCarDriverAccidentActionTypes, StoreFormCarDriverBaseActionTypes, StoreFormCarDriverCancellationActionTypes, StoreFormCarDriverInfoActionTypes, StoreFormCarDriverInsuranceActionTypes, StoreFormCarDriverLicenceActionTypes, StoreFormCarDriverSuspensionActionTypes, StoreFormCarDriverTicketActionTypes, StoreFormCarPostalActionTypes, StoreFormCarQuoteActionTypes, StoreFormCarVehicleActionTypes, StoreFormHomeApplicantBaseActionTypes, StoreFormHomeApplicantCancellationActionTypes, StoreFormHomeApplicantClaimActionTypes, StoreFormHomeApplicantInfoActionTypes, StoreFormHomeApplicantInsuranceActionTypes, StoreFormHomeDiscountActionTypes, StoreFormHomeDwellingActionTypes, StoreFormHomePostalActionTypes, StoreFormHomeQuoteActionTypes, StoreFormLifeApplicantActionTypes, StoreFormLifeCoverageActionTypes, StoreFormLifePostalActionTypes, StoreFormLifeQuoteActionTypes, StorePartnerActionTypes, StoreProvider, addDayToDate, configStateReducer, differenceInHoursFromNow, formCarReducer, formCondoDwellingInitialState, formHomeDwellingInitialState, formHomeReducer, formLifeReducer, formTenantDwellingInitialState, getDwellingInitialState, globalStateReducer, initHttpResponse, reducers, default_1 as token, useHandlerAuth, useHandlerCarMake, useHandlerCarModel, useHandlerCarQuoterEmail, useHandlerHomeQuoterEmail, useHandlerLifeQuoterEmail, useHandlerPartner, useHandlerPostal, useProvince, useStoreAppConfig, useStoreAppDevice, useStoreAppLoader, useStoreAppModal, useStoreClient, useStoreClientLoggedIn, useStoreClientProfile, useStoreClientToken, useStoreDeviceBP, useStoreDeviceType, useStoreFormCarConfig, useStoreFormCarDiscount, useStoreFormCarDriverAccident, useStoreFormCarDriverBase, useStoreFormCarDriverCancellation, useStoreFormCarDriverInfo, useStoreFormCarDriverInsurance, useStoreFormCarDriverLicence, useStoreFormCarDriverSuspension, useStoreFormCarDriverTicket, useStoreFormCarPostal, useStoreFormCarQuote, useStoreFormCarVehicle, useStoreFormHomeApplicantBase, useStoreFormHomeApplicantCancellation, useStoreFormHomeApplicantClaim, useStoreFormHomeApplicantInfo, useStoreFormHomeApplicantInsurance, useStoreFormHomeDiscount, useStoreFormHomeDwelling, useStoreFormHomePostal, useStoreFormHomeQuote, useStoreFormLifeApplicant, useStoreFormLifeCoverage, useStoreFormLifePostal, useStoreFormLifeQuote, useStorePartner, useValidationAddress, useValidationApplicant, useValidationCarDiscount, useValidationCoverage, useValidationDriver, useValidationDwelling, useValidationHomeDiscount, useValidationLifeApplicant, useValidationVehicle };
4932
6456
  //# sourceMappingURL=index.js.map