import { request } from "./client";

// Stats & users
export const adminStats = (token) => request("GET", "/admin/stats", token);

export const adminListUsers = (token) => request("GET", "/admin/users", token);

export const adminCreateUser = (token, data) =>
  request("POST", "/admin/users", token, data);

export const adminUpdateUser = (token, userId, data) =>
  request("PUT", `/admin/users/${userId}`, token, data);

export const adminDeleteUser = (token, userId) =>
  request("DELETE", `/admin/users/${userId}`, token);

export const adminListChats = (token) => request("GET", "/admin/chats", token);

// App settings
export const adminGetAppSettings = (token) =>
  request("GET", "/admin/app-settings", token);

export const adminUpdateAppSettings = (token, data) =>
  request("PUT", "/admin/app-settings", token, data);

// Models
export const adminGetModels = (token) => request("GET", "/admin/models", token);

// Permission defaults
export const adminGetPermissionDefaults = (token) =>
  request("GET", "/admin/permissions/defaults", token);

export const adminUpdatePermissionDefaults = (token, data) =>
  request("PUT", "/admin/permissions/defaults", token, data);

export const adminApplyDefaults = (token) =>
  request("POST", "/admin/permissions/apply-defaults", token);

// User permissions
export const adminGetUserPermissions = (token, userId) =>
  request("GET", `/admin/users/${userId}/permissions`, token);

export const adminUpdateUserPermissions = (token, userId, data) =>
  request("PUT", `/admin/users/${userId}/permissions`, token, data);
