-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from comicrelief/marketing_consent_component
marketing consent component
- Loading branch information
Showing
17 changed files
with
904 additions
and
287 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
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
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 |
---|---|---|
@@ -0,0 +1,159 @@ | ||
{"Questions": [ | ||
{ | ||
"id": "emailConsent", | ||
"text": "Email", | ||
"options": [ | ||
{ | ||
"label": "Yes", | ||
"value": "yes", | ||
"name": "emailPermission", | ||
"hideFields": false | ||
}, | ||
{ | ||
"label": "No", | ||
"value": "no", | ||
"name": "emailPermission", | ||
"hideFields": true | ||
} | ||
], | ||
"field": [ | ||
{ | ||
"id": "emailAddress", | ||
"type": "email", | ||
"name": "email", | ||
"label": "Email address", | ||
"placeholder": "example@email.com", | ||
"required": true | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "postConsent", | ||
"text": "Post", | ||
"options": [ | ||
{ | ||
"label": "Yes", | ||
"value": "yes", | ||
"name": "postPermission", | ||
"hideFields": false | ||
}, | ||
{ | ||
"label": "No", | ||
"value": "no", | ||
"name": "postPermission", | ||
"hideFields": true | ||
} | ||
], | ||
"field": [ | ||
{ | ||
"id": "address1", | ||
"type": "text", | ||
"name": "address1", | ||
"label": "Address line 1", | ||
"placeholder": null, | ||
"required": true | ||
}, | ||
{ | ||
"id": "address2", | ||
"type": "text", | ||
"name": "address2", | ||
"label": "Address line 2", | ||
"placeholder": null, | ||
"required": false, | ||
"min": null | ||
}, | ||
{ | ||
"id": "address3", | ||
"type": "text", | ||
"name": "address3", | ||
"label": "Address line 3", | ||
"placeholder": null, | ||
"required": false, | ||
"min": null | ||
}, | ||
{ | ||
"id": "town", | ||
"type": "text", | ||
"name": "town", | ||
"label": "Town/City", | ||
"placeholder": null, | ||
"required": true, | ||
"pattern": "[a-zA-Z]+", | ||
"min": null | ||
}, | ||
{ | ||
"id": "postcode", | ||
"type": "text", | ||
"name": "postcode", | ||
"label": "Postcode", | ||
"placeholder": "SE1 7TP", | ||
"required": true | ||
}, | ||
{ | ||
"id": "country", | ||
"type": "text", | ||
"name": "country", | ||
"label": "Country", | ||
"placeholder": "United Kingdom", | ||
"required": true | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "phoneConsent", | ||
"text": "Phone", | ||
"options": [ | ||
{ | ||
"label": "Yes", | ||
"value": "yes", | ||
"name": "phonePermission", | ||
"hideFields": false | ||
}, | ||
{ | ||
"label": "No", | ||
"value": "no", | ||
"name": "phonePermission", | ||
"hideFields": true | ||
} | ||
], | ||
"field": [ | ||
{ | ||
"id": "phoneNumber", | ||
"type": "tel", | ||
"name": "phone", | ||
"label": "Phone number", | ||
"placeholder": null, | ||
"required": true | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "SMSConsent", | ||
"text": "SMS", | ||
"options": [ | ||
{ | ||
"label": "Yes", | ||
"value": "yes", | ||
"name": "smsPermission", | ||
"hideFields": false | ||
}, | ||
{ | ||
"label": "No", | ||
"value": "no", | ||
"name": "smsPermission", | ||
"hideFields": true | ||
} | ||
], | ||
"field": [ | ||
{ | ||
"id": "mobileNumber", | ||
"type": "tel", | ||
"name": "mobile", | ||
"label": "Mobile number", | ||
"placeholder": null, | ||
"required": 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,87 @@ | ||
import React, { Component } from 'react'; | ||
import propTypes from 'prop-types'; | ||
import MarketingConsentCheckbox from './MarketingConsentCheckbox'; | ||
import './MarketingConsent.scss'; | ||
|
||
class MarketingConsent extends Component { | ||
/** | ||
* Send State containing new validation data to parent. | ||
* @param prevProps (needed for arguments order) | ||
* @param prevState | ||
*/ | ||
componentDidUpdate(prevProps, prevState) { | ||
if (prevState !== this.state) { | ||
this.props.getValidation(this.state); | ||
} | ||
} | ||
|
||
/** | ||
* Add each Marketing consent question's validation data to the state. | ||
* @param name | ||
* @param validation | ||
*/ | ||
updateState(name, validation) { | ||
this.setState({ | ||
...this.state, | ||
[name]: validation[name], | ||
}); | ||
} | ||
|
||
/** | ||
* Render text and MarketingConsentCheckbox components. | ||
* @return {XML} | ||
*/ | ||
render() { | ||
const data = this.props.itemData; | ||
return ( | ||
<div className={'form__row form__row--marketing-consent'} > | ||
<div className="form__fieldset"> | ||
<p>Hear more about the project Comic Relief funds and other ways you can support our work including fundraising, campaigns and products.</p> | ||
<p>How would you like to hear from us?</p> | ||
{ data.Questions.map(item => | ||
(<MarketingConsentCheckbox | ||
key={item.id} | ||
getValidation={(name, validation) => { this.updateState(name, validation); }} | ||
itemData={item} | ||
valueFromParent={this.props.valueFromParent && this.props.valueFromParent[item.id]} | ||
showErrorMessages={this.props.showErrorMessages} | ||
/>)) } | ||
<p>You can update your communication preferences at any time at | ||
<a | ||
href="https://www.comicrelief.com/update-your-preferences." | ||
target="blank" | ||
rel="noopener noreferrer" | ||
className="link inline" | ||
> | ||
comicrelief.com/update-your-preferences. | ||
<span className="visuallyhidden">(opens in a new window)</span> | ||
</a> Your details will be kept safe, check out our | ||
<a | ||
href="https://www.comicrelief.com/privacy-policy" | ||
target="blank" | ||
rel="noopener noreferrer" | ||
className="link inline" | ||
> | ||
privacy policy | ||
<span className="visuallyhidden">(opens in a new window)</span> | ||
</a> for more details.</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
MarketingConsent.defaultProps = { | ||
valueFromParent: null, | ||
showErrorMessages: false, | ||
}; | ||
MarketingConsent.propTypes = { | ||
getValidation: propTypes.func.isRequired, | ||
valueFromParent: propTypes.object, | ||
showErrorMessages: propTypes.bool, | ||
itemData: propTypes.shape({ | ||
itemData: propTypes.object, | ||
}).isRequired, | ||
}; | ||
|
||
export default MarketingConsent; |
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,15 @@ | ||
.form__row--marketing-consent { | ||
.form__field-wrapper--background { | ||
padding: 22px 44px; | ||
.form__checkbox--inline-2-horizontal { | ||
label { | ||
padding-top: 1em; | ||
} | ||
input[type="checkbox"] + span, | ||
input[type="checkbox"] { | ||
top: 18px; | ||
left: 0; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.