mirror of
https://github.com/ConvoyPanel/panel.git
synced 2026-06-14 01:12:58 +08:00
20 lines
663 B
TypeScript
20 lines
663 B
TypeScript
import { Optimistic } from '@/lib/swr'
|
|
import { useMatch } from 'react-router-dom'
|
|
import useSWR, { Key, SWRResponse } from 'swr'
|
|
|
|
import getAddressPool from '@/api/admin/addressPools/getAddressPool'
|
|
import { AddressPool } from '@/api/admin/addressPools/getAddressPools'
|
|
|
|
|
|
export const getKey = (id: number): Key => ['admin.address-pools', id]
|
|
|
|
const useAddressPoolSWR = () => {
|
|
const match = useMatch('/admin/ipam/:id/*')
|
|
const id = parseInt(match!.params.id!)
|
|
|
|
return useSWR<AddressPool>(getKey(id), () => getAddressPool(id), {
|
|
revalidateOnMount: false,
|
|
}) as Optimistic<SWRResponse<AddressPool, any>>
|
|
}
|
|
|
|
export default useAddressPoolSWR |