Files
cameleer-server/ui/src/api/queries/commands.ts

22 lines
590 B
TypeScript
Raw Normal View History

import { useMutation } from '@tanstack/react-query'
import { api } from '../client'
interface SendGroupCommandParams {
group: string
type: string
payload: Record<string, unknown>
}
export function useSendGroupCommand() {
return useMutation({
mutationFn: async ({ group, type, payload }: SendGroupCommandParams) => {
const { data, error } = await api.POST('/agents/groups/{group}/commands', {
params: { path: { group } },
body: { type, payload } as any,
})
if (error) throw new Error('Failed to send command')
return data!
},
})
}