Remove useTranslation hook from util functions

This commit is contained in:
Rob Gries
2020-10-02 18:17:48 +00:00
parent 1c25ffe037
commit 370de9ec47
5 changed files with 61 additions and 56 deletions

View File

@ -1,9 +1,7 @@
import dayjs from 'dayjs';
import { get, isEmpty } from 'lodash';
import { useTranslation } from 'react-i18next';
export const getModalText = (isEditMode, type) => {
const { t } = useTranslation();
export const getModalText = (isEditMode, type, t) => {
return isEditMode
? `${t('shared.buttons.edit')} ${type}`
: `${t('shared.buttons.add')} ${type}`;
@ -26,8 +24,7 @@ export const formatDate = ({ date, language = 'en' }) => {
return dayjs(date).locale(language.substr(0, 2)).format('MMMM YYYY');
};
export const formatDateRange = ({ startDate, endDate, language = 'en' }) => {
const { t } = useTranslation();
export const formatDateRange = ({ startDate, endDate, language = 'en' }, t) => {
const start = `${dayjs(startDate)
.locale(language.substr(0, 2))
.format('MMMM YYYY')}`;