Files
image-platform/apps/admin/src/infra/backend-api/hooks/use-get-asset.hook.ts
S.Gromov 6a018826f5 feat: добавить рабочий dashboard admin
- добавлен Mantine theme provider и AppShell layout\n- сгенерирован Backend API клиент и добавлены infra/business хуки\n- добавлены таблица assets, detail/presets panels и create asset modal
2026-05-05 15:02:55 +03:00

18 lines
629 B
TypeScript

import useSWR from "swr"
import type { SWRConfiguration } from "swr"
import { backendApi } from "../client"
import type { AssetResponseDto } from "../generated/backend-api.generated"
export const getAssetKey = (publicId: string) => ["backend-api", "assets", "detail", publicId] as const
/**
* Получение asset по publicId.
*/
export const useGetAsset = (publicId: string | null, config?: SWRConfiguration) => {
const key = publicId !== null ? getAssetKey(publicId) : null
const fetcher = () => backendApi.assets.getAsset({ publicId: publicId ?? "" })
return useSWR<AssetResponseDto>(key, fetcher, config)
}