gitscope
← marzneshin / v0.3.0-alpha10 / dashboard/src/features/inbounds/services/inbounds.query.ts
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/features/inbounds/services/inbounds.query.ts · TypeScript
Blame Raw
 1
 2import { useQuery } from "@tanstack/react-query";
 3import { fetch } from "@marzneshin/utils";
 4import { InboundType } from "../types";
 5
 6export async function fetchInbounds(): Promise<InboundType[]> {
 7    return fetch('/inbounds').then((result) => {
 8        return result.items
 9    });
10}
11
12export const InboundsQueryFetchKey = "inbounds";
13
14export const useInboundsQuery = () => {
15    return useQuery({
16        queryKey: [InboundsQueryFetchKey],
17        queryFn: fetchInbounds,
18        initialData: []
19    })
20}