'use client';

import { useMutation, UseMutationOptions } from '@tanstack/react-query';
import { generateAvatarsAction } from '@/app/actions/generateAvatarsAction';
import { Result } from '@/lib/contracts/Result';

interface GenerateAvatarsParams {
  userId: string;
  facePhotoData: string;
  suitColor: string;
}

interface GenerateAvatarsResult {
  success: boolean;
  avatarUrls?: string[];
}

export function useGenerateAvatars(
  options?: Omit<UseMutationOptions<Result<GenerateAvatarsResult, string>, Error, GenerateAvatarsParams>, 'mutationFn'>
) {
  return useMutation<Result<GenerateAvatarsResult, string>, Error, GenerateAvatarsParams>({
    mutationFn: async (params) => {
      return await generateAvatarsAction(params);
    },
    ...options,
  });
}
