import { request } from './request.js';

/**
 * Admin API Endpoints
 * Refactored at the variable level for semantic clarity
 */
export const adminApi = {
  // Statistics & Dashboard
  getDashboardSummary: () => request('common/dashboard/summary'),

  // User Management
  fetchUsers: (params = {}) => {
    const query = new URLSearchParams(params).toString();
    return request(`user/fetch?${query}`);
  },
  updateUser: (id, data) => request(`user/update`, {
    method: 'POST',
    body: JSON.stringify({ id, ...data })
  }),
  deleteUser: (id) => request(`user/drop`, {
    method: 'POST',
    body: JSON.stringify({ id })
  }),

  // Server Management
  getNodes: () => request('server/manage/getNodes'),
  updateNode: (id, data) => request('server/manage/update', {
    method: 'POST',
    body: JSON.stringify({ id, ...data })
  }),

  // Plan Management
  getPlans: () => request('plan/fetch'),
  
  // Real-name Verification (Custom Extension)
  getRealNameRecords: (params = {}) => {
    const query = new URLSearchParams(params).toString();
    return request(`realname/fetch?${query}`);
  }
};
