Files
danak-admin/src/pages/customer/service/CustomerService.ts
T
hamid zarghami 24171dbaf8
deploy to danak / build_and_deploy (push) Has been cancelled
customer search
2026-07-22 15:46:12 +03:30

35 lines
1.1 KiB
TypeScript

import axios from "../../../config/axios";
import { CreateCustomerType } from "../types/CustomerTypes";
export const getCustomers = async (page: number, limit: number, withoutPaginate?: boolean, search?: string) => {
const { data } = await axios.get(
`/users/customers?page=${page}&limit=${limit}&paginate=${withoutPaginate ? "0" : "1"}&q=${encodeURIComponent(search ?? "")}`,
);
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;
};