https://dev.kronoz.win/r/marzneshin.git
| 1 |
d636f3f |
Dawsh |
2y ago |
import { HostType } from "@marzneshin/modules/hosts"; |
| 2 |
d636f3f |
Dawsh |
2y ago |
import { useQuery } from "@tanstack/react-query"; |
| 3 |
d636f3f |
Dawsh |
2y ago |
import { fetch } from "@marzneshin/common/utils"; |
| 4 |
d636f3f |
Dawsh |
2y ago |
|
| 5 |
d636f3f |
Dawsh |
2y ago |
export async function fetchInbound({ queryKey }: { queryKey: [string, number] }): Promise<HostType> { |
| 6 |
d636f3f |
Dawsh |
2y ago |
return fetch(`/inbounds/${queryKey[1]}`); |
| 7 |
d636f3f |
Dawsh |
2y ago |
} |
| 8 |
d636f3f |
Dawsh |
2y ago |
|
| 9 |
d636f3f |
Dawsh |
2y ago |
export const HostQueryFetchKey = "inbounds"; |
| 10 |
d636f3f |
Dawsh |
2y ago |
|
| 11 |
d636f3f |
Dawsh |
2y ago |
export const useHostQuery = ({ inboundId }: { inboundId: number }) => { |
| 12 |
d636f3f |
Dawsh |
2y ago |
return useQuery({ |
| 13 |
d636f3f |
Dawsh |
2y ago |
queryKey: [HostQueryFetchKey, inboundId], |
| 14 |
d636f3f |
Dawsh |
2y ago |
queryFn: fetchInbound, |
| 15 |
d636f3f |
Dawsh |
2y ago |
initialData: undefined |
| 16 |
d636f3f |
Dawsh |
2y ago |
}) |
| 17 |
d636f3f |
Dawsh |
2y ago |
} |