diff --git a/src/config/store.ts b/src/config/store.ts index d4558ad22..6c0a45279 100644 --- a/src/config/store.ts +++ b/src/config/store.ts @@ -1,7 +1,6 @@ -import axios from 'axios'; import { create } from 'zustand'; +import { trcpProxyClient } from '~/utils/api'; import { ConfigType } from '../types/config'; -import { api, trcpProxyClient } from '~/utils/api'; export const useConfigStore = create((set, get) => ({ configs: [], diff --git a/src/tools/config/mutations/useCopyConfigMutation.tsx b/src/tools/config/mutations/useCopyConfigMutation.tsx deleted file mode 100644 index a5f2de91d..000000000 --- a/src/tools/config/mutations/useCopyConfigMutation.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { showNotification } from '@mantine/notifications'; -import { IconCheck, IconX } from '@tabler/icons-react'; -import { useMutation } from '@tanstack/react-query'; -import { useTranslation } from 'next-i18next'; -import { useConfigContext } from '../../../config/provider'; -import { ConfigType } from '../../../types/config'; -import { queryClient } from '../../server/configurations/tanstack/queryClient.tool'; - -export const useCopyConfigMutation = (configName: string) => { - const { config } = useConfigContext(); - const { t } = useTranslation(['settings/general/config-changer']); - - return useMutation({ - mutationKey: ['configs/copy', { configName }], - mutationFn: () => fetchCopy(configName, config), - onSuccess() { - showNotification({ - title: t('modal.copy.events.configCopied.title'), - icon: , - color: 'green', - autoClose: 1500, - radius: 'md', - message: t('modal.copy.events.configCopied.message', { configName }), - }); - // Invalidate a query to fetch new config - queryClient.invalidateQueries(['config/get-all']); - }, - onError() { - showNotification({ - title: t('modal.events.configNotCopied.title'), - icon: , - color: 'red', - autoClose: 1500, - radius: 'md', - message: t('modal.events.configNotCopied.message', { configName }), - }); - }, - }); -}; - -const fetchCopy = async (configName: string, config: ConfigType | undefined) => { - if (!config) { - throw new Error('config is not defiend'); - } - - const copiedConfig = config; - copiedConfig.configProperties.name = configName; - - const response = await fetch(`/api/configs/${configName}`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(config), - }); - return response.json(); -}; diff --git a/src/widgets/useNet/UsenetHistoryList.tsx b/src/widgets/useNet/UsenetHistoryList.tsx index a012e4689..1c129fb93 100644 --- a/src/widgets/useNet/UsenetHistoryList.tsx +++ b/src/widgets/useNet/UsenetHistoryList.tsx @@ -13,14 +13,13 @@ import { } from '@mantine/core'; import { useElementSize } from '@mantine/hooks'; import { IconAlertCircle } from '@tabler/icons-react'; -import { AxiosError } from 'axios'; import dayjs from 'dayjs'; import duration from 'dayjs/plugin/duration'; import { useTranslation } from 'next-i18next'; import { FunctionComponent, useState } from 'react'; import { useGetUsenetHistory } from '../../hooks/widgets/dashDot/api'; -import { humanFileSize } from '../../tools/humanFileSize'; import { parseDuration } from '../../tools/client/parseDuration'; +import { humanFileSize } from '../../tools/humanFileSize'; dayjs.extend(duration); @@ -65,7 +64,7 @@ export const UsenetHistoryList: FunctionComponent = ({ a > {t('modules/usenet:history.error.message')} - {(error as AxiosError)?.response?.data as string} + {error.message}