From 6f2e7be85254775bebd34d6aecc3aa7e538e54d8 Mon Sep 17 00:00:00 2001 From: Youssef Date: Tue, 8 Feb 2022 14:12:53 +0100 Subject: [PATCH] refactor: use locationSettings in application for date format --- .../component/application/EditApplication.tsx | 18 ++++++++++-------- frontend/src/component/menu/routes.js | 2 -- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/component/application/EditApplication.tsx b/frontend/src/component/application/EditApplication.tsx index 5bb95972df..d431754d4f 100644 --- a/frontend/src/component/application/EditApplication.tsx +++ b/frontend/src/component/application/EditApplication.tsx @@ -11,10 +11,9 @@ import { } from '@material-ui/core'; import { Link as LinkIcon } from '@material-ui/icons'; import ConditionallyRender from '../common/ConditionallyRender/ConditionallyRender'; -// import { -// formatFullDateTimeWithLocale, -// formatDateWithLocale, -// } from '../common/util'; +import { + formatDateWithLocale, +} from '../common/util'; import { UPDATE_APPLICATION } from '../providers/AccessProvider/permissions'; import ApplicationView from './ApplicationView'; import ApplicationUpdate from './ApplicationUpdate'; @@ -26,6 +25,7 @@ import AccessContext from '../../contexts/AccessContext'; import useApplicationsApi from '../../hooks/api/actions/useApplicationsApi/useApplicationsApi'; import useApplication from '../../hooks/api/getters/useApplication/useApplication'; import { useHistory, useParams } from 'react-router-dom'; +import { useLocationSettings } from '../../hooks/useLocationSettings'; const EditApplication = () => { const history = useHistory(); @@ -34,6 +34,9 @@ const EditApplication = () => { const { appName, url, description, icon = 'apps', createdAt } = application; const { hasAccess } = useContext(AccessContext); const { deleteApplication } = useApplicationsApi(); + const { locationSettings } = useLocationSettings(); + + console.log(locationSettings) const [loading, setLoading] = useState(true); const [showDialog, setShowDialog] = useState(false); @@ -48,8 +51,8 @@ const EditApplication = () => { setShowDialog(!showDialog); }; - // missing the settings hook (locale) - //const formatDate = v => formatDateWithLocale(v, locale); + const formatDate = (v: Date) => + formatDateWithLocale(v, locationSettings.locale); const onDeleteApplication = async (evt: Event) => { evt.preventDefault(); @@ -134,8 +137,7 @@ const EditApplication = () => {
{description || ''} - {/* // need to use formatDate once we have the useSettings hook ready */} - Created: {createdAt} + Created: {formatDate(createdAt)}