From a129db5fb2cbea852cf6a02e0406ddae314258c9 Mon Sep 17 00:00:00 2001 From: Oliver Lewandowski <109145288+olewandowski1@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:41:20 +0200 Subject: [PATCH] hotfix: fix trimming date (#82) --- src/utils/utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index fde2828..8ea203e 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1,7 +1,7 @@ /* eslint-disable import/prefer-default-export */ import { baseApiUrl, parseData } from '@openimis/fe-core'; -import { MPAY_BILL_URL, WORKER_VOUCHER_STATUS } from '../constants'; +import { EMPTY_STRING, MPAY_BILL_URL, WORKER_VOUCHER_STATUS } from '../constants'; import { fetchMutation } from '../actions'; const fetchMPayArgs = async (url) => { @@ -74,4 +74,8 @@ export const getLastMutationLog = async (dispatch, mutationId) => { export const isTheVoucherExpired = (voucher) => voucher.status === WORKER_VOUCHER_STATUS.EXPIRED || new Date(voucher.expiryDate) < new Date(); -export const trimDate = (date) => date.split('T')[0]; +export const trimDate = (date) => { + if (!date) return EMPTY_STRING; + + return date.split('T')?.[0] ?? date; +};