gitscope
← marzneshin / v0.5.2 / dashboard/src/features/hosts/services/host.query.ts
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/features/hosts/services/host.query.ts · TypeScript
Blame Raw
 1import { HostType } from "@marzneshin/features/hosts";
 2import { useQuery } from "@tanstack/react-query";
 3import { fetch } from "@marzneshin/utils";
 4
 5export async function fetchHost({ queryKey }: { queryKey: [string, number] }): Promise<HostType> {
 6    return fetch(`/inbounds/hosts/${queryKey[1]}`);
 7}
 8
 9export const HostQueryFetchKey = "hosts";
10
11export const useHostQuery = ({ hostId }: { hostId: number }) => {
12    return useQuery({
13        queryKey: [HostQueryFetchKey, hostId],
14        queryFn: fetchHost,
15        initialData: undefined
16    })
17}