@mychoice/mychoice-sdk-store 2.2.24 → 2.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/handlers/dataHandlers/QuoterPhoneDataHandler/QuoterPhoneDataHandler.d.ts +4 -0
- package/dist/cjs/handlers/dataHandlers/QuoterPhoneDataHandler/index.d.ts +1 -0
- package/dist/cjs/handlers/dataHandlers/QuoterPhoneDataHandler/interfaces.d.ts +4 -0
- package/dist/cjs/handlers/dataHandlers/index.d.ts +1 -0
- package/dist/cjs/index.js +274 -29
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/actions.d.ts +1 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts +8 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts +1 -1
- package/dist/cjs/states/reducers/states/formStates/FormHomeState/DiscountState/actions.d.ts +1 -0
- package/dist/cjs/states/reducers/states/formStates/FormHomeState/DiscountState/interfaces.d.ts +8 -0
- package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/actions.d.ts +1 -0
- package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/interfaces.d.ts +8 -0
- package/dist/esm/handlers/dataHandlers/QuoterPhoneDataHandler/QuoterPhoneDataHandler.d.ts +4 -0
- package/dist/esm/handlers/dataHandlers/QuoterPhoneDataHandler/index.d.ts +1 -0
- package/dist/esm/handlers/dataHandlers/QuoterPhoneDataHandler/interfaces.d.ts +4 -0
- package/dist/esm/handlers/dataHandlers/index.d.ts +1 -0
- package/dist/esm/index.js +273 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/states/reducers/states/formStates/FormCarState/DiscountState/actions.d.ts +1 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts +8 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts +1 -1
- package/dist/esm/states/reducers/states/formStates/FormHomeState/DiscountState/actions.d.ts +1 -0
- package/dist/esm/states/reducers/states/formStates/FormHomeState/DiscountState/interfaces.d.ts +8 -0
- package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/actions.d.ts +1 -0
- package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/interfaces.d.ts +8 -0
- package/dist/index.d.ts +38 -3
- package/package.json +3 -3
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UseHandlerQuoterPhoneInterface } from './interfaces';
|
|
2
|
+
export declare const useHandlerCarQuoterPhone: () => UseHandlerQuoterPhoneInterface;
|
|
3
|
+
export declare const useHandlerHomeQuoterPhone: () => UseHandlerQuoterPhoneInterface;
|
|
4
|
+
export declare const useHandlerLifeQuoterPhone: () => UseHandlerQuoterPhoneInterface;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useHandlerCarQuoterPhone, useHandlerHomeQuoterPhone, useHandlerLifeQuoterPhone } from './QuoterPhoneDataHandler';
|
package/dist/cjs/index.js
CHANGED
|
@@ -474,7 +474,7 @@ const vehicleItemInitialState = {
|
|
|
474
474
|
winterTires: true,
|
|
475
475
|
parkingLocation: 'garage',
|
|
476
476
|
primaryUse: mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal,
|
|
477
|
-
distanceDaily:
|
|
477
|
+
distanceDaily: undefined,
|
|
478
478
|
distanceBusiness: 0,
|
|
479
479
|
distanceYearly: 0,
|
|
480
480
|
comprehensive: { ...vehicleComprehensiveInitialState },
|
|
@@ -919,6 +919,10 @@ const driverItemInitialState = {
|
|
|
919
919
|
listedMonth: '',
|
|
920
920
|
insured: true,
|
|
921
921
|
insuredDate: '',
|
|
922
|
+
notCurrentlyInsured: false,
|
|
923
|
+
lastPolicyEndYear: '',
|
|
924
|
+
lastPolicyEndMonth: '',
|
|
925
|
+
lastPolicyCancelReason: '',
|
|
922
926
|
insuranceCancellation: false,
|
|
923
927
|
insuranceCancellationList: [{ ...driverCancellationItemInitialState }],
|
|
924
928
|
licenceSuspension: false,
|
|
@@ -1878,6 +1882,7 @@ const discountQuoterInfoInitialState = {
|
|
|
1878
1882
|
firstName: '',
|
|
1879
1883
|
lastName: '',
|
|
1880
1884
|
phone: '',
|
|
1885
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial,
|
|
1881
1886
|
recalculate: false,
|
|
1882
1887
|
utmSource: '',
|
|
1883
1888
|
utmCampaign: '',
|
|
@@ -1926,6 +1931,7 @@ exports.StoreFormCarDiscountActionTypes = void 0;
|
|
|
1926
1931
|
StoreFormCarDiscountActionTypes["FormCarDiscountQuoterFirstNameSet"] = "FormCarDiscountQuoterFirstNameSet";
|
|
1927
1932
|
StoreFormCarDiscountActionTypes["FormCarDiscountQuoterLastNameSet"] = "FormCarDiscountQuoterLastNameSet";
|
|
1928
1933
|
StoreFormCarDiscountActionTypes["FormCarDiscountQuoterPhoneSet"] = "FormCarDiscountQuoterPhoneSet";
|
|
1934
|
+
StoreFormCarDiscountActionTypes["FormCarDiscountQuoterPhoneStatusSet"] = "FormCarDiscountQuoterPhoneStatusSet";
|
|
1929
1935
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkAdd"] = "FormCarDiscountVehlinkAdd";
|
|
1930
1936
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkSelect"] = "FormCarDiscountVehlinkSelect";
|
|
1931
1937
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkByVehicleDelete"] = "FormCarDiscountVehlinkByVehicleDelete";
|
|
@@ -2076,6 +2082,10 @@ const formCarDiscountStateReducer = (state = { ...formCarDiscountStateInitialSta
|
|
|
2076
2082
|
return setLocalDiscounts$1(action.localIndex, setDiscountQuoterProperty(state, 'lastName', action.payload.lastName));
|
|
2077
2083
|
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneSet:
|
|
2078
2084
|
return setLocalDiscounts$1(action.localIndex, setDiscountQuoterProperty(state, 'phone', action.payload.phone));
|
|
2085
|
+
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet: {
|
|
2086
|
+
const phoneState = setDiscountQuoterProperty(state, 'phone', action.payload.phone);
|
|
2087
|
+
return setLocalDiscounts$1(action.localIndex, setDiscountQuoterProperty(phoneState, 'phoneStatus', action.payload.phoneStatus));
|
|
2088
|
+
}
|
|
2079
2089
|
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterUtmSourceSet:
|
|
2080
2090
|
return setLocalDiscounts$1(action.localIndex, setDiscountQuoterProperty(state, 'utmSource', action.payload.utmSource));
|
|
2081
2091
|
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterUtmCampaignSet:
|
|
@@ -2890,6 +2900,7 @@ const formHomeDiscountStateInitialState = {
|
|
|
2890
2900
|
firstName: '',
|
|
2891
2901
|
lastName: '',
|
|
2892
2902
|
phone: '',
|
|
2903
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial,
|
|
2893
2904
|
recalculate: false,
|
|
2894
2905
|
utmCampaign: '',
|
|
2895
2906
|
utmSource: '',
|
|
@@ -2925,6 +2936,7 @@ exports.StoreFormHomeDiscountActionTypes = void 0;
|
|
|
2925
2936
|
StoreFormHomeDiscountActionTypes["FormHomeQuoterFirstNameSet"] = "FormHomeQuoterFirstNameSet";
|
|
2926
2937
|
StoreFormHomeDiscountActionTypes["FormHomeQuoterLastNameSet"] = "FormHomeQuoterLastNameSet";
|
|
2927
2938
|
StoreFormHomeDiscountActionTypes["FormHomeQuoterPhoneSet"] = "FormHomeQuoterPhoneSet";
|
|
2939
|
+
StoreFormHomeDiscountActionTypes["FormHomeQuoterPhoneStatusSet"] = "FormHomeQuoterPhoneStatusSet";
|
|
2928
2940
|
StoreFormHomeDiscountActionTypes["FormHomeUtmCampaignSet"] = "FormHomeUtmCampaignSet";
|
|
2929
2941
|
StoreFormHomeDiscountActionTypes["FormHomeUtmSourceSet"] = "FormHomeUtmSourceSet";
|
|
2930
2942
|
StoreFormHomeDiscountActionTypes["FormHomeUtmProducerSet"] = "FormHomeUtmProducerSet";
|
|
@@ -2985,6 +2997,11 @@ const formHomeDiscountStateReducer = (state = { ...formHomeDiscountStateInitialS
|
|
|
2985
2997
|
return setLocalDiscounts(action.localIndex, setStateProperty(state, 'lastName', action.payload.lastName, 'quoterInfo'));
|
|
2986
2998
|
case exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneSet:
|
|
2987
2999
|
return setLocalDiscounts(action.localIndex, setStateProperty(state, 'phone', action.payload.phone, 'quoterInfo'));
|
|
3000
|
+
case exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet:
|
|
3001
|
+
return setLocalDiscounts(action.localIndex, {
|
|
3002
|
+
...state,
|
|
3003
|
+
quoterInfo: { ...state.quoterInfo, ...{ phone: action.payload.phone, phoneStatus: action.payload.phoneStatus } },
|
|
3004
|
+
});
|
|
2988
3005
|
case exports.StoreFormHomeDiscountActionTypes.FormHomeUtmSourceSet:
|
|
2989
3006
|
return setLocalDiscounts(action.localIndex, setStateProperty(state, 'utmSource', action.payload.utmSource, 'quoterInfo'));
|
|
2990
3007
|
case exports.StoreFormHomeDiscountActionTypes.FormHomeUtmCampaignSet:
|
|
@@ -3141,6 +3158,7 @@ const lifeFormApplicantInitialState = {
|
|
|
3141
3158
|
firstName: '',
|
|
3142
3159
|
lastName: '',
|
|
3143
3160
|
phone: '',
|
|
3161
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial,
|
|
3144
3162
|
recalculate: false,
|
|
3145
3163
|
utmCampaign: '',
|
|
3146
3164
|
utmSource: '',
|
|
@@ -3176,6 +3194,7 @@ exports.StoreFormLifeApplicantActionTypes = void 0;
|
|
|
3176
3194
|
StoreFormLifeApplicantActionTypes["FormLifeQuoterFirstNameSet"] = "FormLifeQuoterFirstNameSet";
|
|
3177
3195
|
StoreFormLifeApplicantActionTypes["FormLifeQuoterLastNameSet"] = "FormLifeQuoterLastNameSet";
|
|
3178
3196
|
StoreFormLifeApplicantActionTypes["FormLifeQuoterPhoneSet"] = "FormLifeQuoterPhoneSet";
|
|
3197
|
+
StoreFormLifeApplicantActionTypes["FormLifeQuoterPhoneStatusSet"] = "FormLifeQuoterPhoneStatusSet";
|
|
3179
3198
|
StoreFormLifeApplicantActionTypes["FormLifeUtmCampaignSet"] = "FormLifeUtmCampaignSet";
|
|
3180
3199
|
StoreFormLifeApplicantActionTypes["FormLifeUtmSourceSet"] = "FormLifeUtmSourceSet";
|
|
3181
3200
|
StoreFormLifeApplicantActionTypes["FormLifeUtmProducerSet"] = "FormLifeUtmProducerSet";
|
|
@@ -3212,6 +3231,11 @@ const formLifeApplicantStateReducer = (state = { ...lifeFormApplicantInitialStat
|
|
|
3212
3231
|
return setLocalApplicant(action?.localIndex, setStateProperty(state, 'lastName', action.payload.lastName, 'quoterInfo'));
|
|
3213
3232
|
case exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneSet:
|
|
3214
3233
|
return setLocalApplicant(action?.localIndex, setStateProperty(state, 'phone', action.payload.phone, 'quoterInfo'));
|
|
3234
|
+
case exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet:
|
|
3235
|
+
return setLocalApplicant(action?.localIndex, {
|
|
3236
|
+
...state,
|
|
3237
|
+
quoterInfo: { ...state.quoterInfo, ...{ phone: action.payload.phone, phoneStatus: action.payload.phoneStatus } },
|
|
3238
|
+
});
|
|
3215
3239
|
case exports.StoreFormLifeApplicantActionTypes.FormLifeUtmSourceSet:
|
|
3216
3240
|
return setLocalApplicant(action?.localIndex, setStateProperty(state, 'utmSource', action.payload.utmSource, 'quoterInfo'));
|
|
3217
3241
|
case exports.StoreFormLifeApplicantActionTypes.FormLifeUtmCampaignSet:
|
|
@@ -5089,6 +5113,190 @@ const useHandlerLifeQuoterEmail = () => {
|
|
|
5089
5113
|
};
|
|
5090
5114
|
};
|
|
5091
5115
|
|
|
5116
|
+
const useHandlerCarQuoterPhone = () => {
|
|
5117
|
+
const [requestState, setRequestState] = react.useReducer(dataHandlerReducer, {
|
|
5118
|
+
...initialHandlerRequestState,
|
|
5119
|
+
});
|
|
5120
|
+
const { dispatchDiscountState } = useStoreFormCarDiscount();
|
|
5121
|
+
const { cancelToken } = useCancelToken();
|
|
5122
|
+
const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
|
|
5123
|
+
const validatePhone = async (phone) => {
|
|
5124
|
+
dispatchDiscountState({
|
|
5125
|
+
type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
|
|
5126
|
+
payload: {
|
|
5127
|
+
phone,
|
|
5128
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Loading,
|
|
5129
|
+
},
|
|
5130
|
+
});
|
|
5131
|
+
if (phone) {
|
|
5132
|
+
try {
|
|
5133
|
+
const response = await httpRequest({
|
|
5134
|
+
url: `${mychoiceSdkComponents.API_AUTH.GET_PHONE_VALIDATION}?phone=${encodeURIComponent(phone)}`,
|
|
5135
|
+
method: mychoiceSdkComponents.RequestTypes.Get,
|
|
5136
|
+
withoutToken: true,
|
|
5137
|
+
cancelToken,
|
|
5138
|
+
});
|
|
5139
|
+
if (response.data.valid) {
|
|
5140
|
+
dispatchDiscountState({
|
|
5141
|
+
type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
|
|
5142
|
+
payload: {
|
|
5143
|
+
phone,
|
|
5144
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved,
|
|
5145
|
+
},
|
|
5146
|
+
});
|
|
5147
|
+
}
|
|
5148
|
+
else {
|
|
5149
|
+
dispatchDiscountState({
|
|
5150
|
+
type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
|
|
5151
|
+
payload: {
|
|
5152
|
+
phone,
|
|
5153
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined,
|
|
5154
|
+
},
|
|
5155
|
+
});
|
|
5156
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
|
|
5157
|
+
}
|
|
5158
|
+
}
|
|
5159
|
+
catch (error) {
|
|
5160
|
+
dispatchDiscountState({
|
|
5161
|
+
type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
|
|
5162
|
+
payload: {
|
|
5163
|
+
phone,
|
|
5164
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined,
|
|
5165
|
+
},
|
|
5166
|
+
});
|
|
5167
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
else {
|
|
5171
|
+
dispatchDiscountState({
|
|
5172
|
+
type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
|
|
5173
|
+
payload: {
|
|
5174
|
+
phone,
|
|
5175
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined,
|
|
5176
|
+
},
|
|
5177
|
+
});
|
|
5178
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'This field may not be blank.' });
|
|
5179
|
+
}
|
|
5180
|
+
};
|
|
5181
|
+
return {
|
|
5182
|
+
status,
|
|
5183
|
+
validatePhone,
|
|
5184
|
+
successMessage,
|
|
5185
|
+
responseData,
|
|
5186
|
+
errorMessage,
|
|
5187
|
+
isFirstRequest,
|
|
5188
|
+
responseError,
|
|
5189
|
+
};
|
|
5190
|
+
};
|
|
5191
|
+
const useHandlerHomeQuoterPhone = () => {
|
|
5192
|
+
const [requestState, setRequestState] = react.useReducer(dataHandlerReducer, {
|
|
5193
|
+
...initialHandlerRequestState,
|
|
5194
|
+
});
|
|
5195
|
+
const { dispatchDiscountState } = useStoreFormHomeDiscount();
|
|
5196
|
+
const { cancelToken } = useCancelToken();
|
|
5197
|
+
const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
|
|
5198
|
+
const validatePhone = async (phone) => {
|
|
5199
|
+
dispatchDiscountState({
|
|
5200
|
+
type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
|
|
5201
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Loading },
|
|
5202
|
+
});
|
|
5203
|
+
if (phone) {
|
|
5204
|
+
try {
|
|
5205
|
+
const response = await httpRequest({
|
|
5206
|
+
url: `${mychoiceSdkComponents.API_AUTH.GET_PHONE_VALIDATION}?phone=${encodeURIComponent(phone)}`,
|
|
5207
|
+
method: mychoiceSdkComponents.RequestTypes.Get,
|
|
5208
|
+
withoutToken: true,
|
|
5209
|
+
cancelToken,
|
|
5210
|
+
});
|
|
5211
|
+
if (response.data.valid) {
|
|
5212
|
+
dispatchDiscountState({
|
|
5213
|
+
type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
|
|
5214
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved },
|
|
5215
|
+
});
|
|
5216
|
+
}
|
|
5217
|
+
else {
|
|
5218
|
+
dispatchDiscountState({
|
|
5219
|
+
type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
|
|
5220
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
|
|
5221
|
+
});
|
|
5222
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
catch (error) {
|
|
5226
|
+
dispatchDiscountState({
|
|
5227
|
+
type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
|
|
5228
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
|
|
5229
|
+
});
|
|
5230
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
else {
|
|
5234
|
+
dispatchDiscountState({
|
|
5235
|
+
type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
|
|
5236
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
|
|
5237
|
+
});
|
|
5238
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'This field may not be blank.' });
|
|
5239
|
+
}
|
|
5240
|
+
};
|
|
5241
|
+
return {
|
|
5242
|
+
status, validatePhone, successMessage, responseData, errorMessage, isFirstRequest, responseError,
|
|
5243
|
+
};
|
|
5244
|
+
};
|
|
5245
|
+
const useHandlerLifeQuoterPhone = () => {
|
|
5246
|
+
const [requestState, setRequestState] = react.useReducer(dataHandlerReducer, {
|
|
5247
|
+
...initialHandlerRequestState,
|
|
5248
|
+
});
|
|
5249
|
+
const { dispatchApplicantState } = useStoreFormLifeApplicant();
|
|
5250
|
+
const { cancelToken } = useCancelToken();
|
|
5251
|
+
const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
|
|
5252
|
+
const validatePhone = async (phone) => {
|
|
5253
|
+
dispatchApplicantState({
|
|
5254
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
|
|
5255
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Loading },
|
|
5256
|
+
});
|
|
5257
|
+
if (phone) {
|
|
5258
|
+
try {
|
|
5259
|
+
const response = await httpRequest({
|
|
5260
|
+
url: `${mychoiceSdkComponents.API_AUTH.GET_PHONE_VALIDATION}?phone=${encodeURIComponent(phone)}`,
|
|
5261
|
+
method: mychoiceSdkComponents.RequestTypes.Get,
|
|
5262
|
+
withoutToken: true,
|
|
5263
|
+
cancelToken,
|
|
5264
|
+
});
|
|
5265
|
+
if (response.data.valid) {
|
|
5266
|
+
dispatchApplicantState({
|
|
5267
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
|
|
5268
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved },
|
|
5269
|
+
});
|
|
5270
|
+
}
|
|
5271
|
+
else {
|
|
5272
|
+
dispatchApplicantState({
|
|
5273
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
|
|
5274
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
|
|
5275
|
+
});
|
|
5276
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
|
|
5277
|
+
}
|
|
5278
|
+
}
|
|
5279
|
+
catch (error) {
|
|
5280
|
+
dispatchApplicantState({
|
|
5281
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
|
|
5282
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
|
|
5283
|
+
});
|
|
5284
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
else {
|
|
5288
|
+
dispatchApplicantState({
|
|
5289
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
|
|
5290
|
+
payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
|
|
5291
|
+
});
|
|
5292
|
+
setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'This field may not be blank.' });
|
|
5293
|
+
}
|
|
5294
|
+
};
|
|
5295
|
+
return {
|
|
5296
|
+
status, validatePhone, successMessage, responseData, errorMessage, isFirstRequest, responseError,
|
|
5297
|
+
};
|
|
5298
|
+
};
|
|
5299
|
+
|
|
5092
5300
|
const CarQuoteDataHandler = () => {
|
|
5093
5301
|
const { configState } = useStoreFormCarConfig();
|
|
5094
5302
|
const { vehicleState } = useStoreFormCarVehicle();
|
|
@@ -5237,6 +5445,18 @@ const CarQuoteDataHandler = () => {
|
|
|
5237
5445
|
delete driver.insuredYear;
|
|
5238
5446
|
delete driver.insuredDate;
|
|
5239
5447
|
}
|
|
5448
|
+
// "Not currently insured": build the open-ended lapse incident.
|
|
5449
|
+
// IncidentDate uses the selected month/year with the day defaulted to the 1st (History 1-4).
|
|
5450
|
+
if (driver.notCurrentlyInsured && driver.lastPolicyEndYear && driver.lastPolicyEndMonth) {
|
|
5451
|
+
driver.lastPolicyEndDate = addDayToDate(`${driver.lastPolicyEndYear}-${driver.lastPolicyEndMonth}`, 1);
|
|
5452
|
+
}
|
|
5453
|
+
else {
|
|
5454
|
+
driver.notCurrentlyInsured = false;
|
|
5455
|
+
delete driver.lastPolicyEndDate;
|
|
5456
|
+
delete driver.lastPolicyCancelReason;
|
|
5457
|
+
}
|
|
5458
|
+
delete driver.lastPolicyEndYear;
|
|
5459
|
+
delete driver.lastPolicyEndMonth;
|
|
5240
5460
|
const defaultMinDate = driver.dateOfBirth && driver.licenceInfo.firstLicenceAge
|
|
5241
5461
|
? mychoiceSdkComponents.addYearsToDate(driver.dateOfBirth, +driver.licenceInfo.firstLicenceAge) : '';
|
|
5242
5462
|
const isOnlyG = mychoiceSdkComponents.compareDates(defaultMinDate, configState.minDates.g.specialDate) < 0;
|
|
@@ -5433,7 +5653,6 @@ const CarQuoteDataHandler = () => {
|
|
|
5433
5653
|
driver.ticketList = driver.ticketList?.map((listItem) => ({
|
|
5434
5654
|
reason: listItem.ticketReason,
|
|
5435
5655
|
ticketDate: addDayToDate(`${listItem.ticketYear}-${listItem.ticketMonth}`, +birthDay + 1),
|
|
5436
|
-
...(listItem.speed !== undefined ? { speed: listItem.speed } : {}),
|
|
5437
5656
|
}));
|
|
5438
5657
|
}
|
|
5439
5658
|
return driver;
|
|
@@ -5465,7 +5684,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5465
5684
|
}
|
|
5466
5685
|
else {
|
|
5467
5686
|
// g-k) Use user-selected vehicle for extra drivers; skip if they are primary on another vehicle
|
|
5468
|
-
const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex && l.vehicleIndex !== vehicleIndex);
|
|
5687
|
+
const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex + 1 && l.vehicleIndex !== vehicleIndex);
|
|
5469
5688
|
if (isPrimaryElsewhere)
|
|
5470
5689
|
continue;
|
|
5471
5690
|
const occAssignment = discount.occVehlinks?.find((l) => l.driverIndex === driverIndex);
|
|
@@ -5493,7 +5712,12 @@ const CarQuoteDataHandler = () => {
|
|
|
5493
5712
|
delete vehicle.purchaseYear;
|
|
5494
5713
|
delete vehicle.purchaseMonth;
|
|
5495
5714
|
delete vehicle.purchaseDay;
|
|
5496
|
-
if (vehicle.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal
|
|
5715
|
+
if (vehicle.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal) {
|
|
5716
|
+
delete vehicle.distanceBusiness;
|
|
5717
|
+
delete vehicle.businessUsePercent;
|
|
5718
|
+
}
|
|
5719
|
+
else if (vehicle.businessUsePercent) {
|
|
5720
|
+
// Send business_use_percent to the API; backend computes distance_business
|
|
5497
5721
|
delete vehicle.distanceBusiness;
|
|
5498
5722
|
}
|
|
5499
5723
|
if (!vehicle.collision.coverage) {
|
|
@@ -6117,6 +6341,7 @@ const useValidationVehicle = () => {
|
|
|
6117
6341
|
'distanceDaily',
|
|
6118
6342
|
'distanceBusiness',
|
|
6119
6343
|
'distanceYearly',
|
|
6344
|
+
'businessUsePercent',
|
|
6120
6345
|
'purchaseYear',
|
|
6121
6346
|
'purchaseMonth',
|
|
6122
6347
|
];
|
|
@@ -6127,8 +6352,10 @@ const useValidationVehicle = () => {
|
|
|
6127
6352
|
});
|
|
6128
6353
|
vehicleState.items.forEach((item) => {
|
|
6129
6354
|
Object.keys(item).map((key) => {
|
|
6130
|
-
|
|
6131
|
-
|
|
6355
|
+
const isEmpty = key === 'distanceDaily' ? item[key] === undefined || item[key] === null : !item[key];
|
|
6356
|
+
if (checkableKeys.includes(key) && isEmpty) {
|
|
6357
|
+
if (!(key === 'distanceBusiness' && (item.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal || item.businessUsePercent))
|
|
6358
|
+
&& !(key === 'businessUsePercent' && item.primaryUse !== mychoiceSdkComponents.VehiclePrimaryUseTypes.Business)) {
|
|
6132
6359
|
errors.push(key);
|
|
6133
6360
|
}
|
|
6134
6361
|
}
|
|
@@ -6187,6 +6414,7 @@ const useValidationDriver = () => {
|
|
|
6187
6414
|
const { discountState } = useStoreFormCarDiscount();
|
|
6188
6415
|
const { inValidation: driverFormIsInValidation = false, isValid: driverFormIsValid = false, } = driverState;
|
|
6189
6416
|
const { appConfigState } = useStoreAppConfig();
|
|
6417
|
+
const { appType } = appConfigState;
|
|
6190
6418
|
const { dispatchAppModalState } = useStoreAppModal();
|
|
6191
6419
|
const navigate = reactRouterDom.useNavigate();
|
|
6192
6420
|
const driverFormValidate = (isRedirect = true) => {
|
|
@@ -6201,6 +6429,9 @@ const useValidationDriver = () => {
|
|
|
6201
6429
|
'listedYear',
|
|
6202
6430
|
'listedMonth',
|
|
6203
6431
|
'insuredDate',
|
|
6432
|
+
'lastPolicyEndYear',
|
|
6433
|
+
'lastPolicyEndMonth',
|
|
6434
|
+
'lastPolicyCancelReason',
|
|
6204
6435
|
// 'insuredYear',
|
|
6205
6436
|
// 'insuredMonth',
|
|
6206
6437
|
];
|
|
@@ -6233,30 +6464,32 @@ const useValidationDriver = () => {
|
|
|
6233
6464
|
type: exports.StoreFormCarDriverBaseActionTypes.FormCarDriverValidate,
|
|
6234
6465
|
payload: { inValidation: true },
|
|
6235
6466
|
});
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
errors
|
|
6467
|
+
const showPolicyStart = appType !== mychoiceSdkComponents.AppTypes.TheBig && !mychoiceSdkComponents.isMyChoiceLike(appType);
|
|
6468
|
+
if (showPolicyStart) {
|
|
6469
|
+
Object.keys(discountState).forEach((key) => {
|
|
6470
|
+
// checking errors in discountState
|
|
6471
|
+
if (discountKeys.includes(key) && !discountState[key]) {
|
|
6472
|
+
errors.push(key);
|
|
6473
|
+
}
|
|
6474
|
+
});
|
|
6475
|
+
const { policyStartYear = 0, policyStartMonth = 0, policyStartDay = 0 } = discountState;
|
|
6476
|
+
const policyDate = `${policyStartYear}-${policyStartMonth}-${policyStartDay}`;
|
|
6477
|
+
const currentDate = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
6478
|
+
if (mychoiceSdkComponents.compareDates(currentDate, policyDate) >= 0) {
|
|
6479
|
+
errors.push('policyStartYear');
|
|
6480
|
+
errors.push('policyStartMonth');
|
|
6481
|
+
errors.push('policyStartDay');
|
|
6240
6482
|
}
|
|
6241
|
-
});
|
|
6242
|
-
const { policyStartYear = 0, policyStartMonth = 0, policyStartDay = 0 } = discountState;
|
|
6243
|
-
const policyDate = `${policyStartYear}-${policyStartMonth}-${policyStartDay}`;
|
|
6244
|
-
// const currentDay = new Date().getUTCDate();
|
|
6245
|
-
// const currentMonth = new Date().getUTCMonth();
|
|
6246
|
-
// const currentYear = new Date().getUTCFullYear();
|
|
6247
|
-
const currentDate = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
6248
|
-
if (mychoiceSdkComponents.compareDates(currentDate, policyDate) >= 0) {
|
|
6249
|
-
errors.push('policyStartYear');
|
|
6250
|
-
errors.push('policyStartMonth');
|
|
6251
|
-
errors.push('policyStartDay');
|
|
6252
6483
|
}
|
|
6253
6484
|
driverState.items.forEach((item, index) => {
|
|
6254
6485
|
Object.keys(item).forEach((key) => {
|
|
6255
6486
|
// checking errors in driverState
|
|
6256
6487
|
if (keys.includes(key) && !item[key]) {
|
|
6257
6488
|
if ((!item.listed
|
|
6258
|
-
&& (key === 'listedYear' || key === 'listedMonth' || key === 'insuredDate'
|
|
6489
|
+
&& (key === 'listedYear' || key === 'listedMonth' || key === 'insuredDate'
|
|
6490
|
+
|| key === 'lastPolicyEndYear' || key === 'lastPolicyEndMonth' || key === 'lastPolicyCancelReason'))
|
|
6259
6491
|
|| (!item.insured && item.listed && (key === 'insuredDate'))
|
|
6492
|
+
|| (item.insured && (key === 'lastPolicyEndYear' || key === 'lastPolicyEndMonth' || key === 'lastPolicyCancelReason'))
|
|
6260
6493
|
|| (index === 0 && key === 'applicantRelationship')) {
|
|
6261
6494
|
return;
|
|
6262
6495
|
}
|
|
@@ -6344,6 +6577,7 @@ const useValidationCarDiscount = () => {
|
|
|
6344
6577
|
'phone',
|
|
6345
6578
|
'email',
|
|
6346
6579
|
'emailStatus',
|
|
6580
|
+
'phoneStatus',
|
|
6347
6581
|
];
|
|
6348
6582
|
const errors = [];
|
|
6349
6583
|
dispatchDiscountState({
|
|
@@ -6357,11 +6591,14 @@ const useValidationCarDiscount = () => {
|
|
|
6357
6591
|
errors.push(objectKey);
|
|
6358
6592
|
}
|
|
6359
6593
|
});
|
|
6360
|
-
if (discountState.emailTo.emailStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
|
|
6361
|
-
errors.push('email');
|
|
6362
|
-
}
|
|
6363
6594
|
}
|
|
6364
6595
|
});
|
|
6596
|
+
if (discountState.emailTo.emailStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
|
|
6597
|
+
errors.push('email');
|
|
6598
|
+
}
|
|
6599
|
+
if (discountState.quoterInfo.phoneStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
|
|
6600
|
+
errors.push('phone');
|
|
6601
|
+
}
|
|
6365
6602
|
if (!errors.length) {
|
|
6366
6603
|
dispatchDiscountState({
|
|
6367
6604
|
type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountValidate,
|
|
@@ -6762,7 +6999,6 @@ const useValidationHomeDiscount = () => {
|
|
|
6762
6999
|
const discountKeys = [
|
|
6763
7000
|
'firstName',
|
|
6764
7001
|
'lastName',
|
|
6765
|
-
'phone',
|
|
6766
7002
|
];
|
|
6767
7003
|
const errors = [];
|
|
6768
7004
|
dispatchDiscountState({
|
|
@@ -6785,6 +7021,9 @@ const useValidationHomeDiscount = () => {
|
|
|
6785
7021
|
if (discountState.emailTo.emailStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
|
|
6786
7022
|
errors.push('email');
|
|
6787
7023
|
}
|
|
7024
|
+
if (quoterInfo?.phoneStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
|
|
7025
|
+
errors.push('phone');
|
|
7026
|
+
}
|
|
6788
7027
|
if (!errors.length) {
|
|
6789
7028
|
dispatchDiscountState({
|
|
6790
7029
|
type: exports.StoreFormHomeDiscountActionTypes.FormHomeDiscountValidate,
|
|
@@ -6902,7 +7141,6 @@ const useValidationLifeApplicant = () => {
|
|
|
6902
7141
|
const quoterInfoKeys = [
|
|
6903
7142
|
'firstName',
|
|
6904
7143
|
'lastName',
|
|
6905
|
-
'phone',
|
|
6906
7144
|
];
|
|
6907
7145
|
const errors = [];
|
|
6908
7146
|
dispatchApplicantState({
|
|
@@ -6917,6 +7155,9 @@ const useValidationLifeApplicant = () => {
|
|
|
6917
7155
|
if (applicantState.emailTo.emailStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
|
|
6918
7156
|
errors.push('email');
|
|
6919
7157
|
}
|
|
7158
|
+
if (quoterInfo?.phoneStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
|
|
7159
|
+
errors.push('phone');
|
|
7160
|
+
}
|
|
6920
7161
|
if (quoterInfo) {
|
|
6921
7162
|
Object.keys(quoterInfo).forEach((key) => {
|
|
6922
7163
|
if (quoterInfoKeys.includes(key) && !quoterInfo?.[key]) {
|
|
@@ -7661,12 +7902,13 @@ const useAutofillLifeForm = (options) => {
|
|
|
7661
7902
|
},
|
|
7662
7903
|
});
|
|
7663
7904
|
}
|
|
7664
|
-
// Dispatch quoter info - phone
|
|
7905
|
+
// Dispatch quoter info - phone (pre-approved since it comes from a trusted autofill source)
|
|
7665
7906
|
if (applicantData.quoterInfo.phone) {
|
|
7666
7907
|
dispatchApplicantState({
|
|
7667
|
-
type: exports.StoreFormLifeApplicantActionTypes.
|
|
7908
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
|
|
7668
7909
|
payload: {
|
|
7669
7910
|
phone: applicantData.quoterInfo.phone,
|
|
7911
|
+
phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved,
|
|
7670
7912
|
},
|
|
7671
7913
|
});
|
|
7672
7914
|
}
|
|
@@ -7737,8 +7979,11 @@ exports.useHandlerAuth = useHandlerAuth;
|
|
|
7737
7979
|
exports.useHandlerCarMake = useHandlerCarMake;
|
|
7738
7980
|
exports.useHandlerCarModel = useHandlerCarModel;
|
|
7739
7981
|
exports.useHandlerCarQuoterEmail = useHandlerCarQuoterEmail;
|
|
7982
|
+
exports.useHandlerCarQuoterPhone = useHandlerCarQuoterPhone;
|
|
7740
7983
|
exports.useHandlerHomeQuoterEmail = useHandlerHomeQuoterEmail;
|
|
7984
|
+
exports.useHandlerHomeQuoterPhone = useHandlerHomeQuoterPhone;
|
|
7741
7985
|
exports.useHandlerLifeQuoterEmail = useHandlerLifeQuoterEmail;
|
|
7986
|
+
exports.useHandlerLifeQuoterPhone = useHandlerLifeQuoterPhone;
|
|
7742
7987
|
exports.useHandlerPartner = useHandlerPartner;
|
|
7743
7988
|
exports.useHandlerPostal = useHandlerPostal;
|
|
7744
7989
|
exports.useProvince = useProvince;
|