@defra/fcp-sfd-frontend-engine 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +417 -382
- package/dist/index.js +417 -382
- package/package.json +1 -1
- package/src/mutations/business/update-business-details.js +11 -0
- package/src/mutations/mutations.js +18 -16
- package/src/mutations/personal/update-customer-details.js +4 -33
- package/src/services/business/build-business-fix-update-variables-service.js +81 -0
- package/src/services/initialise-fix-journey-service.js +1 -0
- package/src/services/services.js +11 -9
package/dist/index.js
CHANGED
|
@@ -1017,6 +1017,43 @@ var mappers = {
|
|
|
1017
1017
|
personalDetails: mapPersonalDetails
|
|
1018
1018
|
};
|
|
1019
1019
|
|
|
1020
|
+
// src/mutations/business/update-business-address.js
|
|
1021
|
+
var updateBusinessAddressMutation = `
|
|
1022
|
+
mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
|
|
1023
|
+
updateBusinessAddress(input: $input) {
|
|
1024
|
+
business {
|
|
1025
|
+
info {
|
|
1026
|
+
address {
|
|
1027
|
+
line1
|
|
1028
|
+
line2
|
|
1029
|
+
line3
|
|
1030
|
+
line4
|
|
1031
|
+
line5
|
|
1032
|
+
postalCode
|
|
1033
|
+
country
|
|
1034
|
+
city
|
|
1035
|
+
buildingNumberRange
|
|
1036
|
+
buildingName
|
|
1037
|
+
flatName
|
|
1038
|
+
street
|
|
1039
|
+
county
|
|
1040
|
+
uprn
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
`;
|
|
1047
|
+
|
|
1048
|
+
// src/mutations/business/update-business-details.js
|
|
1049
|
+
var updateBusinessDetailsMutation = `
|
|
1050
|
+
mutation UpdateBusinessAllFields($input: UpdateBusinessAllFieldsInput!) {
|
|
1051
|
+
updateBusinessAllFields(input: $input) {
|
|
1052
|
+
success
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
`;
|
|
1056
|
+
|
|
1020
1057
|
// src/mutations/business/update-business-email.js
|
|
1021
1058
|
var updateBusinessEmailMutation = `
|
|
1022
1059
|
mutation UpdateBusinessEmail($input: UpdateBusinessEmailInput!) {
|
|
@@ -1033,6 +1070,23 @@ var updateBusinessEmailMutation = `
|
|
|
1033
1070
|
}
|
|
1034
1071
|
`;
|
|
1035
1072
|
|
|
1073
|
+
// src/mutations/business/update-business-legal-status.js
|
|
1074
|
+
var updateBusinessLegalStatusMutation = `
|
|
1075
|
+
mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
|
|
1076
|
+
updateBusinessLegalStatus(input: $input) {
|
|
1077
|
+
business {
|
|
1078
|
+
info {
|
|
1079
|
+
legalStatus {
|
|
1080
|
+
code
|
|
1081
|
+
type
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
success
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
`;
|
|
1089
|
+
|
|
1036
1090
|
// src/mutations/business/update-business-name.js
|
|
1037
1091
|
var updateBusinessNameMutation = `
|
|
1038
1092
|
mutation UpdateBusinessName($input: UpdateBusinessNameInput!) {
|
|
@@ -1063,65 +1117,35 @@ var updateBusinessPhoneNumbersMutation = `
|
|
|
1063
1117
|
}
|
|
1064
1118
|
`;
|
|
1065
1119
|
|
|
1066
|
-
// src/mutations/
|
|
1067
|
-
var
|
|
1068
|
-
mutation
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
info {
|
|
1072
|
-
name {
|
|
1073
|
-
first
|
|
1074
|
-
last
|
|
1075
|
-
middle
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
`;
|
|
1082
|
-
|
|
1083
|
-
// src/mutations/personal/update-customer-dob.js
|
|
1084
|
-
var updateCustomerDobMutation = `
|
|
1085
|
-
mutation UpdateCustomerDateOfBirth($input: UpdateCustomerDateOfBirthInput!) {
|
|
1086
|
-
updateCustomerDateOfBirth(input: $input) {
|
|
1087
|
-
customer {
|
|
1088
|
-
info {
|
|
1089
|
-
dateOfBirth
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
`;
|
|
1095
|
-
|
|
1096
|
-
// src/mutations/personal/update-customer-phone.js
|
|
1097
|
-
var updateCustomerPhoneMutation = `
|
|
1098
|
-
mutation UpdateCustomerPhone($input: UpdateCustomerPhoneInput!) {
|
|
1099
|
-
updateCustomerPhone(input: $input) {
|
|
1100
|
-
customer {
|
|
1120
|
+
// src/mutations/business/update-business-registration-numbers.js
|
|
1121
|
+
var updateBusinessRegistrationNumbersMutation = `
|
|
1122
|
+
mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
|
|
1123
|
+
updateBusinessRegistrationNumbers(input: $input) {
|
|
1124
|
+
business {
|
|
1101
1125
|
info {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1126
|
+
registrationNumbers {
|
|
1127
|
+
companiesHouse
|
|
1128
|
+
charityCommission
|
|
1105
1129
|
}
|
|
1106
1130
|
}
|
|
1107
1131
|
}
|
|
1132
|
+
success
|
|
1108
1133
|
}
|
|
1109
1134
|
}
|
|
1110
1135
|
`;
|
|
1111
1136
|
|
|
1112
|
-
// src/mutations/
|
|
1113
|
-
var
|
|
1114
|
-
mutation
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
address
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1137
|
+
// src/mutations/business/update-business-vat.js
|
|
1138
|
+
var updateBusinessVatMutation = `
|
|
1139
|
+
mutation UpdateBusinessVAT($input: UpdateBusinessVATInput!) {
|
|
1140
|
+
updateBusinessVAT(input: $input) {
|
|
1141
|
+
business {
|
|
1142
|
+
info {
|
|
1143
|
+
vat
|
|
1122
1144
|
}
|
|
1123
1145
|
}
|
|
1146
|
+
success
|
|
1124
1147
|
}
|
|
1148
|
+
}
|
|
1125
1149
|
`;
|
|
1126
1150
|
|
|
1127
1151
|
// src/mutations/personal/update-customer-address.js
|
|
@@ -1152,139 +1176,92 @@ var updateCustomerAddressMutation = `
|
|
|
1152
1176
|
}
|
|
1153
1177
|
`;
|
|
1154
1178
|
|
|
1155
|
-
// src/mutations/
|
|
1156
|
-
var
|
|
1157
|
-
mutation
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
info {
|
|
1161
|
-
address {
|
|
1162
|
-
line1
|
|
1163
|
-
line2
|
|
1164
|
-
line3
|
|
1165
|
-
line4
|
|
1166
|
-
line5
|
|
1167
|
-
postalCode
|
|
1168
|
-
country
|
|
1169
|
-
city
|
|
1170
|
-
buildingNumberRange
|
|
1171
|
-
buildingName
|
|
1172
|
-
flatName
|
|
1173
|
-
street
|
|
1174
|
-
county
|
|
1175
|
-
uprn
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
+
// src/mutations/personal/update-customer-details.js
|
|
1180
|
+
var updateCustomerDetailsMutation = `
|
|
1181
|
+
mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
|
|
1182
|
+
updateCustomerAllFields(input: $input) {
|
|
1183
|
+
success
|
|
1179
1184
|
}
|
|
1180
1185
|
}
|
|
1181
1186
|
`;
|
|
1182
1187
|
|
|
1183
|
-
// src/mutations/
|
|
1184
|
-
var
|
|
1185
|
-
mutation
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1188
|
+
// src/mutations/personal/update-customer-dob.js
|
|
1189
|
+
var updateCustomerDobMutation = `
|
|
1190
|
+
mutation UpdateCustomerDateOfBirth($input: UpdateCustomerDateOfBirthInput!) {
|
|
1191
|
+
updateCustomerDateOfBirth(input: $input) {
|
|
1192
|
+
customer {
|
|
1193
|
+
info {
|
|
1194
|
+
dateOfBirth
|
|
1195
|
+
}
|
|
1190
1196
|
}
|
|
1191
1197
|
}
|
|
1192
|
-
success
|
|
1193
1198
|
}
|
|
1194
|
-
}
|
|
1195
1199
|
`;
|
|
1196
1200
|
|
|
1197
|
-
// src/mutations/personal/update-customer-
|
|
1198
|
-
var
|
|
1199
|
-
mutation
|
|
1200
|
-
|
|
1201
|
-
success
|
|
1201
|
+
// src/mutations/personal/update-customer-email.js
|
|
1202
|
+
var updateCustomerEmailMutation = `
|
|
1203
|
+
mutation UpdateCustomerEmail($input: UpdateCustomerEmailInput!) {
|
|
1204
|
+
updateCustomerEmail(input: $input) {
|
|
1202
1205
|
customer {
|
|
1203
1206
|
info {
|
|
1204
|
-
name {
|
|
1205
|
-
first
|
|
1206
|
-
middle
|
|
1207
|
-
last
|
|
1208
|
-
}
|
|
1209
|
-
dateOfBirth
|
|
1210
|
-
phone {
|
|
1211
|
-
mobile
|
|
1212
|
-
landline
|
|
1213
|
-
}
|
|
1214
1207
|
email {
|
|
1215
1208
|
address
|
|
1216
1209
|
}
|
|
1217
|
-
address {
|
|
1218
|
-
line1
|
|
1219
|
-
line2
|
|
1220
|
-
line3
|
|
1221
|
-
line4
|
|
1222
|
-
line5
|
|
1223
|
-
buildingNumberRange
|
|
1224
|
-
buildingName
|
|
1225
|
-
flatName
|
|
1226
|
-
street
|
|
1227
|
-
city
|
|
1228
|
-
county
|
|
1229
|
-
postalCode
|
|
1230
|
-
country
|
|
1231
|
-
uprn
|
|
1232
|
-
}
|
|
1233
1210
|
}
|
|
1234
1211
|
}
|
|
1235
1212
|
}
|
|
1236
1213
|
}
|
|
1237
1214
|
`;
|
|
1238
1215
|
|
|
1239
|
-
// src/mutations/
|
|
1240
|
-
var
|
|
1241
|
-
mutation
|
|
1242
|
-
|
|
1243
|
-
|
|
1216
|
+
// src/mutations/personal/update-customer-name.js
|
|
1217
|
+
var updateCustomerNameMutation = `
|
|
1218
|
+
mutation UpdateCustomerName($input: UpdateCustomerNameInput!) {
|
|
1219
|
+
updateCustomerName(input: $input) {
|
|
1220
|
+
customer {
|
|
1244
1221
|
info {
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1222
|
+
name {
|
|
1223
|
+
first
|
|
1224
|
+
last
|
|
1225
|
+
middle
|
|
1248
1226
|
}
|
|
1249
1227
|
}
|
|
1250
1228
|
}
|
|
1251
|
-
success
|
|
1252
1229
|
}
|
|
1253
1230
|
}
|
|
1254
1231
|
`;
|
|
1255
1232
|
|
|
1256
|
-
// src/mutations/
|
|
1257
|
-
var
|
|
1258
|
-
mutation
|
|
1259
|
-
|
|
1260
|
-
|
|
1233
|
+
// src/mutations/personal/update-customer-phone.js
|
|
1234
|
+
var updateCustomerPhoneMutation = `
|
|
1235
|
+
mutation UpdateCustomerPhone($input: UpdateCustomerPhoneInput!) {
|
|
1236
|
+
updateCustomerPhone(input: $input) {
|
|
1237
|
+
customer {
|
|
1261
1238
|
info {
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1239
|
+
phone {
|
|
1240
|
+
landline
|
|
1241
|
+
mobile
|
|
1265
1242
|
}
|
|
1266
1243
|
}
|
|
1267
1244
|
}
|
|
1268
|
-
success
|
|
1269
1245
|
}
|
|
1270
1246
|
}
|
|
1271
1247
|
`;
|
|
1272
1248
|
|
|
1273
1249
|
// src/mutations/mutations.js
|
|
1274
1250
|
var mutations = {
|
|
1251
|
+
updateBusinessAddress: updateBusinessAddressMutation,
|
|
1252
|
+
updateBusinessDetails: updateBusinessDetailsMutation,
|
|
1275
1253
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
1254
|
+
updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
|
|
1276
1255
|
updateBusinessName: updateBusinessNameMutation,
|
|
1277
1256
|
updateBusinessPhoneNumbers: updateBusinessPhoneNumbersMutation,
|
|
1278
|
-
|
|
1279
|
-
updateCustomerName: updateCustomerNameMutation,
|
|
1280
|
-
updateCustomerDob: updateCustomerDobMutation,
|
|
1281
|
-
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
1282
|
-
updateCustomerEmail: updateCustomerEmailMutation,
|
|
1283
|
-
updateCustomerAddress: updateCustomerAddressMutation,
|
|
1257
|
+
updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation,
|
|
1284
1258
|
updateBusinessVat: updateBusinessVatMutation,
|
|
1259
|
+
updateCustomerAddress: updateCustomerAddressMutation,
|
|
1285
1260
|
updateCustomerDetails: updateCustomerDetailsMutation,
|
|
1286
|
-
|
|
1287
|
-
|
|
1261
|
+
updateCustomerDob: updateCustomerDobMutation,
|
|
1262
|
+
updateCustomerEmail: updateCustomerEmailMutation,
|
|
1263
|
+
updateCustomerName: updateCustomerNameMutation,
|
|
1264
|
+
updateCustomerPhone: updateCustomerPhoneMutation
|
|
1288
1265
|
};
|
|
1289
1266
|
|
|
1290
1267
|
// src/presenters/base-presenter.js
|
|
@@ -1526,18 +1503,259 @@ var presenters = {
|
|
|
1526
1503
|
addressChangeLink
|
|
1527
1504
|
};
|
|
1528
1505
|
|
|
1529
|
-
// src/services/
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1506
|
+
// src/services/build-address-variables-service.js
|
|
1507
|
+
var buildUprnAddress = (change) => {
|
|
1508
|
+
return {
|
|
1509
|
+
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
1510
|
+
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
1511
|
+
buildingName: nullIfUndefined(change.buildingName),
|
|
1512
|
+
flatName: nullIfUndefined(change.flatName),
|
|
1513
|
+
street: nullIfUndefined(change.street),
|
|
1514
|
+
city: nullIfUndefined(change.city),
|
|
1515
|
+
county: nullIfUndefined(change.county),
|
|
1516
|
+
postalCode: nullIfUndefined(change.postcode),
|
|
1517
|
+
country: nullIfUndefined(change.country),
|
|
1518
|
+
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
1519
|
+
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
1520
|
+
line1: null,
|
|
1521
|
+
line2: null,
|
|
1522
|
+
line3: null,
|
|
1523
|
+
line4: null,
|
|
1524
|
+
line5: null,
|
|
1525
|
+
uprn: change.uprn
|
|
1526
|
+
// required for DAL/v1
|
|
1527
|
+
};
|
|
1528
|
+
};
|
|
1529
|
+
var buildManualAddress = (change) => {
|
|
1530
|
+
return {
|
|
1531
|
+
pafOrganisationName: null,
|
|
1532
|
+
buildingNumberRange: null,
|
|
1533
|
+
buildingName: null,
|
|
1534
|
+
flatName: null,
|
|
1535
|
+
street: null,
|
|
1536
|
+
dependentLocality: null,
|
|
1537
|
+
doubleDependentLocality: null,
|
|
1538
|
+
county: null,
|
|
1539
|
+
uprn: null,
|
|
1540
|
+
line1: change.address1,
|
|
1541
|
+
// required for DAL/v1
|
|
1542
|
+
line2: nullIfUndefined(change.address2),
|
|
1543
|
+
line3: nullIfUndefined(change.address3),
|
|
1544
|
+
line4: nullIfUndefined(change.county),
|
|
1545
|
+
// manual county mapped for validation
|
|
1546
|
+
line5: null,
|
|
1547
|
+
city: change.city,
|
|
1548
|
+
// required for DAL/v1
|
|
1549
|
+
postalCode: change.postcode,
|
|
1550
|
+
// required for DAL/v1
|
|
1551
|
+
country: change.country
|
|
1552
|
+
// required for DAL/v1
|
|
1553
|
+
};
|
|
1554
|
+
};
|
|
1555
|
+
var nullIfUndefined = (value) => {
|
|
1556
|
+
return value ?? null;
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
// src/services/build-fix-success-message-service.js
|
|
1560
|
+
var LABEL_MAPS = {
|
|
1561
|
+
personal: {
|
|
1562
|
+
name: "full name",
|
|
1563
|
+
email: "personal email address",
|
|
1564
|
+
phone: "personal phone numbers",
|
|
1565
|
+
dob: "date of birth",
|
|
1566
|
+
address: "personal address"
|
|
1567
|
+
},
|
|
1568
|
+
business: {
|
|
1569
|
+
name: "business name",
|
|
1570
|
+
email: "business email address",
|
|
1571
|
+
phone: "business phone numbers",
|
|
1572
|
+
vat: "business vat number",
|
|
1573
|
+
address: "business address"
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
var PROPERTY_MAPS = {
|
|
1577
|
+
personal: {
|
|
1578
|
+
name: "changePersonalName",
|
|
1579
|
+
email: "changePersonalEmail",
|
|
1580
|
+
phone: "changePersonalPhoneNumbers",
|
|
1581
|
+
dob: "changePersonalDob",
|
|
1582
|
+
address: "changePersonalAddress"
|
|
1583
|
+
},
|
|
1584
|
+
business: {
|
|
1585
|
+
name: "changeBusinessName",
|
|
1586
|
+
email: "changeBusinessEmail",
|
|
1587
|
+
phone: "changeBusinessPhoneNumbers",
|
|
1588
|
+
vat: "changeBusinessVat",
|
|
1589
|
+
address: "changeBusinessAddress"
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
var buildFixSuccessMessageService = (type, details) => {
|
|
1593
|
+
const { orderedSectionsToFix } = details;
|
|
1594
|
+
const changes = loopThroughSections(type, details, orderedSectionsToFix);
|
|
1595
|
+
if (changes.length === 0) {
|
|
1596
|
+
return null;
|
|
1597
|
+
}
|
|
1598
|
+
if (changes.length === 1) {
|
|
1599
|
+
return {
|
|
1600
|
+
type: "text",
|
|
1601
|
+
value: `You have updated your ${changes[0]}`
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1604
|
+
return {
|
|
1605
|
+
type: "html",
|
|
1606
|
+
value: `
|
|
1607
|
+
<h3 class="govuk-notification-banner__heading">
|
|
1608
|
+
You have updated your:
|
|
1609
|
+
</h3>
|
|
1610
|
+
<ul class="govuk-list govuk-list--bullet">
|
|
1611
|
+
${changes.map((change) => `<li>${change}</li>`).join("")}
|
|
1612
|
+
</ul>
|
|
1613
|
+
`
|
|
1614
|
+
};
|
|
1615
|
+
};
|
|
1616
|
+
var loopThroughSections = (type, details, orderedSectionsToFix) => {
|
|
1617
|
+
const changes = [];
|
|
1618
|
+
const labelMap = LABEL_MAPS[type];
|
|
1619
|
+
const propertyMap = PROPERTY_MAPS[type];
|
|
1620
|
+
for (const section of orderedSectionsToFix) {
|
|
1621
|
+
if (details[propertyMap[section]]) {
|
|
1622
|
+
changes.push(labelMap[section]);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
return changes;
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
// src/services/business/build-business-fix-update-variables-service.js
|
|
1629
|
+
var buildBusinessFixUpdateVariablesService = (businessDetails) => {
|
|
1630
|
+
const { orderedSectionsToFix, sbi } = businessDetails;
|
|
1631
|
+
const input = { sbi };
|
|
1632
|
+
for (const applySection of sectionAppliers) {
|
|
1633
|
+
applySection(input, businessDetails, orderedSectionsToFix);
|
|
1634
|
+
}
|
|
1635
|
+
return { input };
|
|
1636
|
+
};
|
|
1637
|
+
var applyAddressSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1638
|
+
if (orderedSectionsToFix.includes("address") && businessDetails.changeBusinessAddress) {
|
|
1639
|
+
input.address = { withoutUprn: buildManualAddress(businessDetails.changeBusinessAddress) };
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
var applyEmailSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1643
|
+
if (orderedSectionsToFix.includes("email") && businessDetails.changeBusinessEmail) {
|
|
1644
|
+
Object.assign(input, buildEmailInput(businessDetails.changeBusinessEmail));
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
var applyNameSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1648
|
+
if (orderedSectionsToFix.includes("name") && businessDetails.changeBusinessName) {
|
|
1649
|
+
input.name = businessDetails.changeBusinessName.businessName;
|
|
1650
|
+
}
|
|
1651
|
+
};
|
|
1652
|
+
var applyPhoneSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1653
|
+
if (orderedSectionsToFix.includes("phone") && businessDetails.changeBusinessPhoneNumbers) {
|
|
1654
|
+
Object.assign(input, buildPhoneInput(businessDetails.changeBusinessPhoneNumbers));
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
var applyVatSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
1658
|
+
if (orderedSectionsToFix.includes("vat") && businessDetails.changeBusinessVat) {
|
|
1659
|
+
input.vat = businessDetails.changeBusinessVat.vatNumber ?? "";
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
var sectionAppliers = [
|
|
1663
|
+
applyAddressSection,
|
|
1664
|
+
applyEmailSection,
|
|
1665
|
+
applyNameSection,
|
|
1666
|
+
applyPhoneSection,
|
|
1667
|
+
applyVatSection
|
|
1668
|
+
];
|
|
1669
|
+
var buildEmailInput = (change) => {
|
|
1670
|
+
return {
|
|
1671
|
+
email: {
|
|
1672
|
+
address: change.businessEmail
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
};
|
|
1676
|
+
var buildPhoneInput = (change) => {
|
|
1677
|
+
return {
|
|
1678
|
+
phone: {
|
|
1679
|
+
landline: change.businessTelephone ?? null,
|
|
1680
|
+
mobile: change.businessMobile ?? null
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
// src/services/check-interrupter-journey-session-service.js
|
|
1686
|
+
var checkInterrupterJourneySessionService = (yar, journeyKey) => {
|
|
1687
|
+
const sessionData = yar.get(journeyKey);
|
|
1688
|
+
if (!sessionData) {
|
|
1689
|
+
return false;
|
|
1690
|
+
}
|
|
1691
|
+
if (Array.isArray(sessionData.orderedSectionsToFix)) {
|
|
1692
|
+
return true;
|
|
1693
|
+
}
|
|
1694
|
+
return false;
|
|
1695
|
+
};
|
|
1696
|
+
|
|
1697
|
+
// src/services/initialise-fix-journey-service.js
|
|
1698
|
+
var initialiseFixJourneyService = (yar, source, journeyType) => {
|
|
1699
|
+
let sessionKey;
|
|
1700
|
+
let sectionOrder = [];
|
|
1701
|
+
if (journeyType === "business") {
|
|
1702
|
+
sessionKey = "businessDetailsValidation";
|
|
1703
|
+
sectionOrder = BUSINESS_SECTION_ORDER;
|
|
1704
|
+
}
|
|
1705
|
+
if (journeyType === "personal") {
|
|
1706
|
+
sessionKey = "personalDetailsValidation";
|
|
1707
|
+
sectionOrder = PERSONAL_SECTION_ORDER;
|
|
1708
|
+
}
|
|
1709
|
+
const sessionData = yar.get(sessionKey);
|
|
1710
|
+
if (!(sessionData == null ? void 0 : sessionData.sectionsNeedingUpdate)) {
|
|
1711
|
+
return sessionData;
|
|
1712
|
+
}
|
|
1713
|
+
const orderedSectionsToFix = orderSectionsToFix(
|
|
1714
|
+
sessionData.sectionsNeedingUpdate,
|
|
1715
|
+
source,
|
|
1716
|
+
sectionOrder
|
|
1717
|
+
);
|
|
1718
|
+
updateSessionData(sessionData, source, orderedSectionsToFix);
|
|
1719
|
+
yar.set(sessionKey, sessionData);
|
|
1720
|
+
return sessionData;
|
|
1721
|
+
};
|
|
1722
|
+
var updateSessionData = (sessionData, source, orderedSectionsToFix) => {
|
|
1723
|
+
sessionData.orderedSectionsToFix = orderedSectionsToFix;
|
|
1724
|
+
delete sessionData.sectionsNeedingUpdate;
|
|
1725
|
+
delete sessionData.personalFixUpdates;
|
|
1726
|
+
delete sessionData.businessFixUpdates;
|
|
1727
|
+
if (source) {
|
|
1728
|
+
sessionData.source = source;
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
var orderSectionsToFix = (sectionsNeedingUpdate, source, SECTION_ORDER) => {
|
|
1732
|
+
const sections = SECTION_ORDER.filter((section) => {
|
|
1733
|
+
return sectionsNeedingUpdate.includes(section);
|
|
1734
|
+
});
|
|
1735
|
+
if (!source) {
|
|
1736
|
+
return sections;
|
|
1737
|
+
}
|
|
1738
|
+
if (!SECTION_ORDER.includes(source)) {
|
|
1739
|
+
return sections;
|
|
1740
|
+
}
|
|
1741
|
+
return [
|
|
1742
|
+
source,
|
|
1743
|
+
...sections.filter((section) => section !== source)
|
|
1744
|
+
];
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
// src/services/os-places/address-lookup-service.js
|
|
1748
|
+
import { placesAPI } from "osdatahub";
|
|
1749
|
+
|
|
1750
|
+
// src/mock-data/mock-os-places-addresses.js
|
|
1751
|
+
var mockAddresses = [
|
|
1752
|
+
{
|
|
1753
|
+
properties: {
|
|
1754
|
+
UPRN: "10000001",
|
|
1755
|
+
ADDRESS: "APARTMENT 1, REDBRIDGE HOUSE, 1 ROSE COURT, LONDON, SW1A 1AA",
|
|
1756
|
+
SUB_BUILDING_NAME: "APARTMENT 1",
|
|
1757
|
+
BUILDING_NAME: "REDBRIDGE HOUSE",
|
|
1758
|
+
BUILDING_NUMBER: "1",
|
|
1541
1759
|
THOROUGHFARE_NAME: "ROSE COURT",
|
|
1542
1760
|
POST_TOWN: "LONDON",
|
|
1543
1761
|
POSTCODE: "SW1A 1AA",
|
|
@@ -1768,230 +1986,6 @@ var isRetryable = (error) => {
|
|
|
1768
1986
|
return false;
|
|
1769
1987
|
};
|
|
1770
1988
|
|
|
1771
|
-
// src/services/build-address-variables-service.js
|
|
1772
|
-
var buildUprnAddress = (change) => {
|
|
1773
|
-
return {
|
|
1774
|
-
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
1775
|
-
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
1776
|
-
buildingName: nullIfUndefined(change.buildingName),
|
|
1777
|
-
flatName: nullIfUndefined(change.flatName),
|
|
1778
|
-
street: nullIfUndefined(change.street),
|
|
1779
|
-
city: nullIfUndefined(change.city),
|
|
1780
|
-
county: nullIfUndefined(change.county),
|
|
1781
|
-
postalCode: nullIfUndefined(change.postcode),
|
|
1782
|
-
country: nullIfUndefined(change.country),
|
|
1783
|
-
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
1784
|
-
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
1785
|
-
line1: null,
|
|
1786
|
-
line2: null,
|
|
1787
|
-
line3: null,
|
|
1788
|
-
line4: null,
|
|
1789
|
-
line5: null,
|
|
1790
|
-
uprn: change.uprn
|
|
1791
|
-
// required for DAL/v1
|
|
1792
|
-
};
|
|
1793
|
-
};
|
|
1794
|
-
var buildManualAddress = (change) => {
|
|
1795
|
-
return {
|
|
1796
|
-
pafOrganisationName: null,
|
|
1797
|
-
buildingNumberRange: null,
|
|
1798
|
-
buildingName: null,
|
|
1799
|
-
flatName: null,
|
|
1800
|
-
street: null,
|
|
1801
|
-
dependentLocality: null,
|
|
1802
|
-
doubleDependentLocality: null,
|
|
1803
|
-
county: null,
|
|
1804
|
-
uprn: null,
|
|
1805
|
-
line1: change.address1,
|
|
1806
|
-
// required for DAL/v1
|
|
1807
|
-
line2: nullIfUndefined(change.address2),
|
|
1808
|
-
line3: nullIfUndefined(change.address3),
|
|
1809
|
-
line4: nullIfUndefined(change.county),
|
|
1810
|
-
// manual county mapped for validation
|
|
1811
|
-
line5: null,
|
|
1812
|
-
city: change.city,
|
|
1813
|
-
// required for DAL/v1
|
|
1814
|
-
postalCode: change.postcode,
|
|
1815
|
-
// required for DAL/v1
|
|
1816
|
-
country: change.country
|
|
1817
|
-
// required for DAL/v1
|
|
1818
|
-
};
|
|
1819
|
-
};
|
|
1820
|
-
var nullIfUndefined = (value) => {
|
|
1821
|
-
return value ?? null;
|
|
1822
|
-
};
|
|
1823
|
-
|
|
1824
|
-
// src/services/check-interrupter-journey-session-service.js
|
|
1825
|
-
var checkInterrupterJourneySessionService = (yar, journeyKey) => {
|
|
1826
|
-
const sessionData = yar.get(journeyKey);
|
|
1827
|
-
if (!sessionData) {
|
|
1828
|
-
return false;
|
|
1829
|
-
}
|
|
1830
|
-
if (Array.isArray(sessionData.orderedSectionsToFix)) {
|
|
1831
|
-
return true;
|
|
1832
|
-
}
|
|
1833
|
-
return false;
|
|
1834
|
-
};
|
|
1835
|
-
|
|
1836
|
-
// src/services/initialise-fix-journey-service.js
|
|
1837
|
-
var initialiseFixJourneyService = (yar, source, journeyType) => {
|
|
1838
|
-
let sessionKey;
|
|
1839
|
-
let sectionOrder = [];
|
|
1840
|
-
if (journeyType === "business") {
|
|
1841
|
-
sessionKey = "businessDetailsValidation";
|
|
1842
|
-
sectionOrder = BUSINESS_SECTION_ORDER;
|
|
1843
|
-
}
|
|
1844
|
-
if (journeyType === "personal") {
|
|
1845
|
-
sessionKey = "personalDetailsValidation";
|
|
1846
|
-
sectionOrder = PERSONAL_SECTION_ORDER;
|
|
1847
|
-
}
|
|
1848
|
-
const sessionData = yar.get(sessionKey);
|
|
1849
|
-
if (!(sessionData == null ? void 0 : sessionData.sectionsNeedingUpdate)) {
|
|
1850
|
-
return sessionData;
|
|
1851
|
-
}
|
|
1852
|
-
const orderedSectionsToFix = orderSectionsToFix(
|
|
1853
|
-
sessionData.sectionsNeedingUpdate,
|
|
1854
|
-
source,
|
|
1855
|
-
sectionOrder
|
|
1856
|
-
);
|
|
1857
|
-
updateSessionData(sessionData, source, orderedSectionsToFix);
|
|
1858
|
-
yar.set(sessionKey, sessionData);
|
|
1859
|
-
return sessionData;
|
|
1860
|
-
};
|
|
1861
|
-
var updateSessionData = (sessionData, source, orderedSectionsToFix) => {
|
|
1862
|
-
sessionData.orderedSectionsToFix = orderedSectionsToFix;
|
|
1863
|
-
delete sessionData.sectionsNeedingUpdate;
|
|
1864
|
-
delete sessionData.personalFixUpdates;
|
|
1865
|
-
delete sessionData.businessFixUpdates;
|
|
1866
|
-
if (source) {
|
|
1867
|
-
sessionData.source = source;
|
|
1868
|
-
}
|
|
1869
|
-
};
|
|
1870
|
-
var orderSectionsToFix = (sectionsNeedingUpdate, source, SECTION_ORDER) => {
|
|
1871
|
-
const sections = SECTION_ORDER.filter((section) => {
|
|
1872
|
-
return sectionsNeedingUpdate.includes(section);
|
|
1873
|
-
});
|
|
1874
|
-
if (!source) {
|
|
1875
|
-
return sections;
|
|
1876
|
-
}
|
|
1877
|
-
if (!SECTION_ORDER.includes(source)) {
|
|
1878
|
-
return sections;
|
|
1879
|
-
}
|
|
1880
|
-
return [
|
|
1881
|
-
source,
|
|
1882
|
-
...sections.filter((section) => section !== source)
|
|
1883
|
-
];
|
|
1884
|
-
};
|
|
1885
|
-
|
|
1886
|
-
// src/services/validate-fix-details-service.js
|
|
1887
|
-
var validateFixDetailsService = (payload, orderedSectionsToFix, schemas2) => {
|
|
1888
|
-
const errors = [];
|
|
1889
|
-
for (const section of orderedSectionsToFix) {
|
|
1890
|
-
const schema = schemas2[section];
|
|
1891
|
-
const result = schema.validate(payload, {
|
|
1892
|
-
abortEarly: false,
|
|
1893
|
-
allowUnknown: true
|
|
1894
|
-
});
|
|
1895
|
-
if (result.error) {
|
|
1896
|
-
errors.push(...result.error.details);
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
if (errors.length > 0) {
|
|
1900
|
-
return {
|
|
1901
|
-
error: {
|
|
1902
|
-
details: errors
|
|
1903
|
-
}
|
|
1904
|
-
};
|
|
1905
|
-
}
|
|
1906
|
-
return { value: payload };
|
|
1907
|
-
};
|
|
1908
|
-
|
|
1909
|
-
// src/services/set-fix-session-data-service.js
|
|
1910
|
-
var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey) => {
|
|
1911
|
-
const orderedSectionsToFix = sessionData.orderedSectionsToFix;
|
|
1912
|
-
const type = journeyKey === "businessDetailsValidation" ? "business" : "personal";
|
|
1913
|
-
const SECTION_FIELD_ORDER = type === "business" ? BUSINESS_SECTION_FIELD_ORDER : PERSONAL_SECTION_FIELD_ORDER;
|
|
1914
|
-
const fixUpdates = {};
|
|
1915
|
-
for (const section of orderedSectionsToFix) {
|
|
1916
|
-
const fields = SECTION_FIELD_ORDER[section];
|
|
1917
|
-
fixUpdates[section] = {};
|
|
1918
|
-
for (const field of fields) {
|
|
1919
|
-
fixUpdates[section][field] = payload[field] ?? "";
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
sessionData[updateKey] = fixUpdates;
|
|
1923
|
-
yar.set(journeyKey, sessionData);
|
|
1924
|
-
};
|
|
1925
|
-
|
|
1926
|
-
// src/services/build-fix-success-message-service.js
|
|
1927
|
-
var LABEL_MAPS = {
|
|
1928
|
-
personal: {
|
|
1929
|
-
name: "full name",
|
|
1930
|
-
email: "personal email address",
|
|
1931
|
-
phone: "personal phone numbers",
|
|
1932
|
-
dob: "date of birth",
|
|
1933
|
-
address: "personal address"
|
|
1934
|
-
},
|
|
1935
|
-
business: {
|
|
1936
|
-
name: "business name",
|
|
1937
|
-
email: "business email address",
|
|
1938
|
-
phone: "business phone numbers",
|
|
1939
|
-
vat: "business vat number",
|
|
1940
|
-
address: "business address"
|
|
1941
|
-
}
|
|
1942
|
-
};
|
|
1943
|
-
var PROPERTY_MAPS = {
|
|
1944
|
-
personal: {
|
|
1945
|
-
name: "changePersonalName",
|
|
1946
|
-
email: "changePersonalEmail",
|
|
1947
|
-
phone: "changePersonalPhoneNumbers",
|
|
1948
|
-
dob: "changePersonalDob",
|
|
1949
|
-
address: "changePersonalAddress"
|
|
1950
|
-
},
|
|
1951
|
-
business: {
|
|
1952
|
-
name: "changeBusinessName",
|
|
1953
|
-
email: "changeBusinessEmail",
|
|
1954
|
-
phone: "changeBusinessPhoneNumbers",
|
|
1955
|
-
vat: "changeBusinessVat",
|
|
1956
|
-
address: "changeBusinessAddress"
|
|
1957
|
-
}
|
|
1958
|
-
};
|
|
1959
|
-
var buildFixSuccessMessageService = (type, details) => {
|
|
1960
|
-
const { orderedSectionsToFix } = details;
|
|
1961
|
-
const changes = loopThroughSections(type, details, orderedSectionsToFix);
|
|
1962
|
-
if (changes.length === 0) {
|
|
1963
|
-
return null;
|
|
1964
|
-
}
|
|
1965
|
-
if (changes.length === 1) {
|
|
1966
|
-
return {
|
|
1967
|
-
type: "text",
|
|
1968
|
-
value: `You have updated your ${changes[0]}`
|
|
1969
|
-
};
|
|
1970
|
-
}
|
|
1971
|
-
return {
|
|
1972
|
-
type: "html",
|
|
1973
|
-
value: `
|
|
1974
|
-
<h3 class="govuk-notification-banner__heading">
|
|
1975
|
-
You have updated your:
|
|
1976
|
-
</h3>
|
|
1977
|
-
<ul class="govuk-list govuk-list--bullet">
|
|
1978
|
-
${changes.map((change) => `<li>${change}</li>`).join("")}
|
|
1979
|
-
</ul>
|
|
1980
|
-
`
|
|
1981
|
-
};
|
|
1982
|
-
};
|
|
1983
|
-
var loopThroughSections = (type, details, orderedSectionsToFix) => {
|
|
1984
|
-
const changes = [];
|
|
1985
|
-
const labelMap = LABEL_MAPS[type];
|
|
1986
|
-
const propertyMap = PROPERTY_MAPS[type];
|
|
1987
|
-
for (const section of orderedSectionsToFix) {
|
|
1988
|
-
if (details[propertyMap[section]]) {
|
|
1989
|
-
changes.push(labelMap[section]);
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
return changes;
|
|
1993
|
-
};
|
|
1994
|
-
|
|
1995
1989
|
// src/services/personal/build-customer-fix-update-variables-service.js
|
|
1996
1990
|
var buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
1997
1991
|
const { orderedSectionsToFix, crn } = personalDetails;
|
|
@@ -2000,10 +1994,10 @@ var buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
|
2000
1994
|
Object.assign(input, buildNameInput(personalDetails.changePersonalName));
|
|
2001
1995
|
}
|
|
2002
1996
|
if (orderedSectionsToFix.includes("email") && personalDetails.changePersonalEmail) {
|
|
2003
|
-
Object.assign(input,
|
|
1997
|
+
Object.assign(input, buildEmailInput2(personalDetails.changePersonalEmail));
|
|
2004
1998
|
}
|
|
2005
1999
|
if (orderedSectionsToFix.includes("phone") && personalDetails.changePersonalPhoneNumbers) {
|
|
2006
|
-
Object.assign(input,
|
|
2000
|
+
Object.assign(input, buildPhoneInput2(personalDetails.changePersonalPhoneNumbers));
|
|
2007
2001
|
}
|
|
2008
2002
|
if (orderedSectionsToFix.includes("dob") && personalDetails.changePersonalDob) {
|
|
2009
2003
|
Object.assign(input, buildDobInput(personalDetails.changePersonalDob));
|
|
@@ -2013,7 +2007,7 @@ var buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
|
2013
2007
|
}
|
|
2014
2008
|
return { input };
|
|
2015
2009
|
};
|
|
2016
|
-
var
|
|
2010
|
+
var buildPhoneInput2 = (change) => {
|
|
2017
2011
|
return {
|
|
2018
2012
|
phone: {
|
|
2019
2013
|
landline: change.personalTelephone ?? null,
|
|
@@ -2021,7 +2015,7 @@ var buildPhoneInput = (change) => {
|
|
|
2021
2015
|
}
|
|
2022
2016
|
};
|
|
2023
2017
|
};
|
|
2024
|
-
var
|
|
2018
|
+
var buildEmailInput2 = (change) => {
|
|
2025
2019
|
return {
|
|
2026
2020
|
email: {
|
|
2027
2021
|
address: change.personalEmail
|
|
@@ -2043,17 +2037,58 @@ var buildDobInput = (change) => {
|
|
|
2043
2037
|
};
|
|
2044
2038
|
};
|
|
2045
2039
|
|
|
2040
|
+
// src/services/set-fix-session-data-service.js
|
|
2041
|
+
var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey) => {
|
|
2042
|
+
const orderedSectionsToFix = sessionData.orderedSectionsToFix;
|
|
2043
|
+
const type = journeyKey === "businessDetailsValidation" ? "business" : "personal";
|
|
2044
|
+
const SECTION_FIELD_ORDER = type === "business" ? BUSINESS_SECTION_FIELD_ORDER : PERSONAL_SECTION_FIELD_ORDER;
|
|
2045
|
+
const fixUpdates = {};
|
|
2046
|
+
for (const section of orderedSectionsToFix) {
|
|
2047
|
+
const fields = SECTION_FIELD_ORDER[section];
|
|
2048
|
+
fixUpdates[section] = {};
|
|
2049
|
+
for (const field of fields) {
|
|
2050
|
+
fixUpdates[section][field] = payload[field] ?? "";
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
sessionData[updateKey] = fixUpdates;
|
|
2054
|
+
yar.set(journeyKey, sessionData);
|
|
2055
|
+
};
|
|
2056
|
+
|
|
2057
|
+
// src/services/validate-fix-details-service.js
|
|
2058
|
+
var validateFixDetailsService = (payload, orderedSectionsToFix, schemas2) => {
|
|
2059
|
+
const errors = [];
|
|
2060
|
+
for (const section of orderedSectionsToFix) {
|
|
2061
|
+
const schema = schemas2[section];
|
|
2062
|
+
const result = schema.validate(payload, {
|
|
2063
|
+
abortEarly: false,
|
|
2064
|
+
allowUnknown: true
|
|
2065
|
+
});
|
|
2066
|
+
if (result.error) {
|
|
2067
|
+
errors.push(...result.error.details);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
if (errors.length > 0) {
|
|
2071
|
+
return {
|
|
2072
|
+
error: {
|
|
2073
|
+
details: errors
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
return { value: payload };
|
|
2078
|
+
};
|
|
2079
|
+
|
|
2046
2080
|
// src/services/services.js
|
|
2047
2081
|
var services = {
|
|
2048
2082
|
addressLookup: addressLookupService,
|
|
2049
|
-
|
|
2083
|
+
buildBusinessFixUpdateVariables: buildBusinessFixUpdateVariablesService,
|
|
2084
|
+
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService,
|
|
2085
|
+
buildFixSuccessMessage: buildFixSuccessMessageService,
|
|
2050
2086
|
buildManualAddress,
|
|
2087
|
+
buildUprnAddress,
|
|
2051
2088
|
checkInterrupterJourneySession: checkInterrupterJourneySessionService,
|
|
2052
2089
|
initialiseFixJourney: initialiseFixJourneyService,
|
|
2053
|
-
validateFixDetails: validateFixDetailsService,
|
|
2054
2090
|
setFixSessionData: setFixSessionDataService,
|
|
2055
|
-
|
|
2056
|
-
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService
|
|
2091
|
+
validateFixDetails: validateFixDetailsService
|
|
2057
2092
|
};
|
|
2058
2093
|
export {
|
|
2059
2094
|
constants,
|