From ebb55637cb2dadb0f09b435c266c4e11e32d9aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 21 Jun 2021 18:21:45 +0100 Subject: [PATCH] feat: add gender field mapping --- .../pages/Customers/components/IdDataCard.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/new-lamassu-admin/src/pages/Customers/components/IdDataCard.js b/new-lamassu-admin/src/pages/Customers/components/IdDataCard.js index e04ed564..07c2ffd5 100644 --- a/new-lamassu-admin/src/pages/Customers/components/IdDataCard.js +++ b/new-lamassu-admin/src/pages/Customers/components/IdDataCard.js @@ -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 }, {