18 lines
723 B
TypeScript
18 lines
723 B
TypeScript
import useSWR from "swr"
|
|
import type { SWRConfiguration } from "swr"
|
|
|
|
import { backendApi } from "../client"
|
|
import type { AssetVersionsResponseDto } from "../generated/backend-api.generated"
|
|
|
|
export const getAssetVersionsKey = (publicId: string) => ["backend-api", "assets", "versions", publicId] as const
|
|
|
|
/**
|
|
* Получение истории source versions asset.
|
|
*/
|
|
export const useGetAssetVersions = (publicId: string | null, config?: SWRConfiguration<AssetVersionsResponseDto>) => {
|
|
const key = publicId !== null ? getAssetVersionsKey(publicId) : null
|
|
const fetcher = () => backendApi.assets.listAssetVersions({ publicId: publicId ?? "" })
|
|
|
|
return useSWR<AssetVersionsResponseDto>(key, fetcher, config)
|
|
}
|