import api from '../../../utils/api';
import { useMutation } from '@tanstack/react-query';

export function useCreateAgent() {
  return useMutation({
    mutationFn: async (payload: { name?: string }) => {
      const body = {
        name: payload.name || 'default',
        type: 'Agent',
        voice: 'aura-zeus-en',
        image: '',
        chat_first_message: 'TestAgentWithStoreAndRAG',
        chat_prompt: 'TestAgentWithStoreAndRAG',
        call_first_message: 'TestAgentWithStoreAndRAG',
        call_prompt: 'TestAgentWithStoreAndRAG',
        ai_model: 'gemini',
        idle_reminder: false,
        call_cut_ability: false,
        call_limit_duration: 30,
        call_transfer: false,
        send_message: false,
        real_time_booking: false,
      };
      await api.post('/agent', body);
      return null;
    },
  });
}

export function useUpdateAgentDetails() {
  return useMutation({
    mutationFn: async ({ _id, payload }: { _id: string; payload: any }) => {
      await api.put(`/agent/${_id}`, payload);
    },
  });
}
