@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/esm/index.js
CHANGED
|
@@ -901,6 +901,8 @@ const driverItemInitialState = {
|
|
|
901
901
|
gLicenceMonth: '',
|
|
902
902
|
passedDriverTraining: false,
|
|
903
903
|
previousLicence: false,
|
|
904
|
+
receivedG2: false,
|
|
905
|
+
receivedG: false,
|
|
904
906
|
},
|
|
905
907
|
minMaxDates: {
|
|
906
908
|
...driverItemMinMaxDates,
|
|
@@ -943,13 +945,267 @@ const carFormDriverInitialState = {
|
|
|
943
945
|
const localStateName$c = 'car_drivers';
|
|
944
946
|
const getLocalDrivers = (localIndex = '') => {
|
|
945
947
|
const localDrivers = localStorage.getItem(`${localIndex}_${localStateName$c}`) ? JSON.parse(localStorage.getItem(`${localIndex}_${localStateName$c}`) || '') : null;
|
|
946
|
-
|
|
948
|
+
const state = localDrivers || { ...carFormDriverInitialState };
|
|
949
|
+
// Coerce legacy null Yes/No licence flags back to default No
|
|
950
|
+
state.items?.forEach((item) => {
|
|
951
|
+
const info = item.licenceInfo;
|
|
952
|
+
if (!info)
|
|
953
|
+
return;
|
|
954
|
+
['passedDriverTraining', 'previousLicence', 'receivedG2', 'receivedG'].forEach((key) => {
|
|
955
|
+
if (info[key] == null)
|
|
956
|
+
info[key] = false;
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
return state;
|
|
947
960
|
};
|
|
948
961
|
const setLocalDrivers = (localIndex, state) => {
|
|
949
962
|
localStorage.setItem(`${localIndex || defaultLocalIndex}_${localStateName$c}`, JSON.stringify(state));
|
|
950
963
|
return state;
|
|
951
964
|
};
|
|
952
965
|
|
|
966
|
+
const OntarioCode = 'ON';
|
|
967
|
+
const AlbertaCode = 'AB';
|
|
968
|
+
const NovaScotiaCode = 'NS';
|
|
969
|
+
const NewfoundlandCode = 'NF';
|
|
970
|
+
const NewBrunswickCode = 'NB';
|
|
971
|
+
const provinceList = [
|
|
972
|
+
{
|
|
973
|
+
name: 'Ontario',
|
|
974
|
+
code: OntarioCode,
|
|
975
|
+
toolTip: {
|
|
976
|
+
// eslint-disable-next-line max-len
|
|
977
|
+
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.',
|
|
978
|
+
// eslint-disable-next-line max-len
|
|
979
|
+
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.',
|
|
980
|
+
},
|
|
981
|
+
licenceConfig: {
|
|
982
|
+
minLicenceAge: 16,
|
|
983
|
+
title: '',
|
|
984
|
+
g1: {
|
|
985
|
+
title: 'G1',
|
|
986
|
+
name: 'g1',
|
|
987
|
+
id: 'G1',
|
|
988
|
+
description: '',
|
|
989
|
+
},
|
|
990
|
+
g2: {
|
|
991
|
+
title: 'G2',
|
|
992
|
+
name: 'g2',
|
|
993
|
+
id: 'G2',
|
|
994
|
+
description: '',
|
|
995
|
+
},
|
|
996
|
+
g: {
|
|
997
|
+
title: 'G',
|
|
998
|
+
name: 'g',
|
|
999
|
+
id: 'G',
|
|
1000
|
+
description: '',
|
|
1001
|
+
},
|
|
1002
|
+
},
|
|
1003
|
+
minDates: {
|
|
1004
|
+
g1: {
|
|
1005
|
+
minMonth: 0,
|
|
1006
|
+
defaultMonth: 0, // month plus g one min
|
|
1007
|
+
},
|
|
1008
|
+
g2: {
|
|
1009
|
+
minMonth: 8,
|
|
1010
|
+
defaultMonth: 4, // month plus g2 min
|
|
1011
|
+
},
|
|
1012
|
+
g: {
|
|
1013
|
+
minMonth: 12,
|
|
1014
|
+
defaultMonth: 0,
|
|
1015
|
+
specialDate: '1994-04-01', // special g date, before it you can choose only g licence
|
|
1016
|
+
},
|
|
1017
|
+
},
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
name: 'Alberta',
|
|
1021
|
+
code: AlbertaCode,
|
|
1022
|
+
toolTip: {
|
|
1023
|
+
// eslint-disable-next-line max-len
|
|
1024
|
+
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.',
|
|
1025
|
+
// eslint-disable-next-line max-len
|
|
1026
|
+
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.',
|
|
1027
|
+
},
|
|
1028
|
+
licenceConfig: {
|
|
1029
|
+
title: '',
|
|
1030
|
+
minLicenceAge: 14,
|
|
1031
|
+
g1: {
|
|
1032
|
+
title: 'Class 7',
|
|
1033
|
+
name: 'g1',
|
|
1034
|
+
id: 'G1',
|
|
1035
|
+
description: '',
|
|
1036
|
+
},
|
|
1037
|
+
g2: {
|
|
1038
|
+
title: 'Class 5-GDL',
|
|
1039
|
+
name: 'g2',
|
|
1040
|
+
id: 'G2',
|
|
1041
|
+
description: '',
|
|
1042
|
+
},
|
|
1043
|
+
g: {
|
|
1044
|
+
title: 'Class 5',
|
|
1045
|
+
name: 'g',
|
|
1046
|
+
id: 'G',
|
|
1047
|
+
description: '',
|
|
1048
|
+
},
|
|
1049
|
+
},
|
|
1050
|
+
minDates: {
|
|
1051
|
+
g1: {
|
|
1052
|
+
minMonth: 0,
|
|
1053
|
+
defaultMonth: 0,
|
|
1054
|
+
},
|
|
1055
|
+
g2: {
|
|
1056
|
+
minMonth: 12,
|
|
1057
|
+
defaultMonth: 0,
|
|
1058
|
+
},
|
|
1059
|
+
g: {
|
|
1060
|
+
minMonth: 24,
|
|
1061
|
+
defaultMonth: 0,
|
|
1062
|
+
specialDate: '2004-01-01',
|
|
1063
|
+
},
|
|
1064
|
+
},
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
name: 'Nova Scotia',
|
|
1068
|
+
code: NovaScotiaCode,
|
|
1069
|
+
toolTip: {
|
|
1070
|
+
// eslint-disable-next-line max-len
|
|
1071
|
+
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.',
|
|
1072
|
+
// eslint-disable-next-line max-len
|
|
1073
|
+
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.',
|
|
1074
|
+
},
|
|
1075
|
+
licenceConfig: {
|
|
1076
|
+
title: '',
|
|
1077
|
+
minLicenceAge: 16,
|
|
1078
|
+
g1: {
|
|
1079
|
+
title: 'Class 7',
|
|
1080
|
+
name: 'g1',
|
|
1081
|
+
id: 'G1',
|
|
1082
|
+
description: '',
|
|
1083
|
+
},
|
|
1084
|
+
g2: {
|
|
1085
|
+
title: 'Class 5N',
|
|
1086
|
+
name: 'g2',
|
|
1087
|
+
id: 'G2',
|
|
1088
|
+
description: '',
|
|
1089
|
+
},
|
|
1090
|
+
g: {
|
|
1091
|
+
title: 'Class 5',
|
|
1092
|
+
name: 'g',
|
|
1093
|
+
id: 'G',
|
|
1094
|
+
description: '',
|
|
1095
|
+
},
|
|
1096
|
+
},
|
|
1097
|
+
minDates: {
|
|
1098
|
+
g1: {
|
|
1099
|
+
minMonth: 0,
|
|
1100
|
+
defaultMonth: 0,
|
|
1101
|
+
},
|
|
1102
|
+
g2: {
|
|
1103
|
+
minMonth: 9,
|
|
1104
|
+
defaultMonth: 3,
|
|
1105
|
+
},
|
|
1106
|
+
g: {
|
|
1107
|
+
minMonth: 24,
|
|
1108
|
+
defaultMonth: 0,
|
|
1109
|
+
specialDate: '1995-01-01',
|
|
1110
|
+
},
|
|
1111
|
+
},
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
name: 'Newfoundland',
|
|
1115
|
+
code: NewfoundlandCode,
|
|
1116
|
+
toolTip: {
|
|
1117
|
+
// eslint-disable-next-line max-len
|
|
1118
|
+
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.',
|
|
1119
|
+
// eslint-disable-next-line max-len
|
|
1120
|
+
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.',
|
|
1121
|
+
},
|
|
1122
|
+
licenceConfig: {
|
|
1123
|
+
title: '',
|
|
1124
|
+
minLicenceAge: 16,
|
|
1125
|
+
g1: {
|
|
1126
|
+
title: 'Class 5-Level 1',
|
|
1127
|
+
name: 'g1',
|
|
1128
|
+
id: 'G1',
|
|
1129
|
+
description: '',
|
|
1130
|
+
},
|
|
1131
|
+
g2: {
|
|
1132
|
+
title: 'Class 5-Level 2',
|
|
1133
|
+
name: 'g2',
|
|
1134
|
+
id: 'G2',
|
|
1135
|
+
description: '',
|
|
1136
|
+
},
|
|
1137
|
+
g: {
|
|
1138
|
+
title: 'Class 5',
|
|
1139
|
+
name: 'g',
|
|
1140
|
+
id: 'G',
|
|
1141
|
+
description: '',
|
|
1142
|
+
},
|
|
1143
|
+
},
|
|
1144
|
+
minDates: {
|
|
1145
|
+
g1: {
|
|
1146
|
+
minMonth: 0,
|
|
1147
|
+
defaultMonth: 0,
|
|
1148
|
+
},
|
|
1149
|
+
g2: {
|
|
1150
|
+
minMonth: 8,
|
|
1151
|
+
defaultMonth: 4,
|
|
1152
|
+
},
|
|
1153
|
+
g: {
|
|
1154
|
+
minMonth: 12,
|
|
1155
|
+
defaultMonth: 0,
|
|
1156
|
+
specialDate: '1999-01-01',
|
|
1157
|
+
},
|
|
1158
|
+
},
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
name: 'New Brunswick',
|
|
1162
|
+
code: NewBrunswickCode,
|
|
1163
|
+
toolTip: {
|
|
1164
|
+
// eslint-disable-next-line max-len
|
|
1165
|
+
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.',
|
|
1166
|
+
// eslint-disable-next-line max-len
|
|
1167
|
+
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',
|
|
1168
|
+
},
|
|
1169
|
+
licenceConfig: {
|
|
1170
|
+
title: '',
|
|
1171
|
+
minLicenceAge: 16,
|
|
1172
|
+
g1: {
|
|
1173
|
+
title: 'Class 7 - Level 1',
|
|
1174
|
+
name: 'g1',
|
|
1175
|
+
id: 'G1',
|
|
1176
|
+
description: '',
|
|
1177
|
+
},
|
|
1178
|
+
g2: {
|
|
1179
|
+
title: 'Class 7 - Level 2',
|
|
1180
|
+
name: 'g2',
|
|
1181
|
+
id: 'G2',
|
|
1182
|
+
description: '',
|
|
1183
|
+
},
|
|
1184
|
+
g: {
|
|
1185
|
+
title: 'Class 5',
|
|
1186
|
+
name: 'g',
|
|
1187
|
+
id: 'G',
|
|
1188
|
+
description: '',
|
|
1189
|
+
},
|
|
1190
|
+
},
|
|
1191
|
+
minDates: {
|
|
1192
|
+
g1: {
|
|
1193
|
+
minMonth: 0,
|
|
1194
|
+
defaultMonth: 0,
|
|
1195
|
+
},
|
|
1196
|
+
g2: {
|
|
1197
|
+
minMonth: 8,
|
|
1198
|
+
defaultMonth: 4,
|
|
1199
|
+
},
|
|
1200
|
+
g: {
|
|
1201
|
+
minMonth: 12,
|
|
1202
|
+
defaultMonth: 0,
|
|
1203
|
+
specialDate: '1995-01-01',
|
|
1204
|
+
},
|
|
1205
|
+
},
|
|
1206
|
+
},
|
|
1207
|
+
];
|
|
1208
|
+
|
|
953
1209
|
const setDriverProperty = (state, name, value) => {
|
|
954
1210
|
const newState = deepClone(state);
|
|
955
1211
|
if (name !== 'isValid' && name !== 'inValidation') {
|
|
@@ -1113,11 +1369,17 @@ const setDriverLicenceType = (state, payload) => {
|
|
|
1113
1369
|
const newState = deepClone(state);
|
|
1114
1370
|
newState.isValid = false;
|
|
1115
1371
|
newState.items[newState.activeIndex].licenceInfo.licenceType = payload.licenceType;
|
|
1372
|
+
// Reset follow-up Yes/No to default No when the first licence class changes
|
|
1373
|
+
newState.items[newState.activeIndex].licenceInfo.receivedG2 = false;
|
|
1374
|
+
newState.items[newState.activeIndex].licenceInfo.receivedG = false;
|
|
1116
1375
|
const { minMaxDates } = newState.items[newState.activeIndex];
|
|
1117
1376
|
const currentDate = getFormattedDate('', 'yyyy-MM-dd');
|
|
1118
1377
|
if (payload.licenceType === DriverLicenceTypes.G2 && minMaxDates) {
|
|
1119
1378
|
minMaxDates.gTwoMax = currentDate;
|
|
1120
1379
|
}
|
|
1380
|
+
if (payload.config.code === OntarioCode) {
|
|
1381
|
+
return newState;
|
|
1382
|
+
}
|
|
1121
1383
|
const { licenceType, firstLicenceAge } = newState.items[state.activeIndex].licenceInfo;
|
|
1122
1384
|
const { birthYear, birthMonth, birthDay } = newState.items[state.activeIndex];
|
|
1123
1385
|
const dateOfBirth = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
|
|
@@ -1602,249 +1864,6 @@ var StoreFormCarConfigActionTypes;
|
|
|
1602
1864
|
StoreFormCarConfigActionTypes["FormCarConfigClear"] = "FormCarConfigClear";
|
|
1603
1865
|
})(StoreFormCarConfigActionTypes || (StoreFormCarConfigActionTypes = {}));
|
|
1604
1866
|
|
|
1605
|
-
const OntarioCode = 'ON';
|
|
1606
|
-
const AlbertaCode = 'AB';
|
|
1607
|
-
const NovaScotiaCode = 'NS';
|
|
1608
|
-
const NewfoundlandCode = 'NF';
|
|
1609
|
-
const NewBrunswickCode = 'NB';
|
|
1610
|
-
const provinceList = [
|
|
1611
|
-
{
|
|
1612
|
-
name: 'Ontario',
|
|
1613
|
-
code: OntarioCode,
|
|
1614
|
-
toolTip: {
|
|
1615
|
-
// eslint-disable-next-line max-len
|
|
1616
|
-
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.',
|
|
1617
|
-
// eslint-disable-next-line max-len
|
|
1618
|
-
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.',
|
|
1619
|
-
},
|
|
1620
|
-
licenceConfig: {
|
|
1621
|
-
minLicenceAge: 16,
|
|
1622
|
-
title: '',
|
|
1623
|
-
g1: {
|
|
1624
|
-
title: 'G1',
|
|
1625
|
-
name: 'g1',
|
|
1626
|
-
id: 'G1',
|
|
1627
|
-
description: '',
|
|
1628
|
-
},
|
|
1629
|
-
g2: {
|
|
1630
|
-
title: 'G2',
|
|
1631
|
-
name: 'g2',
|
|
1632
|
-
id: 'G2',
|
|
1633
|
-
description: '',
|
|
1634
|
-
},
|
|
1635
|
-
g: {
|
|
1636
|
-
title: 'G',
|
|
1637
|
-
name: 'g',
|
|
1638
|
-
id: 'G',
|
|
1639
|
-
description: '',
|
|
1640
|
-
},
|
|
1641
|
-
},
|
|
1642
|
-
minDates: {
|
|
1643
|
-
g1: {
|
|
1644
|
-
minMonth: 0,
|
|
1645
|
-
defaultMonth: 0, // month plus g one min
|
|
1646
|
-
},
|
|
1647
|
-
g2: {
|
|
1648
|
-
minMonth: 8,
|
|
1649
|
-
defaultMonth: 4, // month plus g2 min
|
|
1650
|
-
},
|
|
1651
|
-
g: {
|
|
1652
|
-
minMonth: 12,
|
|
1653
|
-
defaultMonth: 0,
|
|
1654
|
-
specialDate: '1994-04-01', // special g date, before it you can choose only g licence
|
|
1655
|
-
},
|
|
1656
|
-
},
|
|
1657
|
-
},
|
|
1658
|
-
{
|
|
1659
|
-
name: 'Alberta',
|
|
1660
|
-
code: AlbertaCode,
|
|
1661
|
-
toolTip: {
|
|
1662
|
-
// eslint-disable-next-line max-len
|
|
1663
|
-
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.',
|
|
1664
|
-
// eslint-disable-next-line max-len
|
|
1665
|
-
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.',
|
|
1666
|
-
},
|
|
1667
|
-
licenceConfig: {
|
|
1668
|
-
title: '',
|
|
1669
|
-
minLicenceAge: 14,
|
|
1670
|
-
g1: {
|
|
1671
|
-
title: 'Class 7',
|
|
1672
|
-
name: 'g1',
|
|
1673
|
-
id: 'G1',
|
|
1674
|
-
description: '',
|
|
1675
|
-
},
|
|
1676
|
-
g2: {
|
|
1677
|
-
title: 'Class 5-GDL',
|
|
1678
|
-
name: 'g2',
|
|
1679
|
-
id: 'G2',
|
|
1680
|
-
description: '',
|
|
1681
|
-
},
|
|
1682
|
-
g: {
|
|
1683
|
-
title: 'Class 5',
|
|
1684
|
-
name: 'g',
|
|
1685
|
-
id: 'G',
|
|
1686
|
-
description: '',
|
|
1687
|
-
},
|
|
1688
|
-
},
|
|
1689
|
-
minDates: {
|
|
1690
|
-
g1: {
|
|
1691
|
-
minMonth: 0,
|
|
1692
|
-
defaultMonth: 0,
|
|
1693
|
-
},
|
|
1694
|
-
g2: {
|
|
1695
|
-
minMonth: 12,
|
|
1696
|
-
defaultMonth: 0,
|
|
1697
|
-
},
|
|
1698
|
-
g: {
|
|
1699
|
-
minMonth: 24,
|
|
1700
|
-
defaultMonth: 0,
|
|
1701
|
-
specialDate: '2004-01-01',
|
|
1702
|
-
},
|
|
1703
|
-
},
|
|
1704
|
-
},
|
|
1705
|
-
{
|
|
1706
|
-
name: 'Nova Scotia',
|
|
1707
|
-
code: NovaScotiaCode,
|
|
1708
|
-
toolTip: {
|
|
1709
|
-
// eslint-disable-next-line max-len
|
|
1710
|
-
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.',
|
|
1711
|
-
// eslint-disable-next-line max-len
|
|
1712
|
-
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.',
|
|
1713
|
-
},
|
|
1714
|
-
licenceConfig: {
|
|
1715
|
-
title: '',
|
|
1716
|
-
minLicenceAge: 16,
|
|
1717
|
-
g1: {
|
|
1718
|
-
title: 'Class 7',
|
|
1719
|
-
name: 'g1',
|
|
1720
|
-
id: 'G1',
|
|
1721
|
-
description: '',
|
|
1722
|
-
},
|
|
1723
|
-
g2: {
|
|
1724
|
-
title: 'Class 5N',
|
|
1725
|
-
name: 'g2',
|
|
1726
|
-
id: 'G2',
|
|
1727
|
-
description: '',
|
|
1728
|
-
},
|
|
1729
|
-
g: {
|
|
1730
|
-
title: 'Class 5',
|
|
1731
|
-
name: 'g',
|
|
1732
|
-
id: 'G',
|
|
1733
|
-
description: '',
|
|
1734
|
-
},
|
|
1735
|
-
},
|
|
1736
|
-
minDates: {
|
|
1737
|
-
g1: {
|
|
1738
|
-
minMonth: 0,
|
|
1739
|
-
defaultMonth: 0,
|
|
1740
|
-
},
|
|
1741
|
-
g2: {
|
|
1742
|
-
minMonth: 9,
|
|
1743
|
-
defaultMonth: 3,
|
|
1744
|
-
},
|
|
1745
|
-
g: {
|
|
1746
|
-
minMonth: 24,
|
|
1747
|
-
defaultMonth: 0,
|
|
1748
|
-
specialDate: '1995-01-01',
|
|
1749
|
-
},
|
|
1750
|
-
},
|
|
1751
|
-
},
|
|
1752
|
-
{
|
|
1753
|
-
name: 'Newfoundland',
|
|
1754
|
-
code: NewfoundlandCode,
|
|
1755
|
-
toolTip: {
|
|
1756
|
-
// eslint-disable-next-line max-len
|
|
1757
|
-
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.',
|
|
1758
|
-
// eslint-disable-next-line max-len
|
|
1759
|
-
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.',
|
|
1760
|
-
},
|
|
1761
|
-
licenceConfig: {
|
|
1762
|
-
title: '',
|
|
1763
|
-
minLicenceAge: 16,
|
|
1764
|
-
g1: {
|
|
1765
|
-
title: 'Class 5-Level 1',
|
|
1766
|
-
name: 'g1',
|
|
1767
|
-
id: 'G1',
|
|
1768
|
-
description: '',
|
|
1769
|
-
},
|
|
1770
|
-
g2: {
|
|
1771
|
-
title: 'Class 5-Level 2',
|
|
1772
|
-
name: 'g2',
|
|
1773
|
-
id: 'G2',
|
|
1774
|
-
description: '',
|
|
1775
|
-
},
|
|
1776
|
-
g: {
|
|
1777
|
-
title: 'Class 5',
|
|
1778
|
-
name: 'g',
|
|
1779
|
-
id: 'G',
|
|
1780
|
-
description: '',
|
|
1781
|
-
},
|
|
1782
|
-
},
|
|
1783
|
-
minDates: {
|
|
1784
|
-
g1: {
|
|
1785
|
-
minMonth: 0,
|
|
1786
|
-
defaultMonth: 0,
|
|
1787
|
-
},
|
|
1788
|
-
g2: {
|
|
1789
|
-
minMonth: 8,
|
|
1790
|
-
defaultMonth: 4,
|
|
1791
|
-
},
|
|
1792
|
-
g: {
|
|
1793
|
-
minMonth: 12,
|
|
1794
|
-
defaultMonth: 0,
|
|
1795
|
-
specialDate: '1999-01-01',
|
|
1796
|
-
},
|
|
1797
|
-
},
|
|
1798
|
-
},
|
|
1799
|
-
{
|
|
1800
|
-
name: 'New Brunswick',
|
|
1801
|
-
code: NewBrunswickCode,
|
|
1802
|
-
toolTip: {
|
|
1803
|
-
// eslint-disable-next-line max-len
|
|
1804
|
-
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.',
|
|
1805
|
-
// eslint-disable-next-line max-len
|
|
1806
|
-
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',
|
|
1807
|
-
},
|
|
1808
|
-
licenceConfig: {
|
|
1809
|
-
title: '',
|
|
1810
|
-
minLicenceAge: 16,
|
|
1811
|
-
g1: {
|
|
1812
|
-
title: 'Class 7 - Level 1',
|
|
1813
|
-
name: 'g1',
|
|
1814
|
-
id: 'G1',
|
|
1815
|
-
description: '',
|
|
1816
|
-
},
|
|
1817
|
-
g2: {
|
|
1818
|
-
title: 'Class 7 - Level 2',
|
|
1819
|
-
name: 'g2',
|
|
1820
|
-
id: 'G2',
|
|
1821
|
-
description: '',
|
|
1822
|
-
},
|
|
1823
|
-
g: {
|
|
1824
|
-
title: 'Class 5',
|
|
1825
|
-
name: 'g',
|
|
1826
|
-
id: 'G',
|
|
1827
|
-
description: '',
|
|
1828
|
-
},
|
|
1829
|
-
},
|
|
1830
|
-
minDates: {
|
|
1831
|
-
g1: {
|
|
1832
|
-
minMonth: 0,
|
|
1833
|
-
defaultMonth: 0,
|
|
1834
|
-
},
|
|
1835
|
-
g2: {
|
|
1836
|
-
minMonth: 8,
|
|
1837
|
-
defaultMonth: 4,
|
|
1838
|
-
},
|
|
1839
|
-
g: {
|
|
1840
|
-
minMonth: 12,
|
|
1841
|
-
defaultMonth: 0,
|
|
1842
|
-
specialDate: '1995-01-01',
|
|
1843
|
-
},
|
|
1844
|
-
},
|
|
1845
|
-
},
|
|
1846
|
-
];
|
|
1847
|
-
|
|
1848
1867
|
const formCarConfigInitialState = {
|
|
1849
1868
|
...provinceList[0],
|
|
1850
1869
|
};
|
|
@@ -1900,7 +1919,7 @@ const formCarDiscountStateInitialState = {
|
|
|
1900
1919
|
policyStartYear: getFormattedDate(addDaysToDate('', 1), 'yyyy'),
|
|
1901
1920
|
quoterInfo: { ...discountQuoterInfoInitialState },
|
|
1902
1921
|
vehlinks: [{
|
|
1903
|
-
driverIndex:
|
|
1922
|
+
driverIndex: -1,
|
|
1904
1923
|
priority: DriverPriorityTypes.Prn,
|
|
1905
1924
|
vehicleIndex: 0,
|
|
1906
1925
|
}],
|
|
@@ -1954,6 +1973,10 @@ const deleteVehlinkByVehicle = (state, vehicleIndex) => {
|
|
|
1954
1973
|
}
|
|
1955
1974
|
});
|
|
1956
1975
|
newState.vehlinks = newVehLinks;
|
|
1976
|
+
// Keep occVehlinks in sync: drop links to the removed vehicle, reindex those after it.
|
|
1977
|
+
newState.occVehlinks = state.occVehlinks
|
|
1978
|
+
.filter((l) => l.vehicleIndex !== vehicleIndex)
|
|
1979
|
+
.map((l) => (l.vehicleIndex > vehicleIndex ? { ...l, vehicleIndex: l.vehicleIndex - 1 } : { ...l }));
|
|
1957
1980
|
return newState;
|
|
1958
1981
|
};
|
|
1959
1982
|
const deleteVehlinkByDriver = (state, driverIndex) => {
|
|
@@ -1961,16 +1984,20 @@ const deleteVehlinkByDriver = (state, driverIndex) => {
|
|
|
1961
1984
|
newState.vehlinks.map((vehLink) => {
|
|
1962
1985
|
const currentVehLink = vehLink;
|
|
1963
1986
|
if (currentVehLink.driverIndex === driverIndex) {
|
|
1964
|
-
currentVehLink.driverIndex =
|
|
1987
|
+
currentVehLink.driverIndex = -1;
|
|
1965
1988
|
}
|
|
1966
1989
|
return currentVehLink;
|
|
1967
1990
|
});
|
|
1991
|
+
// Keep occVehlinks in sync: drop the removed driver, reindex drivers after it.
|
|
1992
|
+
newState.occVehlinks = state.occVehlinks
|
|
1993
|
+
.filter((l) => l.driverIndex !== driverIndex)
|
|
1994
|
+
.map((l) => (l.driverIndex > driverIndex ? { ...l, driverIndex: l.driverIndex - 1 } : { ...l }));
|
|
1968
1995
|
return newState;
|
|
1969
1996
|
};
|
|
1970
1997
|
const addVehlink = (state) => {
|
|
1971
1998
|
const newState = deepClone(state);
|
|
1972
1999
|
newState.vehlinks.push({
|
|
1973
|
-
driverIndex:
|
|
2000
|
+
driverIndex: -1,
|
|
1974
2001
|
priority: DriverPriorityTypes.Prn,
|
|
1975
2002
|
vehicleIndex: state.vehlinks.length,
|
|
1976
2003
|
});
|
|
@@ -2046,7 +2073,9 @@ const formCarDiscountStateReducer = (state = { ...formCarDiscountStateInitialSta
|
|
|
2046
2073
|
case StoreFormCarDiscountActionTypes.FormCarDiscountVehlinkSelect:
|
|
2047
2074
|
return setLocalDiscounts$1(action.localIndex, selectDriverForVehicle(state, action.payload.driverIndex, action.payload.vehicleIndex));
|
|
2048
2075
|
case StoreFormCarDiscountActionTypes.FormCarDiscountOccVehlinkSelect: {
|
|
2049
|
-
const { driverIndex
|
|
2076
|
+
const { driverIndex } = action.payload;
|
|
2077
|
+
// vehicleIndex arrives as a string from the select onChange; store it as a number so the
|
|
2078
|
+
const vehicleIndex = Number(action.payload.vehicleIndex);
|
|
2050
2079
|
const filtered = state.occVehlinks.filter((l) => l.driverIndex !== driverIndex);
|
|
2051
2080
|
const updated = vehicleIndex >= 0
|
|
2052
2081
|
? [...filtered, { driverIndex, vehicleIndex }]
|
|
@@ -5462,23 +5491,13 @@ const CarQuoteDataHandler = () => {
|
|
|
5462
5491
|
};
|
|
5463
5492
|
const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth, } = licenceInfo;
|
|
5464
5493
|
const isOntarioMyChoiceLicence = requestBody.provinceCode === 'ON' && isMyChoiceLike(appConfigState.appType);
|
|
5494
|
+
const originalFirstClass = driver.licenceInfo.licenceType;
|
|
5465
5495
|
if (isOntarioMyChoiceLicence) {
|
|
5466
|
-
// Ontario new flow: licenceType = first class received (Q2).
|
|
5467
|
-
// receivedG2/receivedG flags determine the full progression.
|
|
5468
|
-
// Q1 date is stored in the slot matching licenceType.
|
|
5469
5496
|
const { receivedG2, receivedG } = driver.licenceInfo;
|
|
5470
|
-
const firstClass =
|
|
5471
|
-
//
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
const getOntarioQ1Slot = () => {
|
|
5475
|
-
if (firstClass === DriverLicenceTypes.G2)
|
|
5476
|
-
return { year: g2LicenceYear, month: g2LicenceMonth };
|
|
5477
|
-
if (firstClass === DriverLicenceTypes.G)
|
|
5478
|
-
return { year: gLicenceYear, month: gLicenceMonth };
|
|
5479
|
-
return { year: g1LicenceYear, month: g1LicenceMonth };
|
|
5480
|
-
};
|
|
5481
|
-
const { year: ontarioQ1Year, month: ontarioQ1Month } = getOntarioQ1Slot();
|
|
5497
|
+
const firstClass = originalFirstClass;
|
|
5498
|
+
// Q1 (first-licence date) is always stored in the G1 slot, regardless of the chosen class.
|
|
5499
|
+
const ontarioQ1Year = g1LicenceYear;
|
|
5500
|
+
const ontarioQ1Month = g1LicenceMonth;
|
|
5482
5501
|
const ontarioQ1DateStr = ontarioQ1Year && ontarioQ1Month
|
|
5483
5502
|
? `${ontarioQ1Year}-${ontarioQ1Month}-01` : '';
|
|
5484
5503
|
const ontarioIsOnlyG = !!ontarioQ1DateStr
|
|
@@ -5486,18 +5505,18 @@ const CarQuoteDataHandler = () => {
|
|
|
5486
5505
|
// Determine which dates to send and final licence_type for the API.
|
|
5487
5506
|
// The backend always requires g1_licence_date as the first licence date.
|
|
5488
5507
|
if (ontarioIsOnlyG || firstClass === DriverLicenceTypes.G) {
|
|
5489
|
-
// G Full path: Q1 date is in
|
|
5490
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${
|
|
5508
|
+
// G Full path: Q1 (first licence) date is in the G1 slot; send it as the G date.
|
|
5509
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5491
5510
|
driver.licenceInfo.licenceType = DriverLicenceTypes.G;
|
|
5492
5511
|
delete driver.licenceInfo.passedDriverTraining;
|
|
5493
5512
|
}
|
|
5494
5513
|
else if (firstClass === DriverLicenceTypes.G1) {
|
|
5495
5514
|
// G1 path: Q1 date is in g1LicenceYear/Month
|
|
5496
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`,
|
|
5515
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5497
5516
|
if (receivedG2) {
|
|
5498
|
-
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`,
|
|
5517
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, 1);
|
|
5499
5518
|
if (receivedG) {
|
|
5500
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5519
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5501
5520
|
driver.licenceInfo.licenceType = DriverLicenceTypes.G;
|
|
5502
5521
|
}
|
|
5503
5522
|
else {
|
|
@@ -5505,7 +5524,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5505
5524
|
}
|
|
5506
5525
|
}
|
|
5507
5526
|
else if (receivedG) {
|
|
5508
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5527
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5509
5528
|
driver.licenceInfo.licenceType = DriverLicenceTypes.G;
|
|
5510
5529
|
}
|
|
5511
5530
|
else {
|
|
@@ -5513,11 +5532,11 @@ const CarQuoteDataHandler = () => {
|
|
|
5513
5532
|
}
|
|
5514
5533
|
}
|
|
5515
5534
|
else if (firstClass === DriverLicenceTypes.G2) {
|
|
5516
|
-
// G2 path: Q1 (first licence) date is in
|
|
5517
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${
|
|
5518
|
-
driver.licenceInfo.g2LicenceDate = addDayToDate(`${
|
|
5535
|
+
// G2 path: Q1 (first licence) date is in the G1 slot and IS the G2 date.
|
|
5536
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5537
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5519
5538
|
if (receivedG) {
|
|
5520
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5539
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5521
5540
|
driver.licenceInfo.licenceType = DriverLicenceTypes.G;
|
|
5522
5541
|
}
|
|
5523
5542
|
else {
|
|
@@ -5528,7 +5547,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5528
5547
|
}
|
|
5529
5548
|
else if (isOnlyG) {
|
|
5530
5549
|
if (driver.licenceInfo.licenceType === DriverLicenceTypes.G) {
|
|
5531
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5550
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5532
5551
|
delete driver.licenceInfo.g1LicenceDate;
|
|
5533
5552
|
delete driver.licenceInfo.g2LicenceDate;
|
|
5534
5553
|
deleteLicenceDates();
|
|
@@ -5537,12 +5556,12 @@ const CarQuoteDataHandler = () => {
|
|
|
5537
5556
|
}
|
|
5538
5557
|
else {
|
|
5539
5558
|
if (driver.licenceInfo.licenceType === DriverLicenceTypes.G1) {
|
|
5540
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`,
|
|
5559
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5541
5560
|
deleteLicenceDates();
|
|
5542
5561
|
}
|
|
5543
5562
|
if (driver.licenceInfo.licenceType === DriverLicenceTypes.G2) {
|
|
5544
|
-
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`,
|
|
5545
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`,
|
|
5563
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, 1);
|
|
5564
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5546
5565
|
delete driver.licenceInfo.gLicenceDate;
|
|
5547
5566
|
deleteLicenceDates();
|
|
5548
5567
|
}
|
|
@@ -5550,9 +5569,9 @@ const CarQuoteDataHandler = () => {
|
|
|
5550
5569
|
delete driver.licenceInfo.passedDriverTraining;
|
|
5551
5570
|
}
|
|
5552
5571
|
if (driver.licenceInfo.licenceType === DriverLicenceTypes.G) {
|
|
5553
|
-
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`,
|
|
5554
|
-
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`,
|
|
5555
|
-
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`,
|
|
5572
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, 1);
|
|
5573
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, 1);
|
|
5574
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, 1);
|
|
5556
5575
|
deleteLicenceDates();
|
|
5557
5576
|
}
|
|
5558
5577
|
}
|
|
@@ -5585,7 +5604,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5585
5604
|
if (monthsG2toG < 12)
|
|
5586
5605
|
outside = true;
|
|
5587
5606
|
}
|
|
5588
|
-
if (
|
|
5607
|
+
if (originalFirstClass === DriverLicenceTypes.G2)
|
|
5589
5608
|
outside = true;
|
|
5590
5609
|
if (hasG1 && hasG && !hasG2)
|
|
5591
5610
|
outside = true;
|
|
@@ -5604,7 +5623,10 @@ const CarQuoteDataHandler = () => {
|
|
|
5604
5623
|
delete driver.birthYear;
|
|
5605
5624
|
delete driver.birthMonth;
|
|
5606
5625
|
delete driver.birthDay;
|
|
5607
|
-
|
|
5626
|
+
const licenceConfigEntry = configState.licenceConfig[driver.licenceInfo.licenceType];
|
|
5627
|
+
if (licenceConfigEntry) {
|
|
5628
|
+
driver.licenceInfo.licenceType = licenceConfigEntry.id;
|
|
5629
|
+
}
|
|
5608
5630
|
if (driver.minMaxDates) {
|
|
5609
5631
|
delete driver.minMaxDates;
|
|
5610
5632
|
}
|
|
@@ -5615,8 +5637,8 @@ const CarQuoteDataHandler = () => {
|
|
|
5615
5637
|
else {
|
|
5616
5638
|
driver.insuranceCancellationList = driver.insuranceCancellationList?.map((listItem) => ({
|
|
5617
5639
|
reason: listItem.cancellationReason,
|
|
5618
|
-
startDate: addDayToDate(`${listItem.startYear}-${listItem.startMonth}`,
|
|
5619
|
-
endDate: addDayToDate(`${listItem.endYear}-${listItem.endMonth}`,
|
|
5640
|
+
startDate: addDayToDate(`${listItem.startYear}-${listItem.startMonth}`, 1),
|
|
5641
|
+
endDate: addDayToDate(`${listItem.endYear}-${listItem.endMonth}`, 1),
|
|
5620
5642
|
}));
|
|
5621
5643
|
}
|
|
5622
5644
|
if (!driver.licenceSuspension) {
|
|
@@ -5625,8 +5647,8 @@ const CarQuoteDataHandler = () => {
|
|
|
5625
5647
|
else {
|
|
5626
5648
|
driver.licenceSuspensionList = driver.licenceSuspensionList?.map((listItem) => ({
|
|
5627
5649
|
reason: listItem.suspensionReason,
|
|
5628
|
-
reinstatementDate: addDayToDate(`${listItem.reinstatementYear}-${listItem.reinstatementMonth}`,
|
|
5629
|
-
suspensionDate: addDayToDate(`${listItem.suspensionYear}-${listItem.suspensionMonth}`,
|
|
5650
|
+
reinstatementDate: addDayToDate(`${listItem.reinstatementYear}-${listItem.reinstatementMonth}`, 1),
|
|
5651
|
+
suspensionDate: addDayToDate(`${listItem.suspensionYear}-${listItem.suspensionMonth}`, 1),
|
|
5630
5652
|
}));
|
|
5631
5653
|
}
|
|
5632
5654
|
if (!driver.accident) {
|
|
@@ -5634,7 +5656,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5634
5656
|
}
|
|
5635
5657
|
else {
|
|
5636
5658
|
driver.accidentList = driver.accidentList?.map((listItem) => ({
|
|
5637
|
-
accidentDate: addDayToDate(`${listItem.accidentYear}-${listItem.accidentMonth}`,
|
|
5659
|
+
accidentDate: addDayToDate(`${listItem.accidentYear}-${listItem.accidentMonth}`, 1),
|
|
5638
5660
|
}));
|
|
5639
5661
|
}
|
|
5640
5662
|
if (!driver.ticket) {
|
|
@@ -5643,7 +5665,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5643
5665
|
else {
|
|
5644
5666
|
driver.ticketList = driver.ticketList?.map((listItem) => ({
|
|
5645
5667
|
reason: listItem.ticketReason,
|
|
5646
|
-
ticketDate: addDayToDate(`${listItem.ticketYear}-${listItem.ticketMonth}`,
|
|
5668
|
+
ticketDate: addDayToDate(`${listItem.ticketYear}-${listItem.ticketMonth}`, 1),
|
|
5647
5669
|
}));
|
|
5648
5670
|
}
|
|
5649
5671
|
return driver;
|
|
@@ -5654,7 +5676,8 @@ const CarQuoteDataHandler = () => {
|
|
|
5654
5676
|
const vehicleCount = requestBody.vehicles.length;
|
|
5655
5677
|
const result = [];
|
|
5656
5678
|
for (let vehicleIndex = 0; vehicleIndex < vehicleCount; vehicleIndex++) {
|
|
5657
|
-
const
|
|
5679
|
+
const storedDriverIndex = requestBody.vehlinks[vehicleIndex]?.driverIndex ?? -1;
|
|
5680
|
+
const primaryDriverIndex = driverCount === 1 || storedDriverIndex < 0 ? 0 : storedDriverIndex;
|
|
5658
5681
|
// Primary driver for this vehicle
|
|
5659
5682
|
result.push({
|
|
5660
5683
|
driverIndex: Number(primaryDriverIndex + 1),
|
|
@@ -5675,7 +5698,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5675
5698
|
}
|
|
5676
5699
|
else {
|
|
5677
5700
|
// g-k) Use user-selected vehicle for extra drivers; skip if they are primary on another vehicle
|
|
5678
|
-
const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex
|
|
5701
|
+
const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex && l.vehicleIndex !== vehicleIndex);
|
|
5679
5702
|
if (isPrimaryElsewhere)
|
|
5680
5703
|
continue;
|
|
5681
5704
|
const occAssignment = discount.occVehlinks?.find((l) => l.driverIndex === driverIndex);
|
|
@@ -6353,7 +6376,8 @@ const useValidationVehicle = () => {
|
|
|
6353
6376
|
return item;
|
|
6354
6377
|
});
|
|
6355
6378
|
});
|
|
6356
|
-
|
|
6379
|
+
// MyChoice does not force AB review; the user can proceed without acknowledging.
|
|
6380
|
+
if (isAbReformActive && appConfigState.appType !== AppTypes.MyChoice) {
|
|
6357
6381
|
vehicleState.items.forEach((item) => {
|
|
6358
6382
|
if (!item.accidentbenefits.abAcknowledged) {
|
|
6359
6383
|
errors.push('abAcknowledged');
|
|
@@ -6403,6 +6427,7 @@ const useValidationVehicle = () => {
|
|
|
6403
6427
|
const useValidationDriver = () => {
|
|
6404
6428
|
const { driverState, dispatchDriverBaseState } = useStoreFormCarDriverBase();
|
|
6405
6429
|
const { discountState } = useStoreFormCarDiscount();
|
|
6430
|
+
const { configState } = useStoreFormCarConfig();
|
|
6406
6431
|
const { inValidation: driverFormIsInValidation = false, isValid: driverFormIsValid = false, } = driverState;
|
|
6407
6432
|
const { appConfigState } = useStoreAppConfig();
|
|
6408
6433
|
const { appType } = appConfigState;
|
|
@@ -6472,6 +6497,7 @@ const useValidationDriver = () => {
|
|
|
6472
6497
|
errors.push('policyStartDay');
|
|
6473
6498
|
}
|
|
6474
6499
|
}
|
|
6500
|
+
const isOntarioMyChoice = configState.code === OntarioCode && isMyChoiceLike(appType);
|
|
6475
6501
|
driverState.items.forEach((item, index) => {
|
|
6476
6502
|
Object.keys(item).forEach((key) => {
|
|
6477
6503
|
// checking errors in driverState
|
|
@@ -6492,7 +6518,15 @@ const useValidationDriver = () => {
|
|
|
6492
6518
|
if (key === 'licenceInfo') {
|
|
6493
6519
|
if (licenceInfoKeys.includes(objectKey) && !item[key][objectKey]) {
|
|
6494
6520
|
const { birthDay, birthMonth, birthYear } = item;
|
|
6495
|
-
if (
|
|
6521
|
+
if (isOntarioMyChoice) {
|
|
6522
|
+
// Ontario first-licence date lives in the G1 slot; firstLicenceAge is unused.
|
|
6523
|
+
if (objectKey === 'licenceType'
|
|
6524
|
+
|| objectKey === 'g1LicenceYear'
|
|
6525
|
+
|| objectKey === 'g1LicenceMonth') {
|
|
6526
|
+
errors.push(objectKey);
|
|
6527
|
+
}
|
|
6528
|
+
}
|
|
6529
|
+
else if (birthDay && birthMonth && birthYear && item[key].firstLicenceAge) {
|
|
6496
6530
|
errors.push(objectKey);
|
|
6497
6531
|
}
|
|
6498
6532
|
}
|
|
@@ -6516,6 +6550,27 @@ const useValidationDriver = () => {
|
|
|
6516
6550
|
});
|
|
6517
6551
|
}
|
|
6518
6552
|
});
|
|
6553
|
+
// Ontario MyChoice: validate licence dates when follow-up Yes answers require them.
|
|
6554
|
+
if (isOntarioMyChoice) {
|
|
6555
|
+
const { licenceType, g1LicenceYear, g1LicenceMonth, g2LicenceYear, g2LicenceMonth, gLicenceYear, gLicenceMonth, receivedG2, receivedG, } = item.licenceInfo;
|
|
6556
|
+
const q1Date = g1LicenceYear && g1LicenceMonth ? `${g1LicenceYear}-${g1LicenceMonth}-01` : '';
|
|
6557
|
+
const specialDate = configState.minDates?.g?.specialDate;
|
|
6558
|
+
const isOnlyG = !!q1Date && !!specialDate && compareDates(specialDate, q1Date) >= 0;
|
|
6559
|
+
const firstClass = isOnlyG ? DriverLicenceTypes.G : licenceType;
|
|
6560
|
+
if (firstClass === DriverLicenceTypes.G1 && receivedG2 === true) {
|
|
6561
|
+
if (!g2LicenceYear)
|
|
6562
|
+
errors.push('g2LicenceYear');
|
|
6563
|
+
if (!g2LicenceMonth)
|
|
6564
|
+
errors.push('g2LicenceMonth');
|
|
6565
|
+
}
|
|
6566
|
+
if ((firstClass === DriverLicenceTypes.G1 || firstClass === DriverLicenceTypes.G2)
|
|
6567
|
+
&& receivedG === true) {
|
|
6568
|
+
if (!gLicenceYear)
|
|
6569
|
+
errors.push('gLicenceYear');
|
|
6570
|
+
if (!gLicenceMonth)
|
|
6571
|
+
errors.push('gLicenceMonth');
|
|
6572
|
+
}
|
|
6573
|
+
}
|
|
6519
6574
|
});
|
|
6520
6575
|
if (!errors.length) {
|
|
6521
6576
|
dispatchDriverBaseState({
|
|
@@ -6556,6 +6611,8 @@ const useValidationDriver = () => {
|
|
|
6556
6611
|
|
|
6557
6612
|
const useValidationCarDiscount = () => {
|
|
6558
6613
|
const { discountState, dispatchDiscountState } = useStoreFormCarDiscount();
|
|
6614
|
+
const { vehicleState: { items: vehicles } } = useStoreFormCarVehicle();
|
|
6615
|
+
const { driverState: { items: drivers } } = useStoreFormCarDriverBase();
|
|
6559
6616
|
const { inValidation = false, isValid = false, } = discountState;
|
|
6560
6617
|
const { appConfigState } = useStoreAppConfig();
|
|
6561
6618
|
const { dispatchAppModalState } = useStoreAppModal();
|
|
@@ -6590,6 +6647,42 @@ const useValidationCarDiscount = () => {
|
|
|
6590
6647
|
if (discountState.quoterInfo.phoneStatus !== ValidationStatusTypes.Approved) {
|
|
6591
6648
|
errors.push('phone');
|
|
6592
6649
|
}
|
|
6650
|
+
if (drivers.length > 1) {
|
|
6651
|
+
// One primary-driver question per vehicle must be answered.
|
|
6652
|
+
vehicles.forEach((_vehicle, vehicleIndex) => {
|
|
6653
|
+
const primary = discountState.vehlinks.find((l) => l.vehicleIndex === vehicleIndex);
|
|
6654
|
+
if (!primary || primary.driverIndex < 0) {
|
|
6655
|
+
errors.push(`vehlink-${vehicleIndex}`);
|
|
6656
|
+
}
|
|
6657
|
+
});
|
|
6658
|
+
// When there are at least as many drivers as vehicles, every vehicle must have a distinct/unique primary.
|
|
6659
|
+
if (drivers.length >= vehicles.length) {
|
|
6660
|
+
const seenDrivers = new Set();
|
|
6661
|
+
vehicles.forEach((_vehicle, vehicleIndex) => {
|
|
6662
|
+
const primary = discountState.vehlinks.find((l) => l.vehicleIndex === vehicleIndex);
|
|
6663
|
+
if (primary && primary.driverIndex >= 0) {
|
|
6664
|
+
if (seenDrivers.has(primary.driverIndex)) {
|
|
6665
|
+
errors.push(`vehlink-${vehicleIndex}`);
|
|
6666
|
+
}
|
|
6667
|
+
seenDrivers.add(primary.driverIndex);
|
|
6668
|
+
}
|
|
6669
|
+
});
|
|
6670
|
+
}
|
|
6671
|
+
// When drivers outnumber vehicles AND there is more than one vehicle, each unassigned driver must pick a vehicle.
|
|
6672
|
+
if (drivers.length > vehicles.length && vehicles.length > 1) {
|
|
6673
|
+
const primaryDriverIndices = discountState.vehlinks
|
|
6674
|
+
.filter((l) => l.driverIndex >= 0)
|
|
6675
|
+
.map((l) => l.driverIndex);
|
|
6676
|
+
drivers.forEach((_driver, driverIndex) => {
|
|
6677
|
+
if (primaryDriverIndices.includes(driverIndex))
|
|
6678
|
+
return;
|
|
6679
|
+
const occ = discountState.occVehlinks.find((l) => l.driverIndex === driverIndex);
|
|
6680
|
+
if (!occ || occ.vehicleIndex < 0) {
|
|
6681
|
+
errors.push(`occ-vehlink-${driverIndex}`);
|
|
6682
|
+
}
|
|
6683
|
+
});
|
|
6684
|
+
}
|
|
6685
|
+
}
|
|
6593
6686
|
if (!errors.length) {
|
|
6594
6687
|
dispatchDiscountState({
|
|
6595
6688
|
type: StoreFormCarDiscountActionTypes.FormCarDiscountValidate,
|