Initial commit for new panel

This commit is contained in:
AmirReza Jamali
2025-09-09 11:20:26 +03:30
commit 1d4ccb3575
343 changed files with 20031 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
import api from "../axios";
import { API_ENDPOINTS } from "../endpoints";
import {
CreateCustomerCredentials,
CustomerListResponseSchema,
TAssignCustomerToCompanyCredentials,
} from "../types/Customers";
export const customersService = {
getCustomers: async (params?: Record<string, any>) => {
try {
const response = await api.get(API_ENDPOINTS.CUSTOMERS.READ_ALL, {
params,
});
return CustomerListResponseSchema.parse(response.data);
} catch (error) {
console.error("ERROR caught in Customers Services Read all:", error);
throw error;
}
},
deleteCustomer: async (id: string) => {
try {
return (await api.delete(API_ENDPOINTS.CUSTOMERS.DELETE(id))).data;
} catch (error) {
console.error("ERROR caught in Customers Services Delete:", error);
throw error;
}
},
createCustomer: async (credentials: CreateCustomerCredentials) => {
try {
return (await api.post(API_ENDPOINTS.CUSTOMERS.CREATE, credentials)).data;
} catch (error) {
console.error("ERROR caught in Customers Services Create:", error);
throw error;
}
},
updateCustomer: async ({
id,
credentials,
}: {
id: string;
credentials: CreateCustomerCredentials;
}) => {
try {
return (await api.put(API_ENDPOINTS.CUSTOMERS.UPDATE(id), credentials))
.data;
} catch (error) {
console.error("ERROR caught in Customers Services Update:", error);
throw error;
}
},
assignCompanyToCustomer: async ({
credentials,
id,
}: {
id: string;
credentials: TAssignCustomerToCompanyCredentials;
}): Promise<any> => {
try {
return (
await api.post(
API_ENDPOINTS.CUSTOMERS.ASSIGN_COMPANY_TO_CUSTOMER(id),
credentials,
)
).data;
} catch (error) {
console.error(
"ERROR caught in Customers Service => Assign company to customer",
error,
);
throw error;
}
},
};