diff --git a/new-lamassu-admin/src/pages/Accounting/Accounting.js b/new-lamassu-admin/src/pages/Accounting/Accounting.js index 7f7b7f07..74d65a88 100644 --- a/new-lamassu-admin/src/pages/Accounting/Accounting.js +++ b/new-lamassu-admin/src/pages/Accounting/Accounting.js @@ -158,14 +158,14 @@ const Accounting = () => { width: 150, size: 'sm', textAlign: 'right', - view: it => formatDate(it.created, timezone, 'YYYY-MM-DD') + view: it => formatDate(it.created, timezone, 'yyyy-MM-dd') }, { header: 'Time', width: 150, size: 'sm', textAlign: 'right', - view: it => formatDate(it.created, timezone, 'YYYY-MM-DD') + view: it => formatDate(it.created, timezone, 'yyyy-MM-dd') } ] diff --git a/new-lamassu-admin/src/pages/Customers/CustomerData.js b/new-lamassu-admin/src/pages/Customers/CustomerData.js index e957211c..bb034bbd 100644 --- a/new-lamassu-admin/src/pages/Customers/CustomerData.js +++ b/new-lamassu-admin/src/pages/Customers/CustomerData.js @@ -1,6 +1,6 @@ import Grid from '@material-ui/core/Grid' import { makeStyles } from '@material-ui/core/styles' -import { differenceInYears, format } from 'date-fns/fp' +import { differenceInYears, parse, format } from 'date-fns/fp' import _ from 'lodash/fp' import * as R from 'ramda' import { useState, React } from 'react' @@ -115,13 +115,22 @@ const CustomerData = ({ customer, updateCustomer }) => { { name: 'birthDate', label: 'Birth Date', - value: (rawDob && format('yyyy-MM-dd', rawDob)) ?? '', + value: + (rawDob && + format('yyyy-MM-dd')(parse(new Date(), 'yyyyMMdd', rawDob))) ?? + '', component: TextInput }, { name: 'age', label: 'Age', - value: (rawDob && differenceInYears(rawDob, new Date())) ?? '', + value: + (rawDob && + differenceInYears( + parse(new Date(), 'yyyyMMdd', rawDob), + new Date() + )) ?? + '', component: TextInput }, { @@ -140,7 +149,11 @@ const CustomerData = ({ customer, updateCustomer }) => { name: 'expirationDate', label: 'Expiration Date', value: - (rawExpirationDate && format('yyyy-MM-dd', rawExpirationDate)) ?? '', + (rawExpirationDate && + format('yyyy-MM-dd')( + parse(new Date(), 'yyyyMMdd', rawExpirationDate) + )) ?? + '', component: TextInput } ] diff --git a/new-lamassu-admin/src/pages/Customers/components/IdDataCard.js b/new-lamassu-admin/src/pages/Customers/components/IdDataCard.js index 5da592ff..3083283f 100644 --- a/new-lamassu-admin/src/pages/Customers/components/IdDataCard.js +++ b/new-lamassu-admin/src/pages/Customers/components/IdDataCard.js @@ -1,5 +1,5 @@ import { Box } from '@material-ui/core' -import { differenceInYears, format } from 'date-fns/fp' +import { differenceInYears, format, parse } from 'date-fns/fp' import * as R from 'ramda' import React, { memo } from 'react' @@ -9,7 +9,6 @@ import { OVERRIDE_REJECTED } from 'src/pages/Customers/components/propertyCard' import { ifNotNull } from 'src/utils/nullCheck' -import { toUtc } from 'src/utils/timezones' import { getName } from '../helper' @@ -34,15 +33,21 @@ const IdDataCard = memo(({ customerData, updateCustomer }) => { }, { header: 'Birth Date', - display: ifNotNull(rawDob, format('YYYY-MM-DD', rawDob)), + display: + (rawDob && + format('yyyy-MM-dd')(parse(new Date(), 'yyyyMMdd', rawDob))) ?? + '', size: 110 }, { header: 'Age', - display: ifNotNull( - rawDob, - differenceInYears(toUtc(rawDob), toUtc(new Date())) - ), + display: + (rawDob && + differenceInYears( + parse(new Date(), 'yyyyMMdd', rawDob), + new Date() + )) ?? + '', size: 50 }, { @@ -59,7 +64,7 @@ const IdDataCard = memo(({ customerData, updateCustomer }) => { header: 'Expiration Date', display: ifNotNull( rawExpirationDate, - format('YYYY-MM-DD', rawExpirationDate) + format('yyyy-MM-dd', rawExpirationDate) ) } ] diff --git a/new-lamassu-admin/src/pages/Customers/components/TransactionsList.js b/new-lamassu-admin/src/pages/Customers/components/TransactionsList.js index 5b150b51..a3c16f06 100644 --- a/new-lamassu-admin/src/pages/Customers/components/TransactionsList.js +++ b/new-lamassu-admin/src/pages/Customers/components/TransactionsList.js @@ -50,10 +50,9 @@ const TransactionsList = ({ customer, data, loading, locale }) => { size: 142, value: !R.isNil(timezone) && - ifNotNull( - customer.lastActive, - formatDate(customer.lastActive, timezone, 'yyyy-MM-d') - ) + ((customer.lastActive && + formatDate(customer.lastActive, timezone, 'yyyy-MM-d')) ?? + '') }, { header: 'Last transaction', diff --git a/new-lamassu-admin/src/pages/MachineLogs.js b/new-lamassu-admin/src/pages/MachineLogs.js index 3075eb80..277b82c5 100644 --- a/new-lamassu-admin/src/pages/MachineLogs.js +++ b/new-lamassu-admin/src/pages/MachineLogs.js @@ -142,7 +142,7 @@ const Logs = () => { {timezone && - formatDate(log.timestamp, timezone, 'YYYY-MM-DD HH:mm')} + formatDate(log.timestamp, timezone, 'yyyy-MM-dd HH:mm')} {log.logLevel} {log.message} diff --git a/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js b/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js index be484692..3e13740b 100644 --- a/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js +++ b/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js @@ -187,7 +187,7 @@ const CashboxHistory = ({ machines, currency }) => { header: 'Date', width: 135, textAlign: 'right', - view: it => formatDate(it.created, timezone, 'YYYY-MM-DD') + view: it => formatDate(it.created, timezone, 'yyyy-MM-dd') }, { name: 'time', diff --git a/new-lamassu-admin/src/pages/Maintenance/MachineDetailsCard.js b/new-lamassu-admin/src/pages/Maintenance/MachineDetailsCard.js index a81e6a5f..0aaf1ea2 100644 --- a/new-lamassu-admin/src/pages/Maintenance/MachineDetailsCard.js +++ b/new-lamassu-admin/src/pages/Maintenance/MachineDetailsCard.js @@ -99,7 +99,7 @@ const MachineDetailsRow = ({ it: machine, onActionSuccess, timezone }) => { {timezone && - formatDate(machine.pairedAt, timezone, 'YYYY-MM-DD HH:mm:ss')} + formatDate(machine.pairedAt, timezone, 'yyyy-MM-dd HH:mm:ss')}