move date formatting to a utility.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import type { ChangeEvent, FormEvent } from 'react';
|
import type { ChangeEvent, FormEvent } from 'react';
|
||||||
import type { Identifier } from '../../types/identifiers';
|
import type { Identifier } from '../../types/identifiers';
|
||||||
|
import { formatDateTime } from '../../utils/date';
|
||||||
|
|
||||||
interface ApiTokenEntry {
|
interface ApiTokenEntry {
|
||||||
id?: Identifier;
|
id?: Identifier;
|
||||||
@@ -61,17 +62,6 @@ interface ApiTokensSectionProps {
|
|||||||
onRefreshCapabilities?: () => void;
|
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 = ({
|
const ApiTokensSection = ({
|
||||||
tokens = [],
|
tokens = [],
|
||||||
loading = false,
|
loading = false,
|
||||||
|
|||||||
@@ -1,17 +1,7 @@
|
|||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
import type { FormEvent } from 'react';
|
import type { FormEvent } from 'react';
|
||||||
import type { PasskeyRecord, RegisterPasskeyResult } from '../usePasskeys';
|
import type { PasskeyRecord, RegisterPasskeyResult } from '../usePasskeys';
|
||||||
|
import { formatDateTime } from '../../utils/date';
|
||||||
const formatDateTime = (value) => {
|
|
||||||
if (!value) {
|
|
||||||
return '—';
|
|
||||||
}
|
|
||||||
const timestamp = new Date(value);
|
|
||||||
if (Number.isNaN(timestamp.getTime())) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
return timestamp.toLocaleString();
|
|
||||||
};
|
|
||||||
|
|
||||||
interface PasskeysSectionProps {
|
interface PasskeysSectionProps {
|
||||||
passkeys?: PasskeyRecord[];
|
passkeys?: PasskeyRecord[];
|
||||||
|
|||||||
Reference in New Issue
Block a user