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
import {UserGreeting} from './user-greeting'; | |
import {connect} from 'react-redux'; | |
const mapStateToProps = ({user}) => ({ | |
firstName: user.firstName, | |
lastName: user.lastName | |
}); | |
export const UserGreeetingConnector = connect(mapStateToProps)(UserGreeting); |
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
import React from 'react'; | |
import UserGreeting from './user-greeting-connector'; | |
export const UserDashboard = () => ( | |
<UserGreeting/> | |
); |
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
import React, {Fragment} from 'react'; | |
export const UserGreeting = ({firstName, lastName}) => ( | |
<Fragment>{`Hello, ${firstName} ${lastName}!`}</Fragment> | |
); |
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
import {UserGreeting} from './user-greeting'; | |
import {connect} from 'react-redux'; | |
const mapStateToProps = ({user}) => ({ | |
firstName: user.firstName, | |
lastName: user.lastName | |
}); | |
export default connect(mapStateToProps)(UserGreeting); |
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
export const adjustDividendAmountForSplits = (dividend, splits) => { | |
const applicableSplits = findApplicableSplitsAgainstDividendYear(dividend.exDate, splits); | |
const divAmountWithAppliedSplitRatios = applySplitsRatiosToMatchingDividendAmount(dividend.amount, applicableSplits); | |
return new BigNumber(divAmountWithAppliedSplitRatios).decimalPlaces(defaultDecimalPlaces).toNumber(); | |
}; |
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
export const applySplitsRatiosToMatchingDividendAmount = (dividendAmount, applicableSplits) => applicableSplits.reduce((acc, ratio) => { | |
return new BigNumber(acc).multipliedBy(ratio).toNumber(); | |
}, dividendAmount); |
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
export const adjustDividendAmountForSplits = (dividend, splits) => { | |
const dividendAmount = new BigNumber(dividend.amount); | |
const applicableSplits = findApplicableSplitsAgainstDividendYear(dividend.exDate, splits); | |
const divAmountWithAppliedSplitRatios = applySplitsRatiosToMatchingDividendAmount(dividendAmount, applicableSplits); | |
return divAmountWithAppliedSplitRatios.decimalPlaces(defaultDecimalPlaces).toNumber(); | |
}; |
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
export const applySplitsRatiosToMatchingDividendAmount = (dividendAmount, applicableSplits) => applicableSplits.reduce((acc, ratio) => { | |
const amountWithAppliedSplitRatio = acc.multipliedBy(ratio); | |
return amountWithAppliedSplitRatio; | |
}, dividendAmount); |
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
export const findApplicableSplitsAgainstDividendYear = (dividendYear, splits) => { | |
const formattedDividendYear = Number(moment(dividendYear).format('X')); | |
return splits.reduce((acc, split) => { | |
const formattedExDate = Number(moment(split.exDate).format('X')); | |
return formattedExDate > formattedDividendYear ? | |
[ | |
...acc, | |
split.ratio |
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
import BigNumber from 'bignumber.js'; | |
import moment from 'moment'; | |
const defaultDecimalPlaces = 10; | |
const findApplicableSplitsAgainstDividendYear = (dividendYear, splits) => { | |
const formattedDividendYear = Number(moment(dividendYear).format('X')); | |
return splits.reduce((acc, split) => { | |
const formattedExDate = Number(moment(split.exDate).format('X')); |