@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/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Updates any combination of business name, email, phone, VAT and address.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const updateBusinessDetailsMutation = `
|
|
6
|
+
mutation UpdateBusinessAllFields($input: UpdateBusinessAllFieldsInput!) {
|
|
7
|
+
updateBusinessAllFields(input: $input) {
|
|
8
|
+
success
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`
|
|
@@ -1,29 +1,31 @@
|
|
|
1
|
+
import { updateBusinessAddressMutation } from './business/update-business-address.js'
|
|
2
|
+
import { updateBusinessDetailsMutation } from './business/update-business-details.js'
|
|
1
3
|
import { updateBusinessEmailMutation } from './business/update-business-email.js'
|
|
4
|
+
import { updateBusinessLegalStatusMutation } from './business/update-business-legal-status.js'
|
|
2
5
|
import { updateBusinessNameMutation } from './business/update-business-name.js'
|
|
3
6
|
import { updateBusinessPhoneNumbersMutation } from './business/update-business-phone-numbers.js'
|
|
4
|
-
import {
|
|
5
|
-
import { updateCustomerDobMutation } from './personal/update-customer-dob.js'
|
|
6
|
-
import { updateCustomerPhoneMutation } from './personal/update-customer-phone.js'
|
|
7
|
-
import { updateCustomerEmailMutation } from './personal/update-customer-email.js'
|
|
8
|
-
import { updateCustomerAddressMutation } from './personal/update-customer-address.js'
|
|
9
|
-
import { updateBusinessAddressMutation } from './business/update-business-address.js'
|
|
7
|
+
import { updateBusinessRegistrationNumbersMutation } from './business/update-business-registration-numbers.js'
|
|
10
8
|
import { updateBusinessVatMutation } from './business/update-business-vat.js'
|
|
9
|
+
import { updateCustomerAddressMutation } from './personal/update-customer-address.js'
|
|
11
10
|
import { updateCustomerDetailsMutation } from './personal/update-customer-details.js'
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { updateCustomerDobMutation } from './personal/update-customer-dob.js'
|
|
12
|
+
import { updateCustomerEmailMutation } from './personal/update-customer-email.js'
|
|
13
|
+
import { updateCustomerNameMutation } from './personal/update-customer-name.js'
|
|
14
|
+
import { updateCustomerPhoneMutation } from './personal/update-customer-phone.js'
|
|
14
15
|
|
|
15
16
|
export const mutations = {
|
|
17
|
+
updateBusinessAddress: updateBusinessAddressMutation,
|
|
18
|
+
updateBusinessDetails: updateBusinessDetailsMutation,
|
|
16
19
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
20
|
+
updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
|
|
17
21
|
updateBusinessName: updateBusinessNameMutation,
|
|
18
22
|
updateBusinessPhoneNumbers: updateBusinessPhoneNumbersMutation,
|
|
19
|
-
|
|
20
|
-
updateCustomerName: updateCustomerNameMutation,
|
|
21
|
-
updateCustomerDob: updateCustomerDobMutation,
|
|
22
|
-
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
23
|
-
updateCustomerEmail: updateCustomerEmailMutation,
|
|
24
|
-
updateCustomerAddress: updateCustomerAddressMutation,
|
|
23
|
+
updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation,
|
|
25
24
|
updateBusinessVat: updateBusinessVatMutation,
|
|
25
|
+
updateCustomerAddress: updateCustomerAddressMutation,
|
|
26
26
|
updateCustomerDetails: updateCustomerDetailsMutation,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
updateCustomerDob: updateCustomerDobMutation,
|
|
28
|
+
updateCustomerEmail: updateCustomerEmailMutation,
|
|
29
|
+
updateCustomerName: updateCustomerNameMutation,
|
|
30
|
+
updateCustomerPhone: updateCustomerPhoneMutation
|
|
29
31
|
}
|
|
@@ -1,40 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Updates any combination of personal name, email, phone, and address.
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
export const updateCustomerDetailsMutation = `
|
|
2
6
|
mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
|
|
3
7
|
updateCustomerAllFields(input: $input) {
|
|
4
8
|
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
9
|
}
|
|
39
10
|
}
|
|
40
11
|
`
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds mutation variables for updating a business's 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 buildBusinessFixUpdateVariablesService
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { buildManualAddress } from '../build-address-variables-service.js'
|
|
10
|
+
|
|
11
|
+
const buildBusinessFixUpdateVariablesService = (businessDetails) => {
|
|
12
|
+
const { orderedSectionsToFix, sbi } = businessDetails
|
|
13
|
+
|
|
14
|
+
const input = { sbi }
|
|
15
|
+
|
|
16
|
+
// Conditionally merge each section into input if it's been updated by the user
|
|
17
|
+
for (const applySection of sectionAppliers) {
|
|
18
|
+
applySection(input, businessDetails, orderedSectionsToFix)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return { input }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const applyAddressSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
25
|
+
if (orderedSectionsToFix.includes('address') && businessDetails.changeBusinessAddress) {
|
|
26
|
+
input.address = { withoutUprn: buildManualAddress(businessDetails.changeBusinessAddress) }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const applyEmailSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
31
|
+
if (orderedSectionsToFix.includes('email') && businessDetails.changeBusinessEmail) {
|
|
32
|
+
Object.assign(input, buildEmailInput(businessDetails.changeBusinessEmail))
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const applyNameSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
37
|
+
if (orderedSectionsToFix.includes('name') && businessDetails.changeBusinessName) {
|
|
38
|
+
input.name = businessDetails.changeBusinessName.businessName
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const applyPhoneSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
43
|
+
if (orderedSectionsToFix.includes('phone') && businessDetails.changeBusinessPhoneNumbers) {
|
|
44
|
+
Object.assign(input, buildPhoneInput(businessDetails.changeBusinessPhoneNumbers))
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const applyVatSection = (input, businessDetails, orderedSectionsToFix) => {
|
|
49
|
+
if (orderedSectionsToFix.includes('vat') && businessDetails.changeBusinessVat) {
|
|
50
|
+
input.vat = businessDetails.changeBusinessVat.vatNumber ?? ''
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const sectionAppliers = [
|
|
55
|
+
applyAddressSection,
|
|
56
|
+
applyEmailSection,
|
|
57
|
+
applyNameSection,
|
|
58
|
+
applyPhoneSection,
|
|
59
|
+
applyVatSection
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
const buildEmailInput = (change) => {
|
|
63
|
+
return {
|
|
64
|
+
email: {
|
|
65
|
+
address: change.businessEmail
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const buildPhoneInput = (change) => {
|
|
71
|
+
return {
|
|
72
|
+
phone: {
|
|
73
|
+
landline: change.businessTelephone ?? null,
|
|
74
|
+
mobile: change.businessMobile ?? null
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
buildBusinessFixUpdateVariablesService
|
|
81
|
+
}
|
|
@@ -48,6 +48,7 @@ const initialiseFixJourneyService = (yar, source, journeyType) => {
|
|
|
48
48
|
|
|
49
49
|
const sessionData = yar.get(sessionKey)
|
|
50
50
|
|
|
51
|
+
// yar.get() returns null for a missing/already-cleared key (e.g. journey already completed)
|
|
51
52
|
if (!sessionData?.sectionsNeedingUpdate) {
|
|
52
53
|
return sessionData
|
|
53
54
|
}
|
package/src/services/services.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { buildManualAddress, buildUprnAddress } from './build-address-variables-service.js'
|
|
2
|
+
import { buildFixSuccessMessageService } from './build-fix-success-message-service.js'
|
|
3
|
+
import { buildBusinessFixUpdateVariablesService } from './business/build-business-fix-update-variables-service.js'
|
|
3
4
|
import { checkInterrupterJourneySessionService } from './check-interrupter-journey-session-service.js'
|
|
4
5
|
import { initialiseFixJourneyService } from './initialise-fix-journey-service.js'
|
|
5
|
-
import {
|
|
6
|
-
import { setFixSessionDataService } from './set-fix-session-data-service.js'
|
|
7
|
-
import { buildFixSuccessMessageService } from './build-fix-success-message-service.js'
|
|
6
|
+
import { addressLookupService } from './os-places/address-lookup-service.js'
|
|
8
7
|
import { buildCustomerFixUpdateVariablesService } from './personal/build-customer-fix-update-variables-service.js'
|
|
8
|
+
import { setFixSessionDataService } from './set-fix-session-data-service.js'
|
|
9
|
+
import { validateFixDetailsService } from './validate-fix-details-service.js'
|
|
9
10
|
|
|
10
11
|
export const services = {
|
|
11
12
|
addressLookup: addressLookupService,
|
|
12
|
-
|
|
13
|
+
buildBusinessFixUpdateVariables: buildBusinessFixUpdateVariablesService,
|
|
14
|
+
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService,
|
|
15
|
+
buildFixSuccessMessage: buildFixSuccessMessageService,
|
|
13
16
|
buildManualAddress,
|
|
17
|
+
buildUprnAddress,
|
|
14
18
|
checkInterrupterJourneySession: checkInterrupterJourneySessionService,
|
|
15
19
|
initialiseFixJourney: initialiseFixJourneyService,
|
|
16
|
-
validateFixDetails: validateFixDetailsService,
|
|
17
20
|
setFixSessionData: setFixSessionDataService,
|
|
18
|
-
|
|
19
|
-
buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService
|
|
21
|
+
validateFixDetails: validateFixDetailsService
|
|
20
22
|
}
|