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