import {
  AddAuthPermissionResponseData,
  AuthPermissions,
  ChangeAuthPermissionsResponseData,
  DeleteAuthPermissionsResponseData
} from "@/api/permission/type/permission"
import { AxiosResponseData, IPageResponseData, pageSize } from "@/api/types/requests"
import { request } from "@/utils/service"
export function addAuthPermission(permission: AuthPermissions) {
  return request<AxiosResponseData<AddAuthPermissionResponseData>>({
    url: "/authPermissions/addAuthPermissions",
    method: "POST",
    data: permission,
    withCredentials: true
  })
}
export function changeAuthPermissions(newPermission: AuthPermissions) {
  return request<AxiosResponseData<ChangeAuthPermissionsResponseData>>({
    url: "/authPermissions/changeAuthPermissions",
    method: "POST",
    data: newPermission,
    withCredentials: true
  })
}
export function deleteAuthPermissions(id: number) {
  return request<AxiosResponseData<DeleteAuthPermissionsResponseData>>({
    url: "/authPermissions/delAuthPermissions",
    method: "GET",
    params: {
      id: id
    },
    withCredentials: true
  })
}
export function getAuthPermissions(page: number) {
  return request<AxiosResponseData<IPageResponseData<AuthPermissions>>>({
    url: "/authPermissions/getAuthPermissions",
    method: "GET",
    params: {
      page: page,
      num: pageSize
    },
    withCredentials: true
  })
}
export function changeAuthPermissionsStats(id: number, status: boolean) {
  return request<AxiosResponseData<ChangeAuthPermissionsResponseData>>({
    url: "/authPermissions/changeAuthPermissionsStats",
    method: "GET",
    params: {
      authPermissionId: id,
      status: status
    },
    withCredentials: true
  })
}
