1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 05:19:39 +02:00
portainer/app/react/docker/containers/queries/gpus.tsx
Chaim Lev-Ari bed4257194
refactor(containers): migrate view to react [EE-2212] (#6577)
Co-authored-by: LP B <xAt0mZ@users.noreply.github.com>
2022-08-11 07:33:29 +03:00

29 lines
748 B
TypeScript

import { useQuery } from 'react-query';
import { EnvironmentId } from '@/portainer/environments/types';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { queryKeys } from './query-keys';
async function getContainerGpus(
environmentId: EnvironmentId,
containerId: string
) {
try {
const { data } = await axios.get<{ gpus: string }>(
`/docker/${environmentId}/containers/${containerId}/gpus`
);
return data.gpus;
} catch (err) {
throw parseAxiosError(err as Error);
}
}
export function useContainerGpus(
environmentId: EnvironmentId,
containerId: string
) {
return useQuery(queryKeys.gpus(environmentId, containerId), () =>
getContainerGpus(environmentId, containerId)
);
}