-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/change-contact-consent-to-read-only (#7392)
* Add component for rendering consent details * label change * remove dit marketing checkbox * test fixes
- Loading branch information
1 parent
3664d8e
commit 96f966f
Showing
15 changed files
with
296 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ describe('contact form service', () => { | |
primary: true, | ||
full_telephone_number: '+1 652423467167', | ||
email: '[email protected]', | ||
accepts_dit_email_marketing: true, | ||
address_same_as_company: false, | ||
notes: 'Some notes', | ||
archived_by: null, | ||
|
@@ -60,7 +59,6 @@ describe('contact form service', () => { | |
primary: 'yes', | ||
full_telephone_number: '+1 652423467167', | ||
email: '[email protected]', | ||
accepts_dit_email_marketing: true, | ||
address_same_as_company: 'no', | ||
address_1: '99 N Shore Road', | ||
address_2: 'Suite 20', | ||
|
@@ -107,7 +105,6 @@ describe('contact form service', () => { | |
address_postcode: null, | ||
address_country: null, | ||
notes: 'Some notes', | ||
accepts_dit_email_marketing: true, | ||
} | ||
|
||
const actual = contactFormService.getContactAsFormData(contact) | ||
|
@@ -118,15 +115,5 @@ describe('contact form service', () => { | |
it('should handle a null contact', () => { | ||
expect(contactFormService.getContactAsFormData(null)).to.be.null | ||
}) | ||
|
||
context('when the contact accepts DBT email marketing', () => { | ||
it('should set the marketing preferences to accepts_dit_email_marketing', () => { | ||
const contact = assign({}, contactData, { | ||
accepts_dit_email_marketing: true, | ||
}) | ||
const actual = contactFormService.getContactAsFormData(contact) | ||
expect(actual.accepts_dit_email_marketing).to.be.true | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ const CONTACT = { | |
telephoneCountrycode: '123', | ||
telephoneNumber: '456789', | ||
email: '[email protected]', | ||
acceptsDitEmailMarketing: true, | ||
addressSameAsCompany: true, | ||
address1: 'Foo', | ||
address2: 'Bar', | ||
|
@@ -112,7 +111,6 @@ export default { | |
addressCountry: null, | ||
addressPostcode: null, | ||
notes: null, | ||
acceptsDitEmailMarketing: false, | ||
archived: false, | ||
archivedDocumentsUrlPath: '', | ||
archivedOn: null, | ||
|
25 changes: 25 additions & 0 deletions
25
src/client/modules/Contacts/ContactDetails/ConsentDetails.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import { isNil } from 'lodash' | ||
|
||
import { SectionHeader } from '../../../components' | ||
import { transformContactConsents } from './transformers' | ||
|
||
const ConsentDetails = ({ contact }) => { | ||
const consentGiven = transformContactConsents(contact) | ||
return ( | ||
<div> | ||
<SectionHeader type="contact-consent">Contact consent</SectionHeader> | ||
{isNil(contact.consentData) ? ( | ||
<p data-test="no-contact-consents"> | ||
There is no consent data available for this contact | ||
</p> | ||
) : ( | ||
<p> | ||
{`This contact has ${consentGiven ? 'given' : 'not given'} consent to be contacted.`} | ||
</p> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export default ConsentDetails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/client/modules/Contacts/ContactDetails/__test__/transformers.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'core-js/proposals/array-grouping-v2' | ||
import { transformContactConsents } from '../transformers' | ||
|
||
describe('transformContactConsents', () => { | ||
context('When a falsey contact is passed', () => { | ||
it('Should return false', () => { | ||
expect(transformContactConsents(undefined)).to.equal(false) | ||
}) | ||
}) | ||
|
||
context('When a contact has no consent data', () => { | ||
it('Should return false', () => { | ||
expect(transformContactConsents({})).to.equal(false) | ||
}) | ||
}) | ||
|
||
context( | ||
'When a contact has a single domain and has not given consent', | ||
() => { | ||
it('Should return false', () => { | ||
expect( | ||
transformContactConsents({ | ||
consentData: [ | ||
{ | ||
consentDomain: 'International', | ||
emailContactConsent: false, | ||
}, | ||
], | ||
}) | ||
).to.equal(false) | ||
}) | ||
} | ||
) | ||
|
||
context('When a contact has a single domain and has given consent', () => { | ||
it('Should return true', () => { | ||
expect( | ||
transformContactConsents({ | ||
consentData: [ | ||
{ | ||
consentDomain: 'International', | ||
emailContactConsent: true, | ||
}, | ||
], | ||
}) | ||
).to.equal(true) | ||
}) | ||
}) | ||
|
||
context( | ||
'When a contact has a multiple domains and has given consent to one', | ||
() => { | ||
it('Should return true', () => { | ||
expect( | ||
transformContactConsents({ | ||
consentData: [ | ||
{ | ||
consentDomain: 'International', | ||
emailContactConsent: true, | ||
}, | ||
{ | ||
consentDomain: 'International', | ||
emailContactConsent: false, | ||
}, | ||
], | ||
}) | ||
).to.equal(true) | ||
}) | ||
} | ||
) | ||
|
||
context( | ||
'When a contact has a multiple domains and has given consent to all', | ||
() => { | ||
it('Should return true', () => { | ||
expect( | ||
transformContactConsents({ | ||
consentData: [ | ||
{ | ||
consentDomain: 'International', | ||
emailContactConsent: true, | ||
}, | ||
{ | ||
consentDomain: 'International', | ||
emailContactConsent: true, | ||
}, | ||
], | ||
}) | ||
).to.equal(true) | ||
}) | ||
} | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const transformContactConsents = (contact) => { | ||
if (!contact || !contact.consentData) { | ||
return false | ||
} | ||
|
||
return contact.consentData.some((consent) => consent.emailContactConsent) | ||
} |
Oops, something went wrong.