import { api } from './client'

export async function updateAdminUsername(newUsername) {
  const { data } = await api.put('/admin/username', { new_username: newUsername })
  return data
}

export async function updateAdminPassword(payload = {}) {
  const currentPassword = String(payload.currentPassword || '')
  const newPassword = String(payload.newPassword || '')
  const { data } = await api.put('/admin/password', {
    current_password: currentPassword,
    new_password: newPassword,
  })
  return data
}

export async function logout() {
  const { data } = await api.post('/logout')
  return data
}
