Skip to content

Instantly share code, notes, and snippets.

@lkostrowski
Created May 25, 2020 14:21
Show Gist options
  • Save lkostrowski/102a36ec6b32119557b163f4ea06cba3 to your computer and use it in GitHub Desktop.
Save lkostrowski/102a36ec6b32119557b163f4ea06cba3 to your computer and use it in GitHub Desktop.
export const SystemSelectorV2: SystemsSelectorV2 = {
getSystemsForTableView: createSelector(getSystemsDomain, (domain) =>
Object.values(domain.systemsByID).map((normalizedSystem) => {
const baseData: SystemModel.SystemsTableRowData = {
id: normalizedSystem.id,
systemID: normalizedSystem.systemIdentifier,
address: normalizedSystem.address,
systemType: normalizedSystem.type,
customer: null,
installer: null,
};
return createSelector(
...normalizedSystem.users.map((id) => AccountsSelector.getAccountById(id)),
(...users): SystemModel.SystemsTableRowData => {
return {
...baseData,
customer: AccountModel.findCustomerInAccounts(users),
installer: AccountModel.findInstallerInAccounts(users),
};
},
);
}),
),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment