import { request } from "@/utils/service"
import * as AxiosType from "axios"
import * as Requests from "@/api/types/requests"
import {
  IChangeUserStatus,
  IDelUserResponseData,
  IExChangeAccountRequestsData,
  IExChangeUserResponseData,
  IGetAllUserResponseData
} from "@/api/users/types/users"

export function getAllUsersApi(page: number) {
  return request<AxiosType.AxiosResponse<Requests.IResponseData<IGetAllUserResponseData>>>({
    url: "/account/getUser",
    method: "get",
    params: {
      page: page,
      num: 10
    },
    withCredentials: true
  })
}
export function delUserApi(userId: number) {
  return request<AxiosType.AxiosResponse<Requests.IResponseData<IDelUserResponseData>>>({
    url: "/account/delUser",
    method: "get",
    params: {
      id: userId
    },
    withCredentials: true
  })
}
export function exChangeUserDataApi(newUser: IExChangeAccountRequestsData) {
  return request<AxiosType.AxiosResponse<Requests.IResponseData<IExChangeUserResponseData>>>({
    url: "/account/changeAccount",
    method: "post",
    data: newUser,
    withCredentials: true
  })
}
export function changeUserStatusApi(userid: number, newStatus: boolean) {
  return request<AxiosType.AxiosResponse<Requests.IResponseData<IChangeUserStatus>>>({
    url: "/account/changeStatus",
    method: "get",
    params: {
      userId: userid,
      status: newStatus
    },
    withCredentials: true
  })
}
