🏗️ Migrate dnshole summary to tRPC

This commit is contained in:
Meier Lukas
2023-06-10 14:04:32 +02:00
parent 1fd93e6f49
commit 9b6ce9e1f6
4 changed files with 111 additions and 20 deletions

View File

@@ -1,4 +1,3 @@
import { useTranslation } from 'next-i18next';
import { Card, Center, Container, Stack, Text } from '@mantine/core';
import {
IconAd,
@@ -7,11 +6,13 @@ import {
IconSearch,
IconWorldWww,
} from '@tabler/icons-react';
import { useTranslation } from 'next-i18next';
import { useConfigContext } from '~/config/provider';
import { api } from '~/utils/api';
import { formatNumber } from '../../tools/client/math';
import { defineWidget } from '../helper';
import { WidgetLoading } from '../loading';
import { IWidget } from '../widgets';
import { formatNumber } from '../../tools/client/math';
import { useDnsHoleSummeryQuery } from './query';
const definition = defineWidget({
id: 'dns-hole-summary',
@@ -179,4 +180,17 @@ function DnsHoleSummaryWidgetTile({ widget }: DnsHoleSummaryWidgetProps) {
);
}
export const useDnsHoleSummeryQuery = () => {
const { name: configName } = useConfigContext();
return api.dnsHole.summary.useQuery(
{
configName: configName!,
},
{
refetchInterval: 3 * 60 * 1000,
}
);
};
export default definition;