import axios from "../../../config/axios";
import { CreateCustomerType } from "../types/CustomerTypes";

export const getCustomers = async (page: number, withoutPaginate?: boolean) => {
  const { data } = await axios.get(
    `/users/customers?page=${page}&paginate=${withoutPaginate ? "0" : "1"}`
  );
  return data;
};

export const getProvines = async () => {
  const { data } = await axios.get(`/address/provinces/list?limit=50`);
  return data;
};

export const getCities = async (id: string) => {
  const { data } = await axios.get(`/address/provinces/${id}/cities`);
  return data;
};

export const createCustomer = async (params: CreateCustomerType) => {
  const { data } = await axios.post(`/users/customers`, params);
  return data;
};

export const getDetailCustomer = async (id: string) => {
  const { data } = await axios.get(`/users/customers/${id}`);
  return data;
};

export const updateCustomer = async (
  id: string,
  params: CreateCustomerType
) => {
  const { data } = await axios.patch(`/users/customers/${id}`, params);
  return data;
};
