Last active
July 20, 2021 22:30
-
-
Save germanrdz/556640a9dc277b559f01c2826d776ae7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
Requirement: | |
Refactor this function to improve legibility/maintainability | |
*/ | |
const mapStateToProps = state => { | |
const contactsData = getContacts(state); | |
const managersData = getManagers(state); | |
let contacts; | |
let managers; | |
if (contactsData.get('results')) { | |
const contactsDataJS = contactsData.get('results').toJS(); | |
const contactsKeys = Object.keys(contactsDataJS); | |
contacts = contactsKeys.map(key => contactsDataJS[key]); | |
} | |
if (managersData.get('results')) { | |
const managersDataJS = managersData.get('results').toJS(); | |
const managersKeys = Object.keys(managersDataJS); | |
managers = managersKeys.map(key => managersDataJS[key]); | |
} | |
return { | |
contacts, | |
managers, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment