fix: guard against null expirationDate

fix: NaN age
This commit is contained in:
Nikola Ubavic 2022-01-19 15:05:34 +01:00
parent 0d88e6eba2
commit 3d8281fb73

View file

@ -116,16 +116,27 @@ const DetailsRow = ({ it: tx, timezone }) => {
const exchangeRate = BigNumber(fiat / crypto).toFormat(2) const exchangeRate = BigNumber(fiat / crypto).toFormat(2)
const displayExRate = `1 ${tx.cryptoCode} = ${exchangeRate} ${tx.fiatCode}` const displayExRate = `1 ${tx.cryptoCode} = ${exchangeRate} ${tx.fiatCode}`
const parseDateString = d => parse(new Date(), 'yyyyMMdd', d)
const customer = tx.customerIdCardData && { const customer = tx.customerIdCardData && {
name: `${onlyFirstToUpper( name: `${onlyFirstToUpper(
tx.customerIdCardData.firstName tx.customerIdCardData.firstName
)} ${onlyFirstToUpper(tx.customerIdCardData.lastName)}`, )} ${onlyFirstToUpper(tx.customerIdCardData.lastName)}`,
age: differenceInYears(tx.customerIdCardData.dateOfBirth, new Date()), age:
(tx.customerIdCardData.dateOfBirth &&
differenceInYears(
parseDateString(tx.customerIdCardData.dateOfBirth),
new Date()
)) ??
'',
country: tx.customerIdCardData.country, country: tx.customerIdCardData.country,
idCardNumber: tx.customerIdCardData.documentNumber, idCardNumber: tx.customerIdCardData.documentNumber,
idCardExpirationDate: format('yyyy-MM-dd')( idCardExpirationDate:
parse(new Date(), 'yyyyMMdd', tx.customerIdCardData.expirationDate) (tx.customerIdCardData.expirationDate &&
) format('yyyy-MM-dd')(
parseDateString(tx.customerIdCardData.expirationDate)
)) ??
''
} }
const from = sub({ minutes: MINUTES_OFFSET }, tx.created) const from = sub({ minutes: MINUTES_OFFSET }, tx.created)