import { get, post, put, del } from './base'

// 账户 API Keys 类型
export const AccountApiKeyStatus = {
  ACTIVE: 'active',
  INACTIVE: 'inactive'
}

// 获取用户信息
export const useUserProfile = () => {
  return get('/account/profile')
}

// 更新用户名
export const updateAccountName = (name) => {
  return post('/account/name', { body: { name } })
}

// 更新头像
export const updateAccountAvatar = (avatar) => {
  return post('/account/avatar', { body: { avatar } })
}

// 更新界面语言
export const updateInterfaceLanguage = (interface_language) => {
  return post('/account/interface-language', { body: { interface_language } })
}

// 更新主题
export const updateInterfaceTheme = (interface_theme) => {
  return post('/account/interface-theme', { body: { interface_theme } })
}

// 更新时区
export const updateTimezone = (timezone) => {
  return post('/account/timezone', { body: { timezone } })
}

// 更新密码
export const updatePassword = (password, new_password, repeat_new_password) => {
  return post('/account/password', { 
    body: { 
      password, 
      new_password, 
      repeat_new_password 
    } 
  })
}

// 获取账户 API Keys
export const useAccountApiKeys = () => {
  return get('/account/api-keys')
}

// 创建账户 API Key
export const useCreateAccountApiKey = (body) => {
  return post('/account/api-keys', body)
}

// 更新账户 API Key
export const useUpdateAccountApiKey = (id, body) => {
  return put(`/account/api-keys/${id}`, body)
}

// 删除账户 API Key
export const useDeleteAccountApiKey = (id) => {
  return del(`/account/api-keys/${id}`)
}

// 退出登录
export const useLogout = () => {
  return post('/logout')
}