import axios from "../../../config/axios";
import type {
  CancelReasonsResponseType,
  CreateCancelReasonType,
  CreateReturnReasonType,
  NativeOrdersResponseType,
  OrderDetailResponseType,
  ReturnReasonsResponseType,
} from "../types/Types";

export const getNativeOrders = async (
  page: number = 1,
  status: string
): Promise<NativeOrdersResponseType> => {
  const { data } = await axios.get("/admin/orders/native", {
    params: { page, status },
  });
  return data;
};

export const getSellerOrders = async (
  page: number = 1,
  status: string
): Promise<NativeOrdersResponseType> => {
  const { data } = await axios.get("/admin/orders/seller", {
    params: { page, status },
  });
  return data;
};

export const getOrderDetailUser = async (
  id: string
): Promise<OrderDetailResponseType> => {
  const { data } = await axios.get(`/admin/orders/${id}/user`);
  return data;
};

export const createCancelReason = async (params: CreateCancelReasonType) => {
  const { data } = await axios.post(`/admin/orders/cancel/reasons`, params);
  return data;
};

export const getCancelReasons = async (): Promise<
  CancelReasonsResponseType
> => {
  const { data } = await axios.get(`/cancel/reasons`);
  return data;
};

export const deleteCancelReason = async (id: string) => {
  const { data } = await axios.delete(`/admin/orders/reasons/${id}/delete`);
  return data;
};

export const createReturnReason = async (params: CreateReturnReasonType) => {
  const { data } = await axios.post(`/admin/orders/returns/reasons`, params);
  return data;
};

export const getReturnReasons = async (): Promise<
  ReturnReasonsResponseType
> => {
  const { data } = await axios.get(`/returns/reasons`);
  return data;
};

export const deleteReturnReason = async (id: string) => {
  const { data } = await axios.delete(`/admin/orders/returns/reasons/${id}`);
  return data;
};
