import { ApiError, request } from './client';

export function deleteMediaItems(ids: number[]): Promise<void> {
  return request<void>('/api/v1/media-items', { body: { ids }, method: 'DELETE' });
}

export function messageFromMediaItemsError(error: unknown, fallback = 'Unable to delete media items'): string {
  if (error instanceof ApiError) {
    return error.detail ?? error.message;
  }

  if (error instanceof Error) {
    return error.message;
  }

  return fallback;
}
