Files
image-platform/apps/admin/src/business/assets/hooks/use-asset-versions.hook.ts
2026-05-12 07:54:32 +03:00

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 ?? [],
}
}