import { apiClient } from '@/lib/api/client';
import type { SystemConfig } from '@/types/config';

export const configsApi = {
  getAll: async (): Promise<SystemConfig[]> => {
    const response = await apiClient.get('/configs');
    return response.data.data;
  },

  update: async (key: string, value: string): Promise<SystemConfig> => {
    const response = await apiClient.put(`/configs/${key}`, { value });
    return response.data.data;
  },

  getTransferEnabled: async (): Promise<boolean> => {
    const response = await apiClient.get('/configs/transfer-enabled');
    return response.data.data.enabled;
  },

  setTransferEnabled: async (enabled: boolean): Promise<void> => {
    await apiClient.post('/configs/transfer-enabled', { enabled });
  },
};
