From 834d4f641b6f830f3864350bac92dee7c323b42c Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Thu, 4 Dec 2025 16:21:00 +0100 Subject: [PATCH] move date formatting to a utility. --- frontend/src/settings/sections/ApiTokensSection.tsx | 12 +----------- frontend/src/settings/sections/PasskeysSection.tsx | 12 +----------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/frontend/src/settings/sections/ApiTokensSection.tsx b/frontend/src/settings/sections/ApiTokensSection.tsx index abb292c..4f5561a 100644 --- a/frontend/src/settings/sections/ApiTokensSection.tsx +++ b/frontend/src/settings/sections/ApiTokensSection.tsx @@ -1,6 +1,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import type { ChangeEvent, FormEvent } from 'react'; import type { Identifier } from '../../types/identifiers'; +import { formatDateTime } from '../../utils/date'; interface ApiTokenEntry { id?: Identifier; @@ -61,17 +62,6 @@ interface ApiTokensSectionProps { onRefreshCapabilities?: () => void; } -const formatDateTime = (value) => { - if (!value) { - return '—'; - } - const timestamp = new Date(value); - if (Number.isNaN(timestamp.getTime())) { - return value; - } - return timestamp.toLocaleString(); -}; - const ApiTokensSection = ({ tokens = [], loading = false, diff --git a/frontend/src/settings/sections/PasskeysSection.tsx b/frontend/src/settings/sections/PasskeysSection.tsx index ad1e4f4..71af6f7 100644 --- a/frontend/src/settings/sections/PasskeysSection.tsx +++ b/frontend/src/settings/sections/PasskeysSection.tsx @@ -1,17 +1,7 @@ import { useCallback, useMemo, useState } from 'react'; import type { FormEvent } from 'react'; import type { PasskeyRecord, RegisterPasskeyResult } from '../usePasskeys'; - -const formatDateTime = (value) => { - if (!value) { - return '—'; - } - const timestamp = new Date(value); - if (Number.isNaN(timestamp.getTime())) { - return value; - } - return timestamp.toLocaleString(); -}; +import { formatDateTime } from '../../utils/date'; interface PasskeysSectionProps { passkeys?: PasskeyRecord[];