22 lines
698 B
TypeScript
22 lines
698 B
TypeScript
|
|
import { useGetAsset, useGetAssetVariants } from "infra/backend-api"
|
|||
|
|
|
|||
|
|
import type { AssetOverview } from "../types/assets-api.type"
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Данные выбранного asset и его variants.
|
|||
|
|
*/
|
|||
|
|
export const useAssetOverview = (publicId: string | null): AssetOverview => {
|
|||
|
|
const assetQuery = useGetAsset(publicId)
|
|||
|
|
const variantsQuery = useGetAssetVariants(
|
|||
|
|
publicId,
|
|||
|
|
assetQuery.data?.currentVersion ? String(assetQuery.data.currentVersion) : undefined,
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
asset: assetQuery.data ?? null,
|
|||
|
|
error: assetQuery.error ?? variantsQuery.error,
|
|||
|
|
isLoading: assetQuery.isLoading || variantsQuery.isLoading,
|
|||
|
|
variants: variantsQuery.data?.variants ?? [],
|
|||
|
|
}
|
|||
|
|
}
|