Skip to content

Commit

Permalink
feat: added label overrides on AddressBook
Browse files Browse the repository at this point in the history
Signed-off-by: Haris Spahija <[email protected]>
  • Loading branch information
HarisSpahijaPon committed Oct 28, 2019
1 parent 4808ec2 commit fa77a46
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions package/src/components/AddressBook/v1/AddressBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class AddressBook extends Component {
*/
addressBook: CustomPropTypes.addressBook
}),
/**
* The text for the "Add a new address" text, if it is shown.
*/
addNewItemButtonText: PropTypes.string,
/**
* You can provide a `className` prop that will be applied to the outermost DOM element
* rendered by this component. We do not recommend using this for styling purposes, but
Expand Down Expand Up @@ -47,6 +51,14 @@ class AddressBook extends Component {
*/
AddressReview: CustomPropTypes.component.isRequired
}).isRequired,
/**
* The text for the "Delete address" text, if it is shown.
*/
deleteItemButtonText: PropTypes.string,
/**
* The text for the "Save Changes" text, if it is shown.
*/
entryFormSubmitButtonText: PropTypes.string,
/**
* Is data being saved
*/
Expand Down Expand Up @@ -77,6 +89,9 @@ class AddressBook extends Component {
account: {
addressBook: []
},
addNewItemButtonText: "Add a new address",
deleteItemButtonText: "Delete address",
entryFormSubmitButtonText: "Save Changes",
isSaving: false,
onAddressAdded() {},
onAddressDeleted() {},
Expand Down Expand Up @@ -133,7 +148,7 @@ class AddressBook extends Component {
// Render Methods
//
renderAccordionFormList() {
const { account: { addressBook }, components: { AccordionFormList, AddressForm }, isSaving } = this.props;
const { account: { addressBook }, addNewItemButtonText, components: { AccordionFormList, AddressForm }, deleteItemButtonText, entryFormSubmitButtonText, isSaving } = this.props;

const items = addressBook.map(({ _id, ...address }) => ({
id: _id,
Expand All @@ -156,10 +171,10 @@ class AddressBook extends Component {

return (
<AccordionFormList
addNewItemButtonText="Add a new address"
addNewItemButtonText={addNewItemButtonText}
components={{ ItemAddForm: AddressForm, ItemEditForm: AddressForm }}
deleteItemButtonText="Delete address"
entryFormSubmitButtonText="Save Changes"
deleteItemButtonText={deleteItemButtonText}
entryFormSubmitButtonText={entryFormSubmitButtonText}
itemAddFormProps={itemAddFormProps}
items={items}
onItemDeleted={this.handleDeleteAddress}
Expand Down

0 comments on commit fa77a46

Please sign in to comment.