@mychoice/mychoice-sdk-store 2.2.26 → 2.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +385 -292
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/helper.d.ts +1 -1
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/interfaces.d.ts +4 -4
- package/dist/esm/index.js +385 -292
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/helper.d.ts +1 -1
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/interfaces.d.ts +4 -4
- package/dist/index.d.ts +4 -4
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -910,6 +910,8 @@ const driverItemInitialState = {
|
|
|
910
910
|
gLicenceMonth: '',
|
|
911
911
|
passedDriverTraining: false,
|
|
912
912
|
previousLicence: false,
|
|
913
|
+
receivedG2: false,
|
|
914
|
+
receivedG: false,
|
|
913
915
|
},
|
|
914
916
|
minMaxDates: {
|
|
915
917
|
...driverItemMinMaxDates,
|
|
@@ -952,13 +954,267 @@ const carFormDriverInitialState = {
|
|
|
952
954
|
const localStateName$c = 'car_drivers';
|
|
953
955
|
const getLocalDrivers = (localIndex = '') => {
|
|
954
956
|
const localDrivers = localStorage.getItem(`${localIndex}_${localStateName$c}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$c}`) || '') : null;
|
|
955
|
-
|
|
957
|
+
const state = localDrivers || { ...carFormDriverInitialState };
|
|
958
|
+
// Coerce legacy null Yes/No licence flags back to default No
|
|
959
|
+
state.items?.forEach((item) => {
|
|
960
|
+
const info = item.licenceInfo;
|
|
961
|
+
if (!info)
|
|
962
|
+
return;
|
|
963
|
+
['passedDriverTraining', 'previousLicence', 'receivedG2', 'receivedG'].forEach((key) => {
|
|
964
|
+
if (info[key] == null)
|
|
965
|
+
info[key] = false;
|
|
966
|
+
});
|
|
967
|
+
});
|
|
968
|
+
return state;
|
|
956
969
|
};
|
|
957
970
|
const setLocalDrivers = (localIndex, state) => {
|
|
958
971
|
localStorage.setItem(`${localIndex || mychoiceSdkComponents.defaultLocalIndex}_${localStateName$c}`, JSON.stringify(state));
|
|
959
972
|
return state;
|
|
960
973
|
};
|
|
961
974
|
|
|
975
|
+
const OntarioCode = 'ON';
|
|
976
|
+
const AlbertaCode = 'AB';
|
|
977
|
+
const NovaScotiaCode = 'NS';
|
|
978
|
+
const NewfoundlandCode = 'NF';
|
|
979
|
+
const NewBrunswickCode = 'NB';
|
|
980
|
+
const provinceList = [
|
|
981
|
+
{
|
|
982
|
+
name: 'Ontario',
|
|
983
|
+
code: OntarioCode,
|
|
984
|
+
toolTip: {
|
|
985
|
+
// eslint-disable-next-line max-len
|
|
986
|
+
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.',
|
|
987
|
+
// eslint-disable-next-line max-len
|
|
988
|
+
licenceType: 'The primary driver should disclose their type of driver’s licence on the policy. If you received your licence in Canada before 1994, it should have a ‘G’ classification.',
|
|
989
|
+
},
|
|
990
|
+
licenceConfig: {
|
|
991
|
+
minLicenceAge: 16,
|
|
992
|
+
title: '',
|
|
993
|
+
g1: {
|
|
994
|
+
title: 'G1',
|
|
995
|
+
name: 'g1',
|
|
996
|
+
id: 'G1',
|
|
997
|
+
description: '',
|
|
998
|
+
},
|
|
999
|
+
g2: {
|
|
1000
|
+
title: 'G2',
|
|
1001
|
+
name: 'g2',
|
|
1002
|
+
id: 'G2',
|
|
1003
|
+
description: '',
|
|
1004
|
+
},
|
|
1005
|
+
g: {
|
|
1006
|
+
title: 'G',
|
|
1007
|
+
name: 'g',
|
|
1008
|
+
id: 'G',
|
|
1009
|
+
description: '',
|
|
1010
|
+
},
|
|
1011
|
+
},
|
|
1012
|
+
minDates: {
|
|
1013
|
+
g1: {
|
|
1014
|
+
minMonth: 0,
|
|
1015
|
+
defaultMonth: 0, // month plus g one min
|
|
1016
|
+
},
|
|
1017
|
+
g2: {
|
|
1018
|
+
minMonth: 8,
|
|
1019
|
+
defaultMonth: 4, // month plus g2 min
|
|
1020
|
+
},
|
|
1021
|
+
g: {
|
|
1022
|
+
minMonth: 12,
|
|
1023
|
+
defaultMonth: 0,
|
|
1024
|
+
specialDate: '1994-04-01', // special g date, before it you can choose only g licence
|
|
1025
|
+
},
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
name: 'Alberta',
|
|
1030
|
+
code: AlbertaCode,
|
|
1031
|
+
toolTip: {
|
|
1032
|
+
// eslint-disable-next-line max-len
|
|
1033
|
+
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.',
|
|
1034
|
+
// eslint-disable-next-line max-len
|
|
1035
|
+
licenceType: 'A Class 7 licence is a learner’s licence that let’s you drive under the supervision of a licenced driver. A Class 5-GDL licence is a probationary licence that let’s you drive with limited restrictions. This licence is obtained after having a Class 7 licence for 1 year or more. A Class 5 licence is a full licence obtained after holding a Class 5-GDL licence for 2 years and allows you to drive with almost no restrictions. If you have you have driving experience from another country, please select your present Alberta driver’s licence.',
|
|
1036
|
+
},
|
|
1037
|
+
licenceConfig: {
|
|
1038
|
+
title: '',
|
|
1039
|
+
minLicenceAge: 14,
|
|
1040
|
+
g1: {
|
|
1041
|
+
title: 'Class 7',
|
|
1042
|
+
name: 'g1',
|
|
1043
|
+
id: 'G1',
|
|
1044
|
+
description: '',
|
|
1045
|
+
},
|
|
1046
|
+
g2: {
|
|
1047
|
+
title: 'Class 5-GDL',
|
|
1048
|
+
name: 'g2',
|
|
1049
|
+
id: 'G2',
|
|
1050
|
+
description: '',
|
|
1051
|
+
},
|
|
1052
|
+
g: {
|
|
1053
|
+
title: 'Class 5',
|
|
1054
|
+
name: 'g',
|
|
1055
|
+
id: 'G',
|
|
1056
|
+
description: '',
|
|
1057
|
+
},
|
|
1058
|
+
},
|
|
1059
|
+
minDates: {
|
|
1060
|
+
g1: {
|
|
1061
|
+
minMonth: 0,
|
|
1062
|
+
defaultMonth: 0,
|
|
1063
|
+
},
|
|
1064
|
+
g2: {
|
|
1065
|
+
minMonth: 12,
|
|
1066
|
+
defaultMonth: 0,
|
|
1067
|
+
},
|
|
1068
|
+
g: {
|
|
1069
|
+
minMonth: 24,
|
|
1070
|
+
defaultMonth: 0,
|
|
1071
|
+
specialDate: '2004-01-01',
|
|
1072
|
+
},
|
|
1073
|
+
},
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
name: 'Nova Scotia',
|
|
1077
|
+
code: NovaScotiaCode,
|
|
1078
|
+
toolTip: {
|
|
1079
|
+
// eslint-disable-next-line max-len
|
|
1080
|
+
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.',
|
|
1081
|
+
// eslint-disable-next-line max-len
|
|
1082
|
+
licenceType: 'A Class 7 licence is the learner\'s licence you obtain after passing the written test and it allows you to drive with supervision from a licenced driver. A Class 5N licence is a probationary licence obtained after holding a Class 7 licence for at least 1 year (or 9 months with the completion of a driver\'s education course) and after you pass an advanced test on the road. Here you can drive with limited restrictions. A Class 5 licence is a full driving licence obtained after holding a Class 5N licence for 2 years. If you have driving experience from another country, please select your present Nova Scotia driver’s licence.',
|
|
1083
|
+
},
|
|
1084
|
+
licenceConfig: {
|
|
1085
|
+
title: '',
|
|
1086
|
+
minLicenceAge: 16,
|
|
1087
|
+
g1: {
|
|
1088
|
+
title: 'Class 7',
|
|
1089
|
+
name: 'g1',
|
|
1090
|
+
id: 'G1',
|
|
1091
|
+
description: '',
|
|
1092
|
+
},
|
|
1093
|
+
g2: {
|
|
1094
|
+
title: 'Class 5N',
|
|
1095
|
+
name: 'g2',
|
|
1096
|
+
id: 'G2',
|
|
1097
|
+
description: '',
|
|
1098
|
+
},
|
|
1099
|
+
g: {
|
|
1100
|
+
title: 'Class 5',
|
|
1101
|
+
name: 'g',
|
|
1102
|
+
id: 'G',
|
|
1103
|
+
description: '',
|
|
1104
|
+
},
|
|
1105
|
+
},
|
|
1106
|
+
minDates: {
|
|
1107
|
+
g1: {
|
|
1108
|
+
minMonth: 0,
|
|
1109
|
+
defaultMonth: 0,
|
|
1110
|
+
},
|
|
1111
|
+
g2: {
|
|
1112
|
+
minMonth: 9,
|
|
1113
|
+
defaultMonth: 3,
|
|
1114
|
+
},
|
|
1115
|
+
g: {
|
|
1116
|
+
minMonth: 24,
|
|
1117
|
+
defaultMonth: 0,
|
|
1118
|
+
specialDate: '1995-01-01',
|
|
1119
|
+
},
|
|
1120
|
+
},
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
name: 'Newfoundland',
|
|
1124
|
+
code: NewfoundlandCode,
|
|
1125
|
+
toolTip: {
|
|
1126
|
+
// eslint-disable-next-line max-len
|
|
1127
|
+
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.',
|
|
1128
|
+
// eslint-disable-next-line max-len
|
|
1129
|
+
licenceType: 'A Class 5-Level 1 licence is a learner\'s licence obtained after passing a written test and allows you to drive under supervision. A Class 5-Level 2 licence is a probationary licence obtained after holding a Class 5-Level 1 licence for 1 year (or 8 months with the completion of a driver\'s education course) and passing an advanced test on the road. This allows you to drive with some restrictions. A Class 5 licence is a full licence obtained after holding a Class 5-Level 2 licence for 1 year and passing the final test on the road. If you have driving experience from another country, please select your current Newfoundland and Labrador driver’s licence.',
|
|
1130
|
+
},
|
|
1131
|
+
licenceConfig: {
|
|
1132
|
+
title: '',
|
|
1133
|
+
minLicenceAge: 16,
|
|
1134
|
+
g1: {
|
|
1135
|
+
title: 'Class 5-Level 1',
|
|
1136
|
+
name: 'g1',
|
|
1137
|
+
id: 'G1',
|
|
1138
|
+
description: '',
|
|
1139
|
+
},
|
|
1140
|
+
g2: {
|
|
1141
|
+
title: 'Class 5-Level 2',
|
|
1142
|
+
name: 'g2',
|
|
1143
|
+
id: 'G2',
|
|
1144
|
+
description: '',
|
|
1145
|
+
},
|
|
1146
|
+
g: {
|
|
1147
|
+
title: 'Class 5',
|
|
1148
|
+
name: 'g',
|
|
1149
|
+
id: 'G',
|
|
1150
|
+
description: '',
|
|
1151
|
+
},
|
|
1152
|
+
},
|
|
1153
|
+
minDates: {
|
|
1154
|
+
g1: {
|
|
1155
|
+
minMonth: 0,
|
|
1156
|
+
defaultMonth: 0,
|
|
1157
|
+
},
|
|
1158
|
+
g2: {
|
|
1159
|
+
minMonth: 8,
|
|
1160
|
+
defaultMonth: 4,
|
|
1161
|
+
},
|
|
1162
|
+
g: {
|
|
1163
|
+
minMonth: 12,
|
|
1164
|
+
defaultMonth: 0,
|
|
1165
|
+
specialDate: '1999-01-01',
|
|
1166
|
+
},
|
|
1167
|
+
},
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
name: 'New Brunswick',
|
|
1171
|
+
code: NewBrunswickCode,
|
|
1172
|
+
toolTip: {
|
|
1173
|
+
// eslint-disable-next-line max-len
|
|
1174
|
+
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.',
|
|
1175
|
+
// eslint-disable-next-line max-len
|
|
1176
|
+
licenceType: 'A Class 7-Level 1 licence is a learner\'s licence obtained after passing a written test. A Class 7-Level 2 licence is a probationary licence obtained after holding a Class 7-Level 1 licence for 12 months (or 8 months with the completion of a driver\'s education course) and passing an advanced road test. A Class 5 licence is a full licence obtained after holding a Class 7-Level 2 licence for 12 months and passing the final road test. If you do not currently hold any of the licences listed above, but have a licence for another vehicle class, province, or the U.S., please select "Other',
|
|
1177
|
+
},
|
|
1178
|
+
licenceConfig: {
|
|
1179
|
+
title: '',
|
|
1180
|
+
minLicenceAge: 16,
|
|
1181
|
+
g1: {
|
|
1182
|
+
title: 'Class 7 - Level 1',
|
|
1183
|
+
name: 'g1',
|
|
1184
|
+
id: 'G1',
|
|
1185
|
+
description: '',
|
|
1186
|
+
},
|
|
1187
|
+
g2: {
|
|
1188
|
+
title: 'Class 7 - Level 2',
|
|
1189
|
+
name: 'g2',
|
|
1190
|
+
id: 'G2',
|
|
1191
|
+
description: '',
|
|
1192
|
+
},
|
|
1193
|
+
g: {
|
|
1194
|
+
title: 'Class 5',
|
|
1195
|
+
name: 'g',
|
|
1196
|
+
id: 'G',
|
|
1197
|
+
description: '',
|
|
1198
|
+
},
|
|
1199
|
+
},
|
|
1200
|
+
minDates: {
|
|
1201
|
+
g1: {
|
|
1202
|
+
minMonth: 0,
|
|
1203
|
+
defaultMonth: 0,
|
|
1204
|
+
},
|
|
1205
|
+
g2: {
|
|
1206
|
+
minMonth: 8,
|
|
1207
|
+
defaultMonth: 4,
|
|
1208
|
+
},
|
|
1209
|
+
g: {
|
|
1210
|
+
minMonth: 12,
|
|
1211
|
+
defaultMonth: 0,
|
|
1212
|
+
specialDate: '1995-01-01',
|
|
1213
|
+
},
|
|
1214
|
+
},
|
|
1215
|
+
},
|
|
1216
|
+
];
|
|
1217
|
+
|
|
962
1218
|
const setDriverProperty = (state, name, value) => {
|
|
963
1219
|
const newState = mychoiceSdkComponents.deepClone(state);
|
|
964
1220
|
if (name !== 'isValid' && name !== 'inValidation') {
|
|
@@ -1122,11 +1378,17 @@ const setDriverLicenceType = (state, payload) => {
|
|
|
1122
1378
|
const newState = mychoiceSdkComponents.deepClone(state);
|
|
1123
1379
|
newState.isValid = false;
|
|
1124
1380
|
newState.items[newState.activeIndex].licenceInfo.licenceType = payload.licenceType;
|
|
1381
|
+
// Reset follow-up Yes/No to default No when the first licence class changes
|
|
1382
|
+
newState.items[newState.activeIndex].licenceInfo.receivedG2 = false;
|
|
1383
|
+
newState.items[newState.activeIndex].licenceInfo.receivedG = false;
|
|
1125
1384
|
const { minMaxDates } = newState.items[newState.activeIndex];
|
|
1126
1385
|
const currentDate = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
1127
1386
|
if (payload.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G2 && minMaxDates) {
|
|
1128
1387
|
minMaxDates.gTwoMax = currentDate;
|
|
1129
1388
|
}
|
|
1389
|
+
if (payload.config.code === OntarioCode) {
|
|
1390
|
+
return newState;
|
|
1391
|
+
}
|
|
1130
1392
|
const { licenceType, firstLicenceAge } = newState.items[state.activeIndex].licenceInfo;
|
|
1131
1393
|
const { birthYear, birthMonth, birthDay } = newState.items[state.activeIndex];
|
|
1132
1394
|
const dateOfBirth = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
|
|
@@ -1611,249 +1873,6 @@ exports.StoreFormCarConfigActionTypes = void 0;
|
|
|
1611
1873
|
StoreFormCarConfigActionTypes["FormCarConfigClear"] = "FormCarConfigClear";
|
|
1612
1874
|
})(exports.StoreFormCarConfigActionTypes || (exports.StoreFormCarConfigActionTypes = {}));
|
|
1613
1875
|
|
|
1614
|
-
const OntarioCode = 'ON';
|
|
1615
|
-
const AlbertaCode = 'AB';
|
|
1616
|
-
const NovaScotiaCode = 'NS';
|
|
1617
|
-
const NewfoundlandCode = 'NF';
|
|
1618
|
-
const NewBrunswickCode = 'NB';
|
|
1619
|
-
const provinceList = [
|
|
1620
|
-
{
|
|
1621
|
-
name: 'Ontario',
|
|
1622
|
-
code: OntarioCode,
|
|
1623
|
-
toolTip: {
|
|
1624
|
-
// eslint-disable-next-line max-len
|
|
1625
|
-
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.',
|
|
1626
|
-
// eslint-disable-next-line max-len
|
|
1627
|
-
licenceType: 'The primary driver should disclose their type of driver’s licence on the policy. If you received your licence in Canada before 1994, it should have a ‘G’ classification.',
|
|
1628
|
-
},
|
|
1629
|
-
licenceConfig: {
|
|
1630
|
-
minLicenceAge: 16,
|
|
1631
|
-
title: '',
|
|
1632
|
-
g1: {
|
|
1633
|
-
title: 'G1',
|
|
1634
|
-
name: 'g1',
|
|
1635
|
-
id: 'G1',
|
|
1636
|
-
description: '',
|
|
1637
|
-
},
|
|
1638
|
-
g2: {
|
|
1639
|
-
title: 'G2',
|
|
1640
|
-
name: 'g2',
|
|
1641
|
-
id: 'G2',
|
|
1642
|
-
description: '',
|
|
1643
|
-
},
|
|
1644
|
-
g: {
|
|
1645
|
-
title: 'G',
|
|
1646
|
-
name: 'g',
|
|
1647
|
-
id: 'G',
|
|
1648
|
-
description: '',
|
|
1649
|
-
},
|
|
1650
|
-
},
|
|
1651
|
-
minDates: {
|
|
1652
|
-
g1: {
|
|
1653
|
-
minMonth: 0,
|
|
1654
|
-
defaultMonth: 0, // month plus g one min
|
|
1655
|
-
},
|
|
1656
|
-
g2: {
|
|
1657
|
-
minMonth: 8,
|
|
1658
|
-
defaultMonth: 4, // month plus g2 min
|
|
1659
|
-
},
|
|
1660
|
-
g: {
|
|
1661
|
-
minMonth: 12,
|
|
1662
|
-
defaultMonth: 0,
|
|
1663
|
-
specialDate: '1994-04-01', // special g date, before it you can choose only g licence
|
|
1664
|
-
},
|
|
1665
|
-
},
|
|
1666
|
-
},
|
|
1667
|
-
{
|
|
1668
|
-
name: 'Alberta',
|
|
1669
|
-
code: AlbertaCode,
|
|
1670
|
-
toolTip: {
|
|
1671
|
-
// eslint-disable-next-line max-len
|
|
1672
|
-
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.',
|
|
1673
|
-
// eslint-disable-next-line max-len
|
|
1674
|
-
licenceType: 'A Class 7 licence is a learner’s licence that let’s you drive under the supervision of a licenced driver. A Class 5-GDL licence is a probationary licence that let’s you drive with limited restrictions. This licence is obtained after having a Class 7 licence for 1 year or more. A Class 5 licence is a full licence obtained after holding a Class 5-GDL licence for 2 years and allows you to drive with almost no restrictions. If you have you have driving experience from another country, please select your present Alberta driver’s licence.',
|
|
1675
|
-
},
|
|
1676
|
-
licenceConfig: {
|
|
1677
|
-
title: '',
|
|
1678
|
-
minLicenceAge: 14,
|
|
1679
|
-
g1: {
|
|
1680
|
-
title: 'Class 7',
|
|
1681
|
-
name: 'g1',
|
|
1682
|
-
id: 'G1',
|
|
1683
|
-
description: '',
|
|
1684
|
-
},
|
|
1685
|
-
g2: {
|
|
1686
|
-
title: 'Class 5-GDL',
|
|
1687
|
-
name: 'g2',
|
|
1688
|
-
id: 'G2',
|
|
1689
|
-
description: '',
|
|
1690
|
-
},
|
|
1691
|
-
g: {
|
|
1692
|
-
title: 'Class 5',
|
|
1693
|
-
name: 'g',
|
|
1694
|
-
id: 'G',
|
|
1695
|
-
description: '',
|
|
1696
|
-
},
|
|
1697
|
-
},
|
|
1698
|
-
minDates: {
|
|
1699
|
-
g1: {
|
|
1700
|
-
minMonth: 0,
|
|
1701
|
-
defaultMonth: 0,
|
|
1702
|
-
},
|
|
1703
|
-
g2: {
|
|
1704
|
-
minMonth: 12,
|
|
1705
|
-
defaultMonth: 0,
|
|
1706
|
-
},
|
|
1707
|
-
g: {
|
|
1708
|
-
minMonth: 24,
|
|
1709
|
-
defaultMonth: 0,
|
|
1710
|
-
specialDate: '2004-01-01',
|
|
1711
|
-
},
|
|
1712
|
-
},
|
|
1713
|
-
},
|
|
1714
|
-
{
|
|
1715
|
-
name: 'Nova Scotia',
|
|
1716
|
-
code: NovaScotiaCode,
|
|
1717
|
-
toolTip: {
|
|
1718
|
-
// eslint-disable-next-line max-len
|
|
1719
|
-
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.',
|
|
1720
|
-
// eslint-disable-next-line max-len
|
|
1721
|
-
licenceType: 'A Class 7 licence is the learner\'s licence you obtain after passing the written test and it allows you to drive with supervision from a licenced driver. A Class 5N licence is a probationary licence obtained after holding a Class 7 licence for at least 1 year (or 9 months with the completion of a driver\'s education course) and after you pass an advanced test on the road. Here you can drive with limited restrictions. A Class 5 licence is a full driving licence obtained after holding a Class 5N licence for 2 years. If you have driving experience from another country, please select your present Nova Scotia driver’s licence.',
|
|
1722
|
-
},
|
|
1723
|
-
licenceConfig: {
|
|
1724
|
-
title: '',
|
|
1725
|
-
minLicenceAge: 16,
|
|
1726
|
-
g1: {
|
|
1727
|
-
title: 'Class 7',
|
|
1728
|
-
name: 'g1',
|
|
1729
|
-
id: 'G1',
|
|
1730
|
-
description: '',
|
|
1731
|
-
},
|
|
1732
|
-
g2: {
|
|
1733
|
-
title: 'Class 5N',
|
|
1734
|
-
name: 'g2',
|
|
1735
|
-
id: 'G2',
|
|
1736
|
-
description: '',
|
|
1737
|
-
},
|
|
1738
|
-
g: {
|
|
1739
|
-
title: 'Class 5',
|
|
1740
|
-
name: 'g',
|
|
1741
|
-
id: 'G',
|
|
1742
|
-
description: '',
|
|
1743
|
-
},
|
|
1744
|
-
},
|
|
1745
|
-
minDates: {
|
|
1746
|
-
g1: {
|
|
1747
|
-
minMonth: 0,
|
|
1748
|
-
defaultMonth: 0,
|
|
1749
|
-
},
|
|
1750
|
-
g2: {
|
|
1751
|
-
minMonth: 9,
|
|
1752
|
-
defaultMonth: 3,
|
|
1753
|
-
},
|
|
1754
|
-
g: {
|
|
1755
|
-
minMonth: 24,
|
|
1756
|
-
defaultMonth: 0,
|
|
1757
|
-
specialDate: '1995-01-01',
|
|
1758
|
-
},
|
|
1759
|
-
},
|
|
1760
|
-
},
|
|
1761
|
-
{
|
|
1762
|
-
name: 'Newfoundland',
|
|
1763
|
-
code: NewfoundlandCode,
|
|
1764
|
-
toolTip: {
|
|
1765
|
-
// eslint-disable-next-line max-len
|
|
1766
|
-
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.',
|
|
1767
|
-
// eslint-disable-next-line max-len
|
|
1768
|
-
licenceType: 'A Class 5-Level 1 licence is a learner\'s licence obtained after passing a written test and allows you to drive under supervision. A Class 5-Level 2 licence is a probationary licence obtained after holding a Class 5-Level 1 licence for 1 year (or 8 months with the completion of a driver\'s education course) and passing an advanced test on the road. This allows you to drive with some restrictions. A Class 5 licence is a full licence obtained after holding a Class 5-Level 2 licence for 1 year and passing the final test on the road. If you have driving experience from another country, please select your current Newfoundland and Labrador driver’s licence.',
|
|
1769
|
-
},
|
|
1770
|
-
licenceConfig: {
|
|
1771
|
-
title: '',
|
|
1772
|
-
minLicenceAge: 16,
|
|
1773
|
-
g1: {
|
|
1774
|
-
title: 'Class 5-Level 1',
|
|
1775
|
-
name: 'g1',
|
|
1776
|
-
id: 'G1',
|
|
1777
|
-
description: '',
|
|
1778
|
-
},
|
|
1779
|
-
g2: {
|
|
1780
|
-
title: 'Class 5-Level 2',
|
|
1781
|
-
name: 'g2',
|
|
1782
|
-
id: 'G2',
|
|
1783
|
-
description: '',
|
|
1784
|
-
},
|
|
1785
|
-
g: {
|
|
1786
|
-
title: 'Class 5',
|
|
1787
|
-
name: 'g',
|
|
1788
|
-
id: 'G',
|
|
1789
|
-
description: '',
|
|
1790
|
-
},
|
|
1791
|
-
},
|
|
1792
|
-
minDates: {
|
|
1793
|
-
g1: {
|
|
1794
|
-
minMonth: 0,
|
|
1795
|
-
defaultMonth: 0,
|
|
1796
|
-
},
|
|
1797
|
-
g2: {
|
|
1798
|
-
minMonth: 8,
|
|
1799
|
-
defaultMonth: 4,
|
|
1800
|
-
},
|
|
1801
|
-
g: {
|
|
1802
|
-
minMonth: 12,
|
|
1803
|
-
defaultMonth: 0,
|
|
1804
|
-
specialDate: '1999-01-01',
|
|
1805
|
-
},
|
|
1806
|
-
},
|
|
1807
|
-
},
|
|
1808
|
-
{
|
|
1809
|
-
name: 'New Brunswick',
|
|
1810
|
-
code: NewBrunswickCode,
|
|
1811
|
-
toolTip: {
|
|
1812
|
-
// eslint-disable-next-line max-len
|
|
1813
|
-
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.',
|
|
1814
|
-
// eslint-disable-next-line max-len
|
|
1815
|
-
licenceType: 'A Class 7-Level 1 licence is a learner\'s licence obtained after passing a written test. A Class 7-Level 2 licence is a probationary licence obtained after holding a Class 7-Level 1 licence for 12 months (or 8 months with the completion of a driver\'s education course) and passing an advanced road test. A Class 5 licence is a full licence obtained after holding a Class 7-Level 2 licence for 12 months and passing the final road test. If you do not currently hold any of the licences listed above, but have a licence for another vehicle class, province, or the U.S., please select "Other',
|
|
1816
|
-
},
|
|
1817
|
-
licenceConfig: {
|
|
1818
|
-
title: '',
|
|
1819
|
-
minLicenceAge: 16,
|
|
1820
|
-
g1: {
|
|
1821
|
-
title: 'Class 7 - Level 1',
|
|
1822
|
-
name: 'g1',
|
|
1823
|
-
id: 'G1',
|
|
1824
|
-
description: '',
|
|
1825
|
-
},
|
|
1826
|
-
g2: {
|
|
1827
|
-
title: 'Class 7 - Level 2',
|
|
1828
|
-
name: 'g2',
|
|
1829
|
-
id: 'G2',
|
|
1830
|
-
description: '',
|
|
1831
|
-
},
|
|
1832
|
-
g: {
|
|
1833
|
-
title: 'Class 5',
|
|
1834
|
-
name: 'g',
|
|
1835
|
-
id: 'G',
|
|
1836
|
-
description: '',
|
|
1837
|
-
},
|
|
1838
|
-
},
|
|
1839
|
-
minDates: {
|
|
1840
|
-
g1: {
|
|
1841
|
-
minMonth: 0,
|
|
1842
|
-
defaultMonth: 0,
|
|
1843
|
-
},
|
|
1844
|
-
g2: {
|
|
1845
|
-
minMonth: 8,
|
|
1846
|
-
defaultMonth: 4,
|
|
1847
|
-
},
|
|
1848
|
-
g: {
|
|
1849
|
-
minMonth: 12,
|
|
1850
|
-
defaultMonth: 0,
|
|
1851
|
-
specialDate: '1995-01-01',
|
|
1852
|
-
},
|
|
1853
|
-
},
|
|
1854
|
-
},
|
|
1855
|
-
];
|
|
1856
|
-
|
|
1857
1876
|
const formCarConfigInitialState = {
|
|
1858
1877
|
...provinceList[0],
|
|
1859
1878
|
};
|
|
@@ -1909,7 +1928,7 @@ const formCarDiscountStateInitialState = {
|
|
|
1909
1928
|
policyStartYear: mychoiceSdkComponents.getFormattedDate(mychoiceSdkComponents.addDaysToDate('', 1), 'yyyy'),
|
|
1910
1929
|
quoterInfo: { ...discountQuoterInfoInitialState },
|
|
1911
1930
|
vehlinks: [{
|
|
1912
|
-
driverIndex:
|
|
1931
|
+
driverIndex: -1,
|
|
1913
1932
|
priority: mychoiceSdkComponents.DriverPriorityTypes.Prn,
|
|
1914
1933
|
vehicleIndex: 0,
|
|
1915
1934
|
}],
|
|
@@ -1963,6 +1982,10 @@ const deleteVehlinkByVehicle = (state, vehicleIndex) => {
|
|
|
1963
1982
|
}
|
|
1964
1983
|
});
|
|
1965
1984
|
newState.vehlinks = newVehLinks;
|
|
1985
|
+
// Keep occVehlinks in sync: drop links to the removed vehicle, reindex those after it.
|
|
1986
|
+
newState.occVehlinks = state.occVehlinks
|
|
1987
|
+
.filter((l) => l.vehicleIndex !== vehicleIndex)
|
|
1988
|
+
.map((l) => (l.vehicleIndex > vehicleIndex ? { ...l, vehicleIndex: l.vehicleIndex - 1 } : { ...l }));
|
|
1966
1989
|
return newState;
|
|
1967
1990
|
};
|
|
1968
1991
|
const deleteVehlinkByDriver = (state, driverIndex) => {
|
|
@@ -1970,16 +1993,20 @@ const deleteVehlinkByDriver = (state, driverIndex) => {
|
|
|
1970
1993
|
newState.vehlinks.map((vehLink) => {
|
|
1971
1994
|
const currentVehLink = vehLink;
|
|
1972
1995
|
if (currentVehLink.driverIndex === driverIndex) {
|
|
1973
|
-
currentVehLink.driverIndex =
|
|
1996
|
+
currentVehLink.driverIndex = -1;
|
|
1974
1997
|
}
|
|
1975
1998
|
return currentVehLink;
|
|
1976
1999
|
});
|
|
2000
|
+
// Keep occVehlinks in sync: drop the removed driver, reindex drivers after it.
|
|
2001
|
+
newState.occVehlinks = state.occVehlinks
|
|
2002
|
+
.filter((l) => l.driverIndex !== driverIndex)
|
|
2003
|
+
.map((l) => (l.driverIndex > driverIndex ? { ...l, driverIndex: l.driverIndex - 1 } : { ...l }));
|
|
1977
2004
|
return newState;
|
|
1978
2005
|
};
|
|
1979
2006
|
const addVehlink = (state) => {
|
|
1980
2007
|
const newState = mychoiceSdkComponents.deepClone(state);
|
|
1981
2008
|
newState.vehlinks.push({
|
|
1982
|
-
driverIndex:
|
|
2009
|
+
driverIndex: -1,
|
|
1983
2010
|
priority: mychoiceSdkComponents.DriverPriorityTypes.Prn,
|
|
1984
2011
|
vehicleIndex: state.vehlinks.length,
|
|
1985
2012
|
});
|
|
@@ -2055,7 +2082,9 @@ const formCarDiscountStateReducer = (state = { ...formCarDiscountStateInitialSta
|
|
|
2055
2082
|
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountVehlinkSelect:
|
|
2056
2083
|
return setLocalDiscounts$1(action.localIndex, selectDriverForVehicle(state, action.payload.driverIndex, action.payload.vehicleIndex));
|
|
2057
2084
|
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountOccVehlinkSelect: {
|
|
2058
|
-
const { driverIndex
|
|
2085
|
+
const { driverIndex } = action.payload;
|
|
2086
|
+
// vehicleIndex arrives as a string from the select onChange; store it as a number so the
|
|
2087
|
+
const vehicleIndex = Number(action.payload.vehicleIndex);
|
|
2059
2088
|
const filtered = state.occVehlinks.filter((l) => l.driverIndex !== driverIndex);
|
|
2060
2089
|
const updated = vehicleIndex >= 0
|
|
2061
2090
|
? [...filtered, { driverIndex, vehicleIndex }]
|
|
@@ -5471,23 +5500,13 @@ const CarQuoteDataHandler = () => {
|
|
|
5471
5500
|
};
|
|
5472
5501
|
const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth, } = licenceInfo;
|
|
5473
5502
|
const isOntarioMyChoiceLicence = requestBody.provinceCode === 'ON' && mychoiceSdkComponents.isMyChoiceLike(appConfigState.appType);
|
|
5503
|
+
const originalFirstClass = driver.licenceInfo.licenceType;
|
|
5474
5504
|
if (isOntarioMyChoiceLicence) {
|
|
5475
|
-
// Ontario new flow: licenceType = first class received (Q2).
|
|
5476
|
-
// receivedG2/receivedG flags determine the full progression.
|
|
5477
|
-
// Q1 date is stored in the slot matching licenceType.
|
|
5478
5505
|
const { receivedG2, receivedG } = driver.licenceInfo;
|
|
5479
|
-
const firstClass =
|
|
5480
|
-
//
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
const getOntarioQ1Slot = () => {
|
|
5484
|
-
if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2)
|
|
5485
|
-
return { year: g2LicenceYear, month: g2LicenceMonth };
|
|
5486
|
-
if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G)
|
|
5487
|
-
return { year: gLicenceYear, month: gLicenceMonth };
|
|
5488
|
-
return { year: g1LicenceYear, month: g1LicenceMonth };
|
|
5489
|
-
};
|
|
5490
|
-
const { year: ontarioQ1Year, month: ontarioQ1Month } = getOntarioQ1Slot();
|
|
5506
|
+
const firstClass = originalFirstClass;
|
|
5507
|
+
// Q1 (first-licence date) is always stored in the G1 slot, regardless of the chosen class.
|
|
5508
|
+
const ontarioQ1Year = g1LicenceYear;
|
|
5509
|
+
const ontarioQ1Month = g1LicenceMonth;
|
|
5491
5510
|
const ontarioQ1DateStr = ontarioQ1Year && ontarioQ1Month
|
|
5492
5511
|
? `${ontarioQ1Year}-${ontarioQ1Month}-01` : '';
|
|
5493
5512
|
const ontarioIsOnlyG = !!ontarioQ1DateStr
|
|
@@ -5495,18 +5514,18 @@ const CarQuoteDataHandler = () => {
|
|
|
5495
5514
|
// Determine which dates to send and final licence_type for the API.
|
|
5496
5515
|
// The backend always requires g1_licence_date as the first licence date.
|
|
5497
5516
|
if (ontarioIsOnlyG || firstClass === mychoiceSdkComponents.DriverLicenceTypes.G) {
|
|
5498
|
-
// G Full path: Q1 date is in
|
|
5499
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${
|
|
5517
|
+
// G Full path: Q1 (first licence) date is in the G1 slot; send it as the G date.
|
|
5518
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5500
5519
|
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
|
|
5501
5520
|
delete driver.licenceInfo.passedDriverTraining;
|
|
5502
5521
|
}
|
|
5503
5522
|
else if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1) {
|
|
5504
5523
|
// G1 path: Q1 date is in g1LicenceYear/Month
|
|
5505
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`,
|
|
5524
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5506
5525
|
if (receivedG2) {
|
|
5507
|
-
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`,
|
|
5526
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, 1);
|
|
5508
5527
|
if (receivedG) {
|
|
5509
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5528
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5510
5529
|
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
|
|
5511
5530
|
}
|
|
5512
5531
|
else {
|
|
@@ -5514,7 +5533,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5514
5533
|
}
|
|
5515
5534
|
}
|
|
5516
5535
|
else if (receivedG) {
|
|
5517
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5536
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5518
5537
|
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
|
|
5519
5538
|
}
|
|
5520
5539
|
else {
|
|
@@ -5522,11 +5541,11 @@ const CarQuoteDataHandler = () => {
|
|
|
5522
5541
|
}
|
|
5523
5542
|
}
|
|
5524
5543
|
else if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2) {
|
|
5525
|
-
// G2 path: Q1 (first licence) date is in
|
|
5526
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${
|
|
5527
|
-
driver.licenceInfo.g2LicenceDate = addDayToDate(`${
|
|
5544
|
+
// G2 path: Q1 (first licence) date is in the G1 slot and IS the G2 date.
|
|
5545
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5546
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5528
5547
|
if (receivedG) {
|
|
5529
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5548
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5530
5549
|
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
|
|
5531
5550
|
}
|
|
5532
5551
|
else {
|
|
@@ -5537,7 +5556,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5537
5556
|
}
|
|
5538
5557
|
else if (isOnlyG) {
|
|
5539
5558
|
if (driver.licenceInfo.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G) {
|
|
5540
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5559
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5541
5560
|
delete driver.licenceInfo.g1LicenceDate;
|
|
5542
5561
|
delete driver.licenceInfo.g2LicenceDate;
|
|
5543
5562
|
deleteLicenceDates();
|
|
@@ -5546,12 +5565,12 @@ const CarQuoteDataHandler = () => {
|
|
|
5546
5565
|
}
|
|
5547
5566
|
else {
|
|
5548
5567
|
if (driver.licenceInfo.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G1) {
|
|
5549
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`,
|
|
5568
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5550
5569
|
deleteLicenceDates();
|
|
5551
5570
|
}
|
|
5552
5571
|
if (driver.licenceInfo.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G2) {
|
|
5553
|
-
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`,
|
|
5554
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`,
|
|
5572
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, 1);
|
|
5573
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5555
5574
|
delete driver.licenceInfo.gLicenceDate;
|
|
5556
5575
|
deleteLicenceDates();
|
|
5557
5576
|
}
|
|
@@ -5559,9 +5578,9 @@ const CarQuoteDataHandler = () => {
|
|
|
5559
5578
|
delete driver.licenceInfo.passedDriverTraining;
|
|
5560
5579
|
}
|
|
5561
5580
|
if (driver.licenceInfo.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G) {
|
|
5562
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5563
|
-
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`,
|
|
5564
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`,
|
|
5581
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5582
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, 1);
|
|
5583
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5565
5584
|
deleteLicenceDates();
|
|
5566
5585
|
}
|
|
5567
5586
|
}
|
|
@@ -5594,7 +5613,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5594
5613
|
if (monthsG2toG < 12)
|
|
5595
5614
|
outside = true;
|
|
5596
5615
|
}
|
|
5597
|
-
if (
|
|
5616
|
+
if (originalFirstClass === mychoiceSdkComponents.DriverLicenceTypes.G2)
|
|
5598
5617
|
outside = true;
|
|
5599
5618
|
if (hasG1 && hasG && !hasG2)
|
|
5600
5619
|
outside = true;
|
|
@@ -5613,7 +5632,10 @@ const CarQuoteDataHandler = () => {
|
|
|
5613
5632
|
delete driver.birthYear;
|
|
5614
5633
|
delete driver.birthMonth;
|
|
5615
5634
|
delete driver.birthDay;
|
|
5616
|
-
|
|
5635
|
+
const licenceConfigEntry = configState.licenceConfig[driver.licenceInfo.licenceType];
|
|
5636
|
+
if (licenceConfigEntry) {
|
|
5637
|
+
driver.licenceInfo.licenceType = licenceConfigEntry.id;
|
|
5638
|
+
}
|
|
5617
5639
|
if (driver.minMaxDates) {
|
|
5618
5640
|
delete driver.minMaxDates;
|
|
5619
5641
|
}
|
|
@@ -5624,8 +5646,8 @@ const CarQuoteDataHandler = () => {
|
|
|
5624
5646
|
else {
|
|
5625
5647
|
driver.insuranceCancellationList = driver.insuranceCancellationList?.map((listItem) => ({
|
|
5626
5648
|
reason: listItem.cancellationReason,
|
|
5627
|
-
startDate: addDayToDate(`${listItem.startYear}-${listItem.startMonth}`,
|
|
5628
|
-
endDate: addDayToDate(`${listItem.endYear}-${listItem.endMonth}`,
|
|
5649
|
+
startDate: addDayToDate(`${listItem.startYear}-${listItem.startMonth}`, 1),
|
|
5650
|
+
endDate: addDayToDate(`${listItem.endYear}-${listItem.endMonth}`, 1),
|
|
5629
5651
|
}));
|
|
5630
5652
|
}
|
|
5631
5653
|
if (!driver.licenceSuspension) {
|
|
@@ -5634,8 +5656,8 @@ const CarQuoteDataHandler = () => {
|
|
|
5634
5656
|
else {
|
|
5635
5657
|
driver.licenceSuspensionList = driver.licenceSuspensionList?.map((listItem) => ({
|
|
5636
5658
|
reason: listItem.suspensionReason,
|
|
5637
|
-
reinstatementDate: addDayToDate(`${listItem.reinstatementYear}-${listItem.reinstatementMonth}`,
|
|
5638
|
-
suspensionDate: addDayToDate(`${listItem.suspensionYear}-${listItem.suspensionMonth}`,
|
|
5659
|
+
reinstatementDate: addDayToDate(`${listItem.reinstatementYear}-${listItem.reinstatementMonth}`, 1),
|
|
5660
|
+
suspensionDate: addDayToDate(`${listItem.suspensionYear}-${listItem.suspensionMonth}`, 1),
|
|
5639
5661
|
}));
|
|
5640
5662
|
}
|
|
5641
5663
|
if (!driver.accident) {
|
|
@@ -5643,7 +5665,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5643
5665
|
}
|
|
5644
5666
|
else {
|
|
5645
5667
|
driver.accidentList = driver.accidentList?.map((listItem) => ({
|
|
5646
|
-
accidentDate: addDayToDate(`${listItem.accidentYear}-${listItem.accidentMonth}`,
|
|
5668
|
+
accidentDate: addDayToDate(`${listItem.accidentYear}-${listItem.accidentMonth}`, 1),
|
|
5647
5669
|
}));
|
|
5648
5670
|
}
|
|
5649
5671
|
if (!driver.ticket) {
|
|
@@ -5652,7 +5674,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5652
5674
|
else {
|
|
5653
5675
|
driver.ticketList = driver.ticketList?.map((listItem) => ({
|
|
5654
5676
|
reason: listItem.ticketReason,
|
|
5655
|
-
ticketDate: addDayToDate(`${listItem.ticketYear}-${listItem.ticketMonth}`,
|
|
5677
|
+
ticketDate: addDayToDate(`${listItem.ticketYear}-${listItem.ticketMonth}`, 1),
|
|
5656
5678
|
}));
|
|
5657
5679
|
}
|
|
5658
5680
|
return driver;
|
|
@@ -5663,7 +5685,8 @@ const CarQuoteDataHandler = () => {
|
|
|
5663
5685
|
const vehicleCount = requestBody.vehicles.length;
|
|
5664
5686
|
const result = [];
|
|
5665
5687
|
for (let vehicleIndex = 0; vehicleIndex < vehicleCount; vehicleIndex++) {
|
|
5666
|
-
const
|
|
5688
|
+
const storedDriverIndex = requestBody.vehlinks[vehicleIndex]?.driverIndex ?? -1;
|
|
5689
|
+
const primaryDriverIndex = driverCount === 1 || storedDriverIndex < 0 ? 0 : storedDriverIndex;
|
|
5667
5690
|
// Primary driver for this vehicle
|
|
5668
5691
|
result.push({
|
|
5669
5692
|
driverIndex: Number(primaryDriverIndex + 1),
|
|
@@ -5684,7 +5707,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5684
5707
|
}
|
|
5685
5708
|
else {
|
|
5686
5709
|
// g-k) Use user-selected vehicle for extra drivers; skip if they are primary on another vehicle
|
|
5687
|
-
const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex
|
|
5710
|
+
const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex && l.vehicleIndex !== vehicleIndex);
|
|
5688
5711
|
if (isPrimaryElsewhere)
|
|
5689
5712
|
continue;
|
|
5690
5713
|
const occAssignment = discount.occVehlinks?.find((l) => l.driverIndex === driverIndex);
|
|
@@ -6362,7 +6385,8 @@ const useValidationVehicle = () => {
|
|
|
6362
6385
|
return item;
|
|
6363
6386
|
});
|
|
6364
6387
|
});
|
|
6365
|
-
|
|
6388
|
+
// MyChoice does not force AB review; the user can proceed without acknowledging.
|
|
6389
|
+
if (isAbReformActive && appConfigState.appType !== mychoiceSdkComponents.AppTypes.MyChoice) {
|
|
6366
6390
|
vehicleState.items.forEach((item) => {
|
|
6367
6391
|
if (!item.accidentbenefits.abAcknowledged) {
|
|
6368
6392
|
errors.push('abAcknowledged');
|
|
@@ -6412,6 +6436,7 @@ const useValidationVehicle = () => {
|
|
|
6412
6436
|
const useValidationDriver = () => {
|
|
6413
6437
|
const { driverState, dispatchDriverBaseState } = useStoreFormCarDriverBase();
|
|
6414
6438
|
const { discountState } = useStoreFormCarDiscount();
|
|
6439
|
+
const { configState } = useStoreFormCarConfig();
|
|
6415
6440
|
const { inValidation: driverFormIsInValidation = false, isValid: driverFormIsValid = false, } = driverState;
|
|
6416
6441
|
const { appConfigState } = useStoreAppConfig();
|
|
6417
6442
|
const { appType } = appConfigState;
|
|
@@ -6481,6 +6506,7 @@ const useValidationDriver = () => {
|
|
|
6481
6506
|
errors.push('policyStartDay');
|
|
6482
6507
|
}
|
|
6483
6508
|
}
|
|
6509
|
+
const isOntarioMyChoice = configState.code === OntarioCode && mychoiceSdkComponents.isMyChoiceLike(appType);
|
|
6484
6510
|
driverState.items.forEach((item, index) => {
|
|
6485
6511
|
Object.keys(item).forEach((key) => {
|
|
6486
6512
|
// checking errors in driverState
|
|
@@ -6501,7 +6527,15 @@ const useValidationDriver = () => {
|
|
|
6501
6527
|
if (key === 'licenceInfo') {
|
|
6502
6528
|
if (licenceInfoKeys.includes(objectKey) && !item[key][objectKey]) {
|
|
6503
6529
|
const { birthDay, birthMonth, birthYear } = item;
|
|
6504
|
-
if (
|
|
6530
|
+
if (isOntarioMyChoice) {
|
|
6531
|
+
// Ontario first-licence date lives in the G1 slot; firstLicenceAge is unused.
|
|
6532
|
+
if (objectKey === 'licenceType'
|
|
6533
|
+
|| objectKey === 'g1LicenceYear'
|
|
6534
|
+
|| objectKey === 'g1LicenceMonth') {
|
|
6535
|
+
errors.push(objectKey);
|
|
6536
|
+
}
|
|
6537
|
+
}
|
|
6538
|
+
else if (birthDay && birthMonth && birthYear && item[key].firstLicenceAge) {
|
|
6505
6539
|
errors.push(objectKey);
|
|
6506
6540
|
}
|
|
6507
6541
|
}
|
|
@@ -6525,6 +6559,27 @@ const useValidationDriver = () => {
|
|
|
6525
6559
|
});
|
|
6526
6560
|
}
|
|
6527
6561
|
});
|
|
6562
|
+
// Ontario MyChoice: validate licence dates when follow-up Yes answers require them.
|
|
6563
|
+
if (isOntarioMyChoice) {
|
|
6564
|
+
const { licenceType, g1LicenceYear, g1LicenceMonth, g2LicenceYear, g2LicenceMonth, gLicenceYear, gLicenceMonth, receivedG2, receivedG, } = item.licenceInfo;
|
|
6565
|
+
const q1Date = g1LicenceYear && g1LicenceMonth ? `${g1LicenceYear}-${g1LicenceMonth}-01` : '';
|
|
6566
|
+
const specialDate = configState.minDates?.g?.specialDate;
|
|
6567
|
+
const isOnlyG = !!q1Date && !!specialDate && mychoiceSdkComponents.compareDates(specialDate, q1Date) >= 0;
|
|
6568
|
+
const firstClass = isOnlyG ? mychoiceSdkComponents.DriverLicenceTypes.G : licenceType;
|
|
6569
|
+
if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1 && receivedG2 === true) {
|
|
6570
|
+
if (!g2LicenceYear)
|
|
6571
|
+
errors.push('g2LicenceYear');
|
|
6572
|
+
if (!g2LicenceMonth)
|
|
6573
|
+
errors.push('g2LicenceMonth');
|
|
6574
|
+
}
|
|
6575
|
+
if ((firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1 || firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2)
|
|
6576
|
+
&& receivedG === true) {
|
|
6577
|
+
if (!gLicenceYear)
|
|
6578
|
+
errors.push('gLicenceYear');
|
|
6579
|
+
if (!gLicenceMonth)
|
|
6580
|
+
errors.push('gLicenceMonth');
|
|
6581
|
+
}
|
|
6582
|
+
}
|
|
6528
6583
|
});
|
|
6529
6584
|
if (!errors.length) {
|
|
6530
6585
|
dispatchDriverBaseState({
|
|
@@ -6565,6 +6620,8 @@ const useValidationDriver = () => {
|
|
|
6565
6620
|
|
|
6566
6621
|
const useValidationCarDiscount = () => {
|
|
6567
6622
|
const { discountState, dispatchDiscountState } = useStoreFormCarDiscount();
|
|
6623
|
+
const { vehicleState: { items: vehicles } } = useStoreFormCarVehicle();
|
|
6624
|
+
const { driverState: { items: drivers } } = useStoreFormCarDriverBase();
|
|
6568
6625
|
const { inValidation = false, isValid = false, } = discountState;
|
|
6569
6626
|
const { appConfigState } = useStoreAppConfig();
|
|
6570
6627
|
const { dispatchAppModalState } = useStoreAppModal();
|
|
@@ -6599,6 +6656,42 @@ const useValidationCarDiscount = () => {
|
|
|
6599
6656
|
if (discountState.quoterInfo.phoneStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
|
|
6600
6657
|
errors.push('phone');
|
|
6601
6658
|
}
|
|
6659
|
+
if (drivers.length > 1) {
|
|
6660
|
+
// One primary-driver question per vehicle must be answered.
|
|
6661
|
+
vehicles.forEach((_vehicle, vehicleIndex) => {
|
|
6662
|
+
const primary = discountState.vehlinks.find((l) => l.vehicleIndex === vehicleIndex);
|
|
6663
|
+
if (!primary || primary.driverIndex < 0) {
|
|
6664
|
+
errors.push(`vehlink-${vehicleIndex}`);
|
|
6665
|
+
}
|
|
6666
|
+
});
|
|
6667
|
+
// When there are at least as many drivers as vehicles, every vehicle must have a distinct/unique primary.
|
|
6668
|
+
if (drivers.length >= vehicles.length) {
|
|
6669
|
+
const seenDrivers = new Set();
|
|
6670
|
+
vehicles.forEach((_vehicle, vehicleIndex) => {
|
|
6671
|
+
const primary = discountState.vehlinks.find((l) => l.vehicleIndex === vehicleIndex);
|
|
6672
|
+
if (primary && primary.driverIndex >= 0) {
|
|
6673
|
+
if (seenDrivers.has(primary.driverIndex)) {
|
|
6674
|
+
errors.push(`vehlink-${vehicleIndex}`);
|
|
6675
|
+
}
|
|
6676
|
+
seenDrivers.add(primary.driverIndex);
|
|
6677
|
+
}
|
|
6678
|
+
});
|
|
6679
|
+
}
|
|
6680
|
+
// When drivers outnumber vehicles AND there is more than one vehicle, each unassigned driver must pick a vehicle.
|
|
6681
|
+
if (drivers.length > vehicles.length && vehicles.length > 1) {
|
|
6682
|
+
const primaryDriverIndices = discountState.vehlinks
|
|
6683
|
+
.filter((l) => l.driverIndex >= 0)
|
|
6684
|
+
.map((l) => l.driverIndex);
|
|
6685
|
+
drivers.forEach((_driver, driverIndex) => {
|
|
6686
|
+
if (primaryDriverIndices.includes(driverIndex))
|
|
6687
|
+
return;
|
|
6688
|
+
const occ = discountState.occVehlinks.find((l) => l.driverIndex === driverIndex);
|
|
6689
|
+
if (!occ || occ.vehicleIndex < 0) {
|
|
6690
|
+
errors.push(`occ-vehlink-${driverIndex}`);
|
|
6691
|
+
}
|
|
6692
|
+
});
|
|
6693
|
+
}
|
|
6694
|
+
}
|
|
6602
6695
|
if (!errors.length) {
|
|
6603
6696
|
dispatchDiscountState({
|
|
6604
6697
|
type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountValidate,
|