@defra/fcp-sfd-frontend-engine 0.23.0 → 0.25.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 +197 -4
- package/dist/index.js +197 -4
- package/package.json +1 -1
- package/src/constants/index.js +4 -2
- package/src/constants/success-messages.js +1 -0
- package/src/mutations/business/update-business-vat.js +12 -0
- package/src/mutations/mutations.js +5 -1
- package/src/mutations/personal/update-customer-details.js +40 -0
- package/src/services/build-fix-success-message-service.js +95 -0
- package/src/services/personal/build-customer-fix-update-variables-service.js +76 -0
- package/src/services/services.js +5 -1
- package/src/utils/build-update-business-vat-variables.js +16 -0
- package/src/utils/utils.js +3 -1
package/dist/index.cjs
CHANGED
|
@@ -101,6 +101,7 @@ var MONTH_MAP = {
|
|
|
101
101
|
var BUSINESS_EMAIL_ADDRESS = "You have updated your business email address";
|
|
102
102
|
var BUSINESS_NAME = "You have updated your business name";
|
|
103
103
|
var BUSINESS_PHONE_NUMBERS = "You have updated your business phone numbers";
|
|
104
|
+
var BUSINESS_VAT = "You have updated your VAT registration number";
|
|
104
105
|
|
|
105
106
|
// src/constants/interrupter-journey.js
|
|
106
107
|
var PERSONAL_SECTION_FIELD_ORDER = {
|
|
@@ -184,7 +185,8 @@ var constants = {
|
|
|
184
185
|
successMessages: {
|
|
185
186
|
BUSINESS_EMAIL_ADDRESS,
|
|
186
187
|
BUSINESS_NAME,
|
|
187
|
-
BUSINESS_PHONE_NUMBERS
|
|
188
|
+
BUSINESS_PHONE_NUMBERS,
|
|
189
|
+
BUSINESS_VAT
|
|
188
190
|
},
|
|
189
191
|
interrupterJourney: {
|
|
190
192
|
PERSONAL_SECTION_FIELD_ORDER,
|
|
@@ -923,6 +925,62 @@ var updateBusinessAddressMutation = `
|
|
|
923
925
|
}
|
|
924
926
|
`;
|
|
925
927
|
|
|
928
|
+
// src/mutations/business/update-business-vat.js
|
|
929
|
+
var updateBusinessVatMutation = `
|
|
930
|
+
mutation UpdateBusinessVAT($input: UpdateBusinessVATInput!) {
|
|
931
|
+
updateBusinessVAT(input: $input) {
|
|
932
|
+
business {
|
|
933
|
+
info {
|
|
934
|
+
vat
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
success
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
`;
|
|
941
|
+
|
|
942
|
+
// src/mutations/personal/update-customer-details.js
|
|
943
|
+
var updateCustomerDetailsMutation = `
|
|
944
|
+
mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
|
|
945
|
+
updateCustomerAllFields(input: $input) {
|
|
946
|
+
success
|
|
947
|
+
customer {
|
|
948
|
+
info {
|
|
949
|
+
name {
|
|
950
|
+
first
|
|
951
|
+
middle
|
|
952
|
+
last
|
|
953
|
+
}
|
|
954
|
+
dateOfBirth
|
|
955
|
+
phone {
|
|
956
|
+
mobile
|
|
957
|
+
landline
|
|
958
|
+
}
|
|
959
|
+
email {
|
|
960
|
+
address
|
|
961
|
+
}
|
|
962
|
+
address {
|
|
963
|
+
line1
|
|
964
|
+
line2
|
|
965
|
+
line3
|
|
966
|
+
line4
|
|
967
|
+
line5
|
|
968
|
+
buildingNumberRange
|
|
969
|
+
buildingName
|
|
970
|
+
flatName
|
|
971
|
+
street
|
|
972
|
+
city
|
|
973
|
+
county
|
|
974
|
+
postalCode
|
|
975
|
+
country
|
|
976
|
+
uprn
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
`;
|
|
983
|
+
|
|
926
984
|
// src/mutations/mutations.js
|
|
927
985
|
var mutations = {
|
|
928
986
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
@@ -933,7 +991,9 @@ var mutations = {
|
|
|
933
991
|
updateCustomerDob: updateCustomerDobMutation,
|
|
934
992
|
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
935
993
|
updateCustomerEmail: updateCustomerEmailMutation,
|
|
936
|
-
updateCustomerAddress: updateCustomerAddressMutation
|
|
994
|
+
updateCustomerAddress: updateCustomerAddressMutation,
|
|
995
|
+
updateBusinessVat: updateBusinessVatMutation,
|
|
996
|
+
updateCustomerDetails: updateCustomerDetailsMutation
|
|
937
997
|
};
|
|
938
998
|
|
|
939
999
|
// src/presenters/base-presenter.js
|
|
@@ -1233,13 +1293,24 @@ var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobil
|
|
|
1233
1293
|
};
|
|
1234
1294
|
};
|
|
1235
1295
|
|
|
1296
|
+
// src/utils/build-update-business-vat-variables.js
|
|
1297
|
+
var buildUpdateBusinessVatVariables = (vat, sbi) => {
|
|
1298
|
+
return {
|
|
1299
|
+
input: {
|
|
1300
|
+
vat,
|
|
1301
|
+
sbi
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1236
1306
|
// src/utils/utils.js
|
|
1237
1307
|
var utils = {
|
|
1238
1308
|
formatFullName,
|
|
1239
1309
|
formatValidationErrors,
|
|
1240
1310
|
buildUpdateBusinessEmailVariables,
|
|
1241
1311
|
buildUpdateBusinessNameVariables,
|
|
1242
|
-
buildUpdateBusinessPhoneNumbersVariables
|
|
1312
|
+
buildUpdateBusinessPhoneNumbersVariables,
|
|
1313
|
+
buildUpdateBusinessVatVariables
|
|
1243
1314
|
};
|
|
1244
1315
|
|
|
1245
1316
|
// src/services/os-places/address-lookup-service.js
|
|
@@ -1639,6 +1710,126 @@ var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey
|
|
|
1639
1710
|
yar.set(journeyKey, sessionData);
|
|
1640
1711
|
};
|
|
1641
1712
|
|
|
1713
|
+
// src/services/build-fix-success-message-service.js
|
|
1714
|
+
var LABEL_MAPS = {
|
|
1715
|
+
personal: {
|
|
1716
|
+
name: "full name",
|
|
1717
|
+
email: "personal email address",
|
|
1718
|
+
phone: "personal phone numbers",
|
|
1719
|
+
dob: "date of birth",
|
|
1720
|
+
address: "personal address"
|
|
1721
|
+
},
|
|
1722
|
+
business: {
|
|
1723
|
+
name: "business name",
|
|
1724
|
+
email: "business email address",
|
|
1725
|
+
phone: "business phone numbers",
|
|
1726
|
+
vat: "business vat number",
|
|
1727
|
+
address: "business address"
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
var PROPERTY_MAPS = {
|
|
1731
|
+
personal: {
|
|
1732
|
+
name: "changePersonalName",
|
|
1733
|
+
email: "changePersonalEmail",
|
|
1734
|
+
phone: "changePersonalPhoneNumbers",
|
|
1735
|
+
dob: "changePersonalDob",
|
|
1736
|
+
address: "changePersonalAddress"
|
|
1737
|
+
},
|
|
1738
|
+
business: {
|
|
1739
|
+
name: "changeBusinessName",
|
|
1740
|
+
email: "changeBusinessEmail",
|
|
1741
|
+
phone: "changeBusinessPhoneNumbers",
|
|
1742
|
+
vat: "changeBusinessVat",
|
|
1743
|
+
address: "changeBusinessAddress"
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
var buildFixSuccessMessageService = (type, details) => {
|
|
1747
|
+
const { orderedSectionsToFix } = details;
|
|
1748
|
+
const changes = loopThroughSections(type, details, orderedSectionsToFix);
|
|
1749
|
+
if (changes.length === 0) {
|
|
1750
|
+
return null;
|
|
1751
|
+
}
|
|
1752
|
+
if (changes.length === 1) {
|
|
1753
|
+
return {
|
|
1754
|
+
type: "text",
|
|
1755
|
+
value: `You have updated your ${changes[0]}`
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
return {
|
|
1759
|
+
type: "html",
|
|
1760
|
+
value: `
|
|
1761
|
+
<h3 class="govuk-notification-banner__heading">
|
|
1762
|
+
You have updated your:
|
|
1763
|
+
</h3>
|
|
1764
|
+
<ul class="govuk-list govuk-list--bullet">
|
|
1765
|
+
${changes.map((change) => `<li>${change}</li>`).join("")}
|
|
1766
|
+
</ul>
|
|
1767
|
+
`
|
|
1768
|
+
};
|
|
1769
|
+
};
|
|
1770
|
+
var loopThroughSections = (type, details, orderedSectionsToFix) => {
|
|
1771
|
+
const changes = [];
|
|
1772
|
+
const labelMap = LABEL_MAPS[type];
|
|
1773
|
+
const propertyMap = PROPERTY_MAPS[type];
|
|
1774
|
+
for (const section of orderedSectionsToFix) {
|
|
1775
|
+
if (details[propertyMap[section]]) {
|
|
1776
|
+
changes.push(labelMap[section]);
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
return changes;
|
|
1780
|
+
};
|
|
1781
|
+
|
|
1782
|
+
// src/services/personal/build-customer-fix-update-variables-service.js
|
|
1783
|
+
var buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
1784
|
+
const { orderedSectionsToFix, crn } = personalDetails;
|
|
1785
|
+
const input = { crn };
|
|
1786
|
+
if (orderedSectionsToFix.includes("name") && personalDetails.changePersonalName) {
|
|
1787
|
+
Object.assign(input, buildNameInput(personalDetails.changePersonalName));
|
|
1788
|
+
}
|
|
1789
|
+
if (orderedSectionsToFix.includes("email") && personalDetails.changePersonalEmail) {
|
|
1790
|
+
Object.assign(input, buildEmailInput(personalDetails.changePersonalEmail));
|
|
1791
|
+
}
|
|
1792
|
+
if (orderedSectionsToFix.includes("phone") && personalDetails.changePersonalPhoneNumbers) {
|
|
1793
|
+
Object.assign(input, buildPhoneInput(personalDetails.changePersonalPhoneNumbers));
|
|
1794
|
+
}
|
|
1795
|
+
if (orderedSectionsToFix.includes("dob") && personalDetails.changePersonalDob) {
|
|
1796
|
+
Object.assign(input, buildDobInput(personalDetails.changePersonalDob));
|
|
1797
|
+
}
|
|
1798
|
+
if (orderedSectionsToFix.includes("address") && personalDetails.changePersonalAddress) {
|
|
1799
|
+
Object.assign(input, { address: buildManualAddress(personalDetails.changePersonalAddress) });
|
|
1800
|
+
}
|
|
1801
|
+
return { input };
|
|
1802
|
+
};
|
|
1803
|
+
var buildPhoneInput = (change) => {
|
|
1804
|
+
return {
|
|
1805
|
+
phone: {
|
|
1806
|
+
landline: change.personalTelephone ?? null,
|
|
1807
|
+
mobile: change.personalMobile ?? null
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
};
|
|
1811
|
+
var buildEmailInput = (change) => {
|
|
1812
|
+
return {
|
|
1813
|
+
email: {
|
|
1814
|
+
address: change.personalEmail
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
};
|
|
1818
|
+
var buildNameInput = (change) => {
|
|
1819
|
+
return {
|
|
1820
|
+
first: change.first,
|
|
1821
|
+
middle: change.middle ?? null,
|
|
1822
|
+
last: change.last
|
|
1823
|
+
};
|
|
1824
|
+
};
|
|
1825
|
+
var buildDobInput = (change) => {
|
|
1826
|
+
const { day, month, year } = change;
|
|
1827
|
+
return {
|
|
1828
|
+
// DAL expects dateOfBirth as YYYY-MM-DD e.g. '1990-04-05' not '1990-4-5'
|
|
1829
|
+
dateOfBirth: `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`
|
|
1830
|
+
};
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1642
1833
|
// src/services/services.js
|
|
1643
1834
|
var services = {
|
|
1644
1835
|
addressLookup: addressLookupService,
|
|
@@ -1647,7 +1838,9 @@ var services = {
|
|
|
1647
1838
|
checkInterrupterJourneySession: checkInterrupterJourneySessionService,
|
|
1648
1839
|
initialiseFixJourney: initialiseFixJourneyService,
|
|
1649
1840
|
validateFixDetails: validateFixDetailsService,
|
|
1650
|
-
setFixSessionData: setFixSessionDataService
|
|
1841
|
+
setFixSessionData: setFixSessionDataService,
|
|
1842
|
+
buildFixSuccessMessage: buildFixSuccessMessageService,
|
|
1843
|
+
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService
|
|
1651
1844
|
};
|
|
1652
1845
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1653
1846
|
0 && (module.exports = {
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,7 @@ var MONTH_MAP = {
|
|
|
60
60
|
var BUSINESS_EMAIL_ADDRESS = "You have updated your business email address";
|
|
61
61
|
var BUSINESS_NAME = "You have updated your business name";
|
|
62
62
|
var BUSINESS_PHONE_NUMBERS = "You have updated your business phone numbers";
|
|
63
|
+
var BUSINESS_VAT = "You have updated your VAT registration number";
|
|
63
64
|
|
|
64
65
|
// src/constants/interrupter-journey.js
|
|
65
66
|
var PERSONAL_SECTION_FIELD_ORDER = {
|
|
@@ -143,7 +144,8 @@ var constants = {
|
|
|
143
144
|
successMessages: {
|
|
144
145
|
BUSINESS_EMAIL_ADDRESS,
|
|
145
146
|
BUSINESS_NAME,
|
|
146
|
-
BUSINESS_PHONE_NUMBERS
|
|
147
|
+
BUSINESS_PHONE_NUMBERS,
|
|
148
|
+
BUSINESS_VAT
|
|
147
149
|
},
|
|
148
150
|
interrupterJourney: {
|
|
149
151
|
PERSONAL_SECTION_FIELD_ORDER,
|
|
@@ -882,6 +884,62 @@ var updateBusinessAddressMutation = `
|
|
|
882
884
|
}
|
|
883
885
|
`;
|
|
884
886
|
|
|
887
|
+
// src/mutations/business/update-business-vat.js
|
|
888
|
+
var updateBusinessVatMutation = `
|
|
889
|
+
mutation UpdateBusinessVAT($input: UpdateBusinessVATInput!) {
|
|
890
|
+
updateBusinessVAT(input: $input) {
|
|
891
|
+
business {
|
|
892
|
+
info {
|
|
893
|
+
vat
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
success
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
`;
|
|
900
|
+
|
|
901
|
+
// src/mutations/personal/update-customer-details.js
|
|
902
|
+
var updateCustomerDetailsMutation = `
|
|
903
|
+
mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
|
|
904
|
+
updateCustomerAllFields(input: $input) {
|
|
905
|
+
success
|
|
906
|
+
customer {
|
|
907
|
+
info {
|
|
908
|
+
name {
|
|
909
|
+
first
|
|
910
|
+
middle
|
|
911
|
+
last
|
|
912
|
+
}
|
|
913
|
+
dateOfBirth
|
|
914
|
+
phone {
|
|
915
|
+
mobile
|
|
916
|
+
landline
|
|
917
|
+
}
|
|
918
|
+
email {
|
|
919
|
+
address
|
|
920
|
+
}
|
|
921
|
+
address {
|
|
922
|
+
line1
|
|
923
|
+
line2
|
|
924
|
+
line3
|
|
925
|
+
line4
|
|
926
|
+
line5
|
|
927
|
+
buildingNumberRange
|
|
928
|
+
buildingName
|
|
929
|
+
flatName
|
|
930
|
+
street
|
|
931
|
+
city
|
|
932
|
+
county
|
|
933
|
+
postalCode
|
|
934
|
+
country
|
|
935
|
+
uprn
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
`;
|
|
942
|
+
|
|
885
943
|
// src/mutations/mutations.js
|
|
886
944
|
var mutations = {
|
|
887
945
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
@@ -892,7 +950,9 @@ var mutations = {
|
|
|
892
950
|
updateCustomerDob: updateCustomerDobMutation,
|
|
893
951
|
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
894
952
|
updateCustomerEmail: updateCustomerEmailMutation,
|
|
895
|
-
updateCustomerAddress: updateCustomerAddressMutation
|
|
953
|
+
updateCustomerAddress: updateCustomerAddressMutation,
|
|
954
|
+
updateBusinessVat: updateBusinessVatMutation,
|
|
955
|
+
updateCustomerDetails: updateCustomerDetailsMutation
|
|
896
956
|
};
|
|
897
957
|
|
|
898
958
|
// src/presenters/base-presenter.js
|
|
@@ -1192,13 +1252,24 @@ var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobil
|
|
|
1192
1252
|
};
|
|
1193
1253
|
};
|
|
1194
1254
|
|
|
1255
|
+
// src/utils/build-update-business-vat-variables.js
|
|
1256
|
+
var buildUpdateBusinessVatVariables = (vat, sbi) => {
|
|
1257
|
+
return {
|
|
1258
|
+
input: {
|
|
1259
|
+
vat,
|
|
1260
|
+
sbi
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
};
|
|
1264
|
+
|
|
1195
1265
|
// src/utils/utils.js
|
|
1196
1266
|
var utils = {
|
|
1197
1267
|
formatFullName,
|
|
1198
1268
|
formatValidationErrors,
|
|
1199
1269
|
buildUpdateBusinessEmailVariables,
|
|
1200
1270
|
buildUpdateBusinessNameVariables,
|
|
1201
|
-
buildUpdateBusinessPhoneNumbersVariables
|
|
1271
|
+
buildUpdateBusinessPhoneNumbersVariables,
|
|
1272
|
+
buildUpdateBusinessVatVariables
|
|
1202
1273
|
};
|
|
1203
1274
|
|
|
1204
1275
|
// src/services/os-places/address-lookup-service.js
|
|
@@ -1598,6 +1669,126 @@ var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey
|
|
|
1598
1669
|
yar.set(journeyKey, sessionData);
|
|
1599
1670
|
};
|
|
1600
1671
|
|
|
1672
|
+
// src/services/build-fix-success-message-service.js
|
|
1673
|
+
var LABEL_MAPS = {
|
|
1674
|
+
personal: {
|
|
1675
|
+
name: "full name",
|
|
1676
|
+
email: "personal email address",
|
|
1677
|
+
phone: "personal phone numbers",
|
|
1678
|
+
dob: "date of birth",
|
|
1679
|
+
address: "personal address"
|
|
1680
|
+
},
|
|
1681
|
+
business: {
|
|
1682
|
+
name: "business name",
|
|
1683
|
+
email: "business email address",
|
|
1684
|
+
phone: "business phone numbers",
|
|
1685
|
+
vat: "business vat number",
|
|
1686
|
+
address: "business address"
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
var PROPERTY_MAPS = {
|
|
1690
|
+
personal: {
|
|
1691
|
+
name: "changePersonalName",
|
|
1692
|
+
email: "changePersonalEmail",
|
|
1693
|
+
phone: "changePersonalPhoneNumbers",
|
|
1694
|
+
dob: "changePersonalDob",
|
|
1695
|
+
address: "changePersonalAddress"
|
|
1696
|
+
},
|
|
1697
|
+
business: {
|
|
1698
|
+
name: "changeBusinessName",
|
|
1699
|
+
email: "changeBusinessEmail",
|
|
1700
|
+
phone: "changeBusinessPhoneNumbers",
|
|
1701
|
+
vat: "changeBusinessVat",
|
|
1702
|
+
address: "changeBusinessAddress"
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
var buildFixSuccessMessageService = (type, details) => {
|
|
1706
|
+
const { orderedSectionsToFix } = details;
|
|
1707
|
+
const changes = loopThroughSections(type, details, orderedSectionsToFix);
|
|
1708
|
+
if (changes.length === 0) {
|
|
1709
|
+
return null;
|
|
1710
|
+
}
|
|
1711
|
+
if (changes.length === 1) {
|
|
1712
|
+
return {
|
|
1713
|
+
type: "text",
|
|
1714
|
+
value: `You have updated your ${changes[0]}`
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
return {
|
|
1718
|
+
type: "html",
|
|
1719
|
+
value: `
|
|
1720
|
+
<h3 class="govuk-notification-banner__heading">
|
|
1721
|
+
You have updated your:
|
|
1722
|
+
</h3>
|
|
1723
|
+
<ul class="govuk-list govuk-list--bullet">
|
|
1724
|
+
${changes.map((change) => `<li>${change}</li>`).join("")}
|
|
1725
|
+
</ul>
|
|
1726
|
+
`
|
|
1727
|
+
};
|
|
1728
|
+
};
|
|
1729
|
+
var loopThroughSections = (type, details, orderedSectionsToFix) => {
|
|
1730
|
+
const changes = [];
|
|
1731
|
+
const labelMap = LABEL_MAPS[type];
|
|
1732
|
+
const propertyMap = PROPERTY_MAPS[type];
|
|
1733
|
+
for (const section of orderedSectionsToFix) {
|
|
1734
|
+
if (details[propertyMap[section]]) {
|
|
1735
|
+
changes.push(labelMap[section]);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
return changes;
|
|
1739
|
+
};
|
|
1740
|
+
|
|
1741
|
+
// src/services/personal/build-customer-fix-update-variables-service.js
|
|
1742
|
+
var buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
1743
|
+
const { orderedSectionsToFix, crn } = personalDetails;
|
|
1744
|
+
const input = { crn };
|
|
1745
|
+
if (orderedSectionsToFix.includes("name") && personalDetails.changePersonalName) {
|
|
1746
|
+
Object.assign(input, buildNameInput(personalDetails.changePersonalName));
|
|
1747
|
+
}
|
|
1748
|
+
if (orderedSectionsToFix.includes("email") && personalDetails.changePersonalEmail) {
|
|
1749
|
+
Object.assign(input, buildEmailInput(personalDetails.changePersonalEmail));
|
|
1750
|
+
}
|
|
1751
|
+
if (orderedSectionsToFix.includes("phone") && personalDetails.changePersonalPhoneNumbers) {
|
|
1752
|
+
Object.assign(input, buildPhoneInput(personalDetails.changePersonalPhoneNumbers));
|
|
1753
|
+
}
|
|
1754
|
+
if (orderedSectionsToFix.includes("dob") && personalDetails.changePersonalDob) {
|
|
1755
|
+
Object.assign(input, buildDobInput(personalDetails.changePersonalDob));
|
|
1756
|
+
}
|
|
1757
|
+
if (orderedSectionsToFix.includes("address") && personalDetails.changePersonalAddress) {
|
|
1758
|
+
Object.assign(input, { address: buildManualAddress(personalDetails.changePersonalAddress) });
|
|
1759
|
+
}
|
|
1760
|
+
return { input };
|
|
1761
|
+
};
|
|
1762
|
+
var buildPhoneInput = (change) => {
|
|
1763
|
+
return {
|
|
1764
|
+
phone: {
|
|
1765
|
+
landline: change.personalTelephone ?? null,
|
|
1766
|
+
mobile: change.personalMobile ?? null
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
};
|
|
1770
|
+
var buildEmailInput = (change) => {
|
|
1771
|
+
return {
|
|
1772
|
+
email: {
|
|
1773
|
+
address: change.personalEmail
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
};
|
|
1777
|
+
var buildNameInput = (change) => {
|
|
1778
|
+
return {
|
|
1779
|
+
first: change.first,
|
|
1780
|
+
middle: change.middle ?? null,
|
|
1781
|
+
last: change.last
|
|
1782
|
+
};
|
|
1783
|
+
};
|
|
1784
|
+
var buildDobInput = (change) => {
|
|
1785
|
+
const { day, month, year } = change;
|
|
1786
|
+
return {
|
|
1787
|
+
// DAL expects dateOfBirth as YYYY-MM-DD e.g. '1990-04-05' not '1990-4-5'
|
|
1788
|
+
dateOfBirth: `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`
|
|
1789
|
+
};
|
|
1790
|
+
};
|
|
1791
|
+
|
|
1601
1792
|
// src/services/services.js
|
|
1602
1793
|
var services = {
|
|
1603
1794
|
addressLookup: addressLookupService,
|
|
@@ -1606,7 +1797,9 @@ var services = {
|
|
|
1606
1797
|
checkInterrupterJourneySession: checkInterrupterJourneySessionService,
|
|
1607
1798
|
initialiseFixJourney: initialiseFixJourneyService,
|
|
1608
1799
|
validateFixDetails: validateFixDetailsService,
|
|
1609
|
-
setFixSessionData: setFixSessionDataService
|
|
1800
|
+
setFixSessionData: setFixSessionDataService,
|
|
1801
|
+
buildFixSuccessMessage: buildFixSuccessMessageService,
|
|
1802
|
+
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService
|
|
1610
1803
|
};
|
|
1611
1804
|
export {
|
|
1612
1805
|
constants,
|
package/package.json
CHANGED
package/src/constants/index.js
CHANGED
|
@@ -36,7 +36,8 @@ import { MONTH_MAP } from './month-map.js'
|
|
|
36
36
|
import {
|
|
37
37
|
BUSINESS_EMAIL_ADDRESS,
|
|
38
38
|
BUSINESS_NAME,
|
|
39
|
-
BUSINESS_PHONE_NUMBERS
|
|
39
|
+
BUSINESS_PHONE_NUMBERS,
|
|
40
|
+
BUSINESS_VAT
|
|
40
41
|
} from './success-messages.js'
|
|
41
42
|
|
|
42
43
|
// Interrupter journey constants
|
|
@@ -86,7 +87,8 @@ export const constants = {
|
|
|
86
87
|
successMessages: {
|
|
87
88
|
BUSINESS_EMAIL_ADDRESS,
|
|
88
89
|
BUSINESS_NAME,
|
|
89
|
-
BUSINESS_PHONE_NUMBERS
|
|
90
|
+
BUSINESS_PHONE_NUMBERS,
|
|
91
|
+
BUSINESS_VAT
|
|
90
92
|
},
|
|
91
93
|
interrupterJourney: {
|
|
92
94
|
PERSONAL_SECTION_FIELD_ORDER,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export const BUSINESS_EMAIL_ADDRESS = 'You have updated your business email address'
|
|
2
2
|
export const BUSINESS_NAME = 'You have updated your business name'
|
|
3
3
|
export const BUSINESS_PHONE_NUMBERS = 'You have updated your business phone numbers'
|
|
4
|
+
export const BUSINESS_VAT = 'You have updated your VAT registration number'
|
|
@@ -7,6 +7,8 @@ import { updateCustomerPhoneMutation } from './personal/update-customer-phone.js
|
|
|
7
7
|
import { updateCustomerEmailMutation } from './personal/update-customer-email.js'
|
|
8
8
|
import { updateCustomerAddressMutation } from './personal/update-customer-address.js'
|
|
9
9
|
import { updateBusinessAddressMutation } from './business/update-business-address.js'
|
|
10
|
+
import { updateBusinessVatMutation } from './business/update-business-vat.js'
|
|
11
|
+
import { updateCustomerDetailsMutation } from './personal/update-customer-details.js'
|
|
10
12
|
|
|
11
13
|
export const mutations = {
|
|
12
14
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
@@ -17,5 +19,7 @@ export const mutations = {
|
|
|
17
19
|
updateCustomerDob: updateCustomerDobMutation,
|
|
18
20
|
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
19
21
|
updateCustomerEmail: updateCustomerEmailMutation,
|
|
20
|
-
updateCustomerAddress: updateCustomerAddressMutation
|
|
22
|
+
updateCustomerAddress: updateCustomerAddressMutation,
|
|
23
|
+
updateBusinessVat: updateBusinessVatMutation,
|
|
24
|
+
updateCustomerDetails: updateCustomerDetailsMutation
|
|
21
25
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const updateCustomerDetailsMutation = `
|
|
2
|
+
mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
|
|
3
|
+
updateCustomerAllFields(input: $input) {
|
|
4
|
+
success
|
|
5
|
+
customer {
|
|
6
|
+
info {
|
|
7
|
+
name {
|
|
8
|
+
first
|
|
9
|
+
middle
|
|
10
|
+
last
|
|
11
|
+
}
|
|
12
|
+
dateOfBirth
|
|
13
|
+
phone {
|
|
14
|
+
mobile
|
|
15
|
+
landline
|
|
16
|
+
}
|
|
17
|
+
email {
|
|
18
|
+
address
|
|
19
|
+
}
|
|
20
|
+
address {
|
|
21
|
+
line1
|
|
22
|
+
line2
|
|
23
|
+
line3
|
|
24
|
+
line4
|
|
25
|
+
line5
|
|
26
|
+
buildingNumberRange
|
|
27
|
+
buildingName
|
|
28
|
+
flatName
|
|
29
|
+
street
|
|
30
|
+
city
|
|
31
|
+
county
|
|
32
|
+
postalCode
|
|
33
|
+
country
|
|
34
|
+
uprn
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a success notification message based on which personal or business
|
|
3
|
+
* details were updated by the user.
|
|
4
|
+
*
|
|
5
|
+
* Returns either plain text (for a single change), HTML (for multiple changes),
|
|
6
|
+
* or null (when nothing changed) suitable for rendering inside a GOV.UK
|
|
7
|
+
* notification banner.
|
|
8
|
+
* @module buildFixSuccessMessageService
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const LABEL_MAPS = {
|
|
12
|
+
personal: {
|
|
13
|
+
name: 'full name',
|
|
14
|
+
email: 'personal email address',
|
|
15
|
+
phone: 'personal phone numbers',
|
|
16
|
+
dob: 'date of birth',
|
|
17
|
+
address: 'personal address'
|
|
18
|
+
},
|
|
19
|
+
business: {
|
|
20
|
+
name: 'business name',
|
|
21
|
+
email: 'business email address',
|
|
22
|
+
phone: 'business phone numbers',
|
|
23
|
+
vat: 'business vat number',
|
|
24
|
+
address: 'business address'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const PROPERTY_MAPS = {
|
|
29
|
+
personal: {
|
|
30
|
+
name: 'changePersonalName',
|
|
31
|
+
email: 'changePersonalEmail',
|
|
32
|
+
phone: 'changePersonalPhoneNumbers',
|
|
33
|
+
dob: 'changePersonalDob',
|
|
34
|
+
address: 'changePersonalAddress'
|
|
35
|
+
},
|
|
36
|
+
business: {
|
|
37
|
+
name: 'changeBusinessName',
|
|
38
|
+
email: 'changeBusinessEmail',
|
|
39
|
+
phone: 'changeBusinessPhoneNumbers',
|
|
40
|
+
vat: 'changeBusinessVat',
|
|
41
|
+
address: 'changeBusinessAddress'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const buildFixSuccessMessageService = (type, details) => {
|
|
46
|
+
const { orderedSectionsToFix } = details
|
|
47
|
+
|
|
48
|
+
const changes = loopThroughSections(type, details, orderedSectionsToFix)
|
|
49
|
+
|
|
50
|
+
if (changes.length === 0) {
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (changes.length === 1) {
|
|
55
|
+
return {
|
|
56
|
+
type: 'text',
|
|
57
|
+
value: `You have updated your ${changes[0]}`
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
type: 'html',
|
|
63
|
+
value: `
|
|
64
|
+
<h3 class="govuk-notification-banner__heading">
|
|
65
|
+
You have updated your:
|
|
66
|
+
</h3>
|
|
67
|
+
<ul class="govuk-list govuk-list--bullet">
|
|
68
|
+
${changes.map(change => `<li>${change}</li>`).join('')}
|
|
69
|
+
</ul>
|
|
70
|
+
`
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const loopThroughSections = (type, details, orderedSectionsToFix) => {
|
|
75
|
+
const changes = []
|
|
76
|
+
|
|
77
|
+
// Pick the personal/business label and property maps for this journey type
|
|
78
|
+
const labelMap = LABEL_MAPS[type]
|
|
79
|
+
const propertyMap = PROPERTY_MAPS[type]
|
|
80
|
+
|
|
81
|
+
// Loop through the ordered sections and check if each section has change data
|
|
82
|
+
for (const section of orderedSectionsToFix) {
|
|
83
|
+
// Only include a section if its change data is actually present
|
|
84
|
+
if (details[propertyMap[section]]) {
|
|
85
|
+
// Store the human-readable label rather than the raw section key
|
|
86
|
+
changes.push(labelMap[section])
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return changes
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export {
|
|
94
|
+
buildFixSuccessMessageService
|
|
95
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds mutation variables for updating a user's personal details via the fix journey.
|
|
3
|
+
* Only includes the sections that actually need updating, using the
|
|
4
|
+
* unified `input` format for the GraphQL mutation.
|
|
5
|
+
*
|
|
6
|
+
* @module buildCustomerFixUpdateVariablesService
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { buildManualAddress } from '../build-address-variables-service.js'
|
|
10
|
+
|
|
11
|
+
const buildCustomerFixUpdateVariablesService = (personalDetails) => {
|
|
12
|
+
const { orderedSectionsToFix, crn } = personalDetails
|
|
13
|
+
|
|
14
|
+
const input = { crn }
|
|
15
|
+
|
|
16
|
+
// Conditionally merge each section into input if it's been updated by the user
|
|
17
|
+
if (orderedSectionsToFix.includes('name') && personalDetails.changePersonalName) {
|
|
18
|
+
Object.assign(input, buildNameInput(personalDetails.changePersonalName))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (orderedSectionsToFix.includes('email') && personalDetails.changePersonalEmail) {
|
|
22
|
+
Object.assign(input, buildEmailInput(personalDetails.changePersonalEmail))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (orderedSectionsToFix.includes('phone') && personalDetails.changePersonalPhoneNumbers) {
|
|
26
|
+
Object.assign(input, buildPhoneInput(personalDetails.changePersonalPhoneNumbers))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (orderedSectionsToFix.includes('dob') && personalDetails.changePersonalDob) {
|
|
30
|
+
Object.assign(input, buildDobInput(personalDetails.changePersonalDob))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (orderedSectionsToFix.includes('address') && personalDetails.changePersonalAddress) {
|
|
34
|
+
Object.assign(input, { address: buildManualAddress(personalDetails.changePersonalAddress) })
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return { input }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const buildPhoneInput = (change) => {
|
|
41
|
+
return {
|
|
42
|
+
phone: {
|
|
43
|
+
landline: change.personalTelephone ?? null,
|
|
44
|
+
mobile: change.personalMobile ?? null
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const buildEmailInput = (change) => {
|
|
50
|
+
return {
|
|
51
|
+
email: {
|
|
52
|
+
address: change.personalEmail
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const buildNameInput = (change) => {
|
|
58
|
+
return {
|
|
59
|
+
first: change.first,
|
|
60
|
+
middle: change.middle ?? null,
|
|
61
|
+
last: change.last
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const buildDobInput = (change) => {
|
|
66
|
+
const { day, month, year } = change
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
// DAL expects dateOfBirth as YYYY-MM-DD e.g. '1990-04-05' not '1990-4-5'
|
|
70
|
+
dateOfBirth: `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
buildCustomerFixUpdateVariablesService
|
|
76
|
+
}
|
package/src/services/services.js
CHANGED
|
@@ -4,6 +4,8 @@ import { checkInterrupterJourneySessionService } from './check-interrupter-journ
|
|
|
4
4
|
import { initialiseFixJourneyService } from './initialise-fix-journey-service.js'
|
|
5
5
|
import { validateFixDetailsService } from './validate-fix-details-service.js'
|
|
6
6
|
import { setFixSessionDataService } from './set-fix-session-data-service.js'
|
|
7
|
+
import { buildFixSuccessMessageService } from './build-fix-success-message-service.js'
|
|
8
|
+
import { buildCustomerFixUpdateVariablesService } from './personal/build-customer-fix-update-variables-service.js'
|
|
7
9
|
|
|
8
10
|
export const services = {
|
|
9
11
|
addressLookup: addressLookupService,
|
|
@@ -12,5 +14,7 @@ export const services = {
|
|
|
12
14
|
checkInterrupterJourneySession: checkInterrupterJourneySessionService,
|
|
13
15
|
initialiseFixJourney: initialiseFixJourneyService,
|
|
14
16
|
validateFixDetails: validateFixDetailsService,
|
|
15
|
-
setFixSessionData: setFixSessionDataService
|
|
17
|
+
setFixSessionData: setFixSessionDataService,
|
|
18
|
+
buildFixSuccessMessage: buildFixSuccessMessageService,
|
|
19
|
+
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService
|
|
16
20
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the GraphQL variables for the `updateBusinessVAT` mutation.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} vat - The new business VAT registration number
|
|
5
|
+
* @param {string} sbi - The Single Business Identifier of the business being updated
|
|
6
|
+
* @returns {object} The mutation variables in the shape `{ input: { vat, sbi } }`
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const buildUpdateBusinessVatVariables = (vat, sbi) => {
|
|
10
|
+
return {
|
|
11
|
+
input: {
|
|
12
|
+
vat,
|
|
13
|
+
sbi
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/utils/utils.js
CHANGED
|
@@ -3,11 +3,13 @@ import { formatValidationErrors } from './format-validation-errors.js'
|
|
|
3
3
|
import { buildUpdateBusinessEmailVariables } from './build-update-business-email-variables.js'
|
|
4
4
|
import { buildUpdateBusinessNameVariables } from './build-update-business-name-variables.js'
|
|
5
5
|
import { buildUpdateBusinessPhoneNumbersVariables } from './build-update-business-phone-numbers-variables.js'
|
|
6
|
+
import { buildUpdateBusinessVatVariables } from './build-update-business-vat-variables.js'
|
|
6
7
|
|
|
7
8
|
export const utils = {
|
|
8
9
|
formatFullName,
|
|
9
10
|
formatValidationErrors,
|
|
10
11
|
buildUpdateBusinessEmailVariables,
|
|
11
12
|
buildUpdateBusinessNameVariables,
|
|
12
|
-
buildUpdateBusinessPhoneNumbersVariables
|
|
13
|
+
buildUpdateBusinessPhoneNumbersVariables,
|
|
14
|
+
buildUpdateBusinessVatVariables
|
|
13
15
|
}
|