Skip to content

Instantly share code, notes, and snippets.

@ayoola-solomon
Created March 7, 2018 15:37
Show Gist options
  • Save ayoola-solomon/e3111373760ce18404d89bcc88363a8f to your computer and use it in GitHub Desktop.
Save ayoola-solomon/e3111373760ce18404d89bcc88363a8f to your computer and use it in GitHub Desktop.
const monthlyRateColumn = ({ showDuration, monthlyRate, duration }) => ({
text: columnText('currency', monthlyRate),
subText: showDuration && (
<span>
{bankItemContent.rate.monthly}{' '}
<Text fontWeight={fontWeight.BOLD}>
{contentWithParams(bankItemContent.rate.duration, { duration })}
</Text>
</span>
),
});
const effectiveInterestColumn = ({
minEffectiveInterest,
maxEffectiveInterest,
eitherOrEffectiveInterest,
specialOfferType,
}) => ({
text: columnText('percentage', minEffectiveInterest),
subText:
isValidRate(maxEffectiveInterest) &&
(eitherOrEffectiveInterest
? contentWithParams(bankItemContent.rate.either, {
rate: maxEffectiveInterest,
})
: contentWithParams(bankItemContent.rate.effective, {
rate: maxEffectiveInterest,
})),
highlighted: Boolean(specialOfferType),
});
const debitInterestColumn = ({
minDebtInterestRate,
maxDebtInterestRate,
eitherOrEffectiveInterest,
}) => ({
text: columnText('percentage', minDebtInterestRate),
subText:
isValidRate(maxDebtInterestRate) &&
(eitherOrEffectiveInterest
? contentWithParams(bankItemContent.rate.either, {
rate: maxDebtInterestRate,
})
: contentWithParams(bankItemContent.rate.effective, {
rate: maxDebtInterestRate,
})),
});
@keshant
Copy link

keshant commented Mar 7, 2018

I would rather combine only the last two methods :)

const interestColumn = ({
  minInterestRate,
  maxInterestRate,
  eitherOrEffectiveInterest,
  specialOfferType = false,
}) => ({
  text: columnText('percentage', minInterestRate),
  subText:
  isValidRate(maxInterestRate) &&
  (eitherOrEffectiveInterest
    ? contentWithParams(bankItemContent.rate.either, {
      rate: maxInterestRate,
    })
    : contentWithParams(bankItemContent.rate.effective, {
      rate: maxInterestRate,
    })),
  highlighted: Boolean(specialOfferType),
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment