feat: add gender field mapping

This commit is contained in:
Sérgio Salgado 2021-06-21 18:21:45 +01:00 committed by Josh Harvey
parent ae3aaa8258
commit 82b7e40220

View file

@ -14,11 +14,26 @@ import { getName } from '../helper'
import Field from './Field'
const formatGender = field => {
const genderMap = {
1: 'M',
2: 'F'
}
const isNumber = s => {
if (typeof s !== 'string') return false
return !isNaN(s) && !isNaN(parseInt(s))
}
return !isNumber(field) ? field : genderMap[field]
}
const IdDataCard = memo(({ customerData, updateCustomer }) => {
const idData = R.path(['idCardData'])(customerData)
const rawExpirationDate = R.path(['expirationDate'])(idData)
const country = R.path(['country'])(idData)
const rawDob = R.path(['dateOfBirth'])(idData)
console.log('customer', customerData)
const elements = [
{
@ -46,7 +61,9 @@ const IdDataCard = memo(({ customerData, updateCustomer }) => {
},
{
header: 'Gender',
display: R.path(['gender'])(idData),
display: formatGender(
R.path(['gender'])(idData) ?? R.path(['sex'])(idData)
),
size: 80
},
{