import { mutationOptions } from '@tanstack/react-query';
import { invalidatePeopleData } from '@/lib/query-invalidation';
import { createUser, updateUser, deleteUser } from './service';
import type { UserMutationPayload } from './types';

export const createUserMutation = mutationOptions({
  mutationFn: (data: UserMutationPayload) => createUser(data),
  onSuccess: () => invalidatePeopleData()
});

export const updateUserMutation = mutationOptions({
  mutationFn: ({ id, values }: { id: string; values: UserMutationPayload }) =>
    updateUser(id, values),
  onSuccess: () => invalidatePeopleData()
});

export const deleteUserMutation = mutationOptions({
  mutationFn: (id: string) => deleteUser(id),
  onSuccess: () => invalidatePeopleData()
});
