25 lines
725 B
TypeScript
25 lines
725 B
TypeScript
import { useGetAssetVersions } from "infra/backend-api"
|
|
|
|
import type { AssetVersionsHistory } from "../types/assets-api.type"
|
|
|
|
/**
|
|
* История source versions выбранного asset.
|
|
*/
|
|
export const useAssetVersions = (publicId: string | null): AssetVersionsHistory => {
|
|
const versionsQuery = useGetAssetVersions(publicId)
|
|
|
|
const refresh = async () => {
|
|
await versionsQuery.mutate()
|
|
}
|
|
|
|
return {
|
|
currentVersion: versionsQuery.data?.currentVersion ?? null,
|
|
error: versionsQuery.error,
|
|
isLoading: versionsQuery.isLoading,
|
|
isRefreshing: versionsQuery.isValidating,
|
|
publicId: versionsQuery.data?.publicId ?? publicId,
|
|
refresh,
|
|
versions: versionsQuery.data?.versions ?? [],
|
|
}
|
|
}
|