import { IAddStoreResponse, IChangeStoreStatusResponse, IStore } from "@/api/store/types/store"
import { request } from "@/utils/service"
import * as AxiosType from "axios/index"
import { IPageResponseData, IResponseData } from "@/api/types/requests"

export function addStoreApi(store: IStore) {
  return request<AxiosType.AxiosResponse<IResponseData<IAddStoreResponse>>>({
    url: "/store/addStore",
    method: "POST",
    data: store,
    withCredentials: true
  })
}
export function getStoreApi(page: number) {
  return request<AxiosType.AxiosResponse<IResponseData<IPageResponseData<IStore>>>>({
    url: "/store/getStore",
    method: "GET",
    params: {
      page: page,
      num: 10
    },
    withCredentials: true
  })
}
export function getAllStoreApi() {
  return request<AxiosType.AxiosResponse<IResponseData<IStore[]>>>({
    url: "/store/getAllStore",
    method: "GET",
    withCredentials: true
  })
}
export function changeStoreStatusApi(store: IStore) {
  return request<AxiosType.AxiosResponse<IResponseData<IChangeStoreStatusResponse>>>({
    url: "/store/changeStoreStatus",
    method: "GET",
    params: {
      storeId: store.id,
      status: !store.status
    },
    withCredentials: true
  })
}
