diff --git a/src/components/ActiveConfigurationsTable/index.tsx b/src/components/ActiveConfigurationsTable/index.tsx index 906cdf5..40e260f 100644 --- a/src/components/ActiveConfigurationsTable/index.tsx +++ b/src/components/ActiveConfigurationsTable/index.tsx @@ -16,6 +16,7 @@ import { ColumnsType } from 'antd/es/table' import './active-configurations-table.scss' import dayjs from 'dayjs' import CanEdit from '@components/CanEdit' +import { dateFormats } from '@constants/date.ts' const ActiveConfigurationsTable: FC = @@ -167,7 +168,7 @@ const ActiveConfigurationsTable: FC = key: 'updatedAt', align: 'center', render: (value: string) => { - return dayjs(value).format('HH:mm:ss DD.MM.YYYY') + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/components/CompareVersionModal/index.tsx b/src/components/CompareVersionModal/index.tsx index 177f6cb..e11dddb 100644 --- a/src/components/CompareVersionModal/index.tsx +++ b/src/components/CompareVersionModal/index.tsx @@ -19,6 +19,7 @@ import { VersionType } from '@type/version.type' import './compare-version-modal.scss' import dayjs from 'dayjs' +import { dateFormats } from '@constants/date.ts' const Original = CodeMirrorMerge.Original @@ -52,7 +53,7 @@ const CompareVersionModal: FC = ({ title: 'Создано', dataIndex: 'createdAt', render: (value: string) => { - return dayjs(value).format('HH:mm:ss DD.MM.YYYY') + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/components/TokenContent/index.tsx b/src/components/TokenContent/index.tsx index 498ef45..dbb2f7f 100644 --- a/src/components/TokenContent/index.tsx +++ b/src/components/TokenContent/index.tsx @@ -24,6 +24,7 @@ import tokensApi from '@services/tokensService.ts' import './tokens.scss' import CanEdit from '@components/CanEdit' +import { dateFormats } from '@constants/date.ts' const { FormSelect } = FormComponents const { EmptyData } = Layout @@ -120,8 +121,7 @@ const TokenContent = ({ id }: TokenPropTypes) => { dataIndex: 'createdAt', key: 'createdAt', render: (record) => { - const FULL_DATE_FORMAT = 'DD-MM-YYYY/HH:mm' - const formatTime = dayjs(record.createdAt).format(FULL_DATE_FORMAT) + const formatTime = dayjs(record.createdAt).format(dateFormats.fullFormat) return
{formatTime}
} }, @@ -142,10 +142,9 @@ const TokenContent = ({ id }: TokenPropTypes) => { dataIndex: 'expireTime', key: 'expireTime', render: (value, record) => { - const FULL_DATE_FORMAT = 'DD-MM-YYYY, HH:mm' const formatTime = dayjs(record.createdAt) .add(record.expireTime) - .format(FULL_DATE_FORMAT) + .format(dateFormats.fullFormat) return value > 0 ? {formatTime} : Никогда } diff --git a/src/constants/date.ts b/src/constants/date.ts new file mode 100644 index 0000000..9cc4087 --- /dev/null +++ b/src/constants/date.ts @@ -0,0 +1,6 @@ +type FormattersKey = 'fullFormat' + + +export const dateFormats:Record = { + fullFormat: 'DD.MM.YYYY HH:mm:ss' +} diff --git a/src/pages/AllVersionsPage/index.tsx b/src/pages/AllVersionsPage/index.tsx index 1e5f292..3a89b51 100644 --- a/src/pages/AllVersionsPage/index.tsx +++ b/src/pages/AllVersionsPage/index.tsx @@ -28,6 +28,7 @@ import { PermissionKeysType } from '@type/roles.type.ts' import { VersionType } from '@type/version.type.ts' import './all-versions-page.scss' +import { dateFormats } from '@constants/date.ts' const AllVersionsPage = () => { @@ -157,7 +158,7 @@ const AllVersionsPage = () => { title: 'Создано', dataIndex: 'createdAt', render: (value: string) => { - return dayjs(value).format('HH:mm:ss DD.MM.YYYY') + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/pages/ConnectionsPage/index.tsx b/src/pages/ConnectionsPage/index.tsx index 171ef05..81f9a8e 100644 --- a/src/pages/ConnectionsPage/index.tsx +++ b/src/pages/ConnectionsPage/index.tsx @@ -16,6 +16,7 @@ import { PermissionKeysType } from '@type/roles.type.ts' import './connections.scss' import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' +import { dateFormats } from '@constants/date.ts' const Connections = () => { const { data: ConnectionsList = [], isLoading: isModulesLoading } = @@ -51,7 +52,7 @@ const Connections = () => { } const formatFullDate = (obj: string) => - dayjs(obj).format('YYYY-MM-DD, HH:mm:ss') + dayjs(obj).format(dateFormats.fullFormat) const keySelector = ({ address: { ip, port }, diff --git a/src/pages/SecurityLogPage/index.tsx b/src/pages/SecurityLogPage/index.tsx index d1b70c1..f48f057 100644 --- a/src/pages/SecurityLogPage/index.tsx +++ b/src/pages/SecurityLogPage/index.tsx @@ -16,6 +16,8 @@ import { LogType } from '@type/log.type' import { PermissionKeysType } from '@type/roles.type' import './security-log-page.scss' +import dayjs from 'dayjs' +import { dateFormats } from '@constants/date.ts' const limit = 10 @@ -75,8 +77,7 @@ const SecurityLogPage = () => { dataIndex: 'createdAt', key: 'createdAt', render: (value) => { - const date = new Date(value) - return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}` + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/pages/SessionsPage/index.tsx b/src/pages/SessionsPage/index.tsx index 4825e49..1cb9e86 100644 --- a/src/pages/SessionsPage/index.tsx +++ b/src/pages/SessionsPage/index.tsx @@ -29,6 +29,8 @@ import { PermissionKeysType } from '@type/roles.type.ts' import { SessionType } from '@type/session.type' import './sessions-page.scss' +import dayjs from 'dayjs' +import { dateFormats } from '@constants/date.ts' const limit = 10 @@ -96,8 +98,7 @@ const SessionsPage = () => { dataIndex: 'createdAt', key: 'createdAt', render: (value) => { - const date = new Date(value) - return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}` + return dayjs(value).format(dateFormats.fullFormat) } }, { @@ -105,8 +106,7 @@ const SessionsPage = () => { dataIndex: 'expiredAt', key: 'expiredAt', render: (value) => { - const date = new Date(value) - return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}` + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/pages/UserEditor/index.tsx b/src/pages/UserEditor/index.tsx index f7b3f4a..407e848 100644 --- a/src/pages/UserEditor/index.tsx +++ b/src/pages/UserEditor/index.tsx @@ -1,10 +1,12 @@ import { ArrowLeftOutlined, SaveOutlined } from '@ant-design/icons' import { Button, message, Spin } from 'antd' +import dayjs from 'dayjs' import { FormComponents } from 'isp-ui-kit' import { useEffect } from 'react' import { useForm } from 'react-hook-form' import { useLocation, useNavigate } from 'react-router-dom' +import { dateFormats } from '@constants/date.ts' import { ValidationRules } from '@constants/form/validationRules.ts' import { findExclusiveRole } from '@utils/roleUtils.ts' @@ -23,6 +25,7 @@ import { LabelItem } from 'isp-ui-kit/dist/FormComponents/formTypes' import './user-editor.scss' + const UserEditor = () => { const location = useLocation() const navigate = useNavigate() @@ -166,9 +169,7 @@ const UserEditor = () => { {state.lastSessionCreatedAt && ( <> Последняя сессия   - {new Date(state.lastSessionCreatedAt).toLocaleDateString()} -   - {new Date(state.lastSessionCreatedAt).toLocaleTimeString()} + {dayjs(state.lastSessionCreatedAt).format(dateFormats.fullFormat)} )} diff --git a/src/pages/UsersPage/index.tsx b/src/pages/UsersPage/index.tsx index 591e111..2c05acb 100644 --- a/src/pages/UsersPage/index.tsx +++ b/src/pages/UsersPage/index.tsx @@ -25,6 +25,8 @@ import { PermissionKeysType } from '@type/roles.type.ts' import { UserType } from '@type/user.type.ts' import './users-page.scss' +import dayjs from 'dayjs' +import { dateFormats } from '@constants/date.ts' const UsersPage = () => { const { data: allUsers = [], isLoading: isUsersLoading } = @@ -124,7 +126,7 @@ const UsersPage = () => { dataIndex: 'lastSessionCreatedAt', key: 'lastSessionCreatedAt', render: (value: string) => - value ? new Date(value).toLocaleDateString() : '' + value ? dayjs(value).format(dateFormats.fullFormat) : '' }, { dataIndex: 'actions',