36334119bd
feat(multi-select): enhance MultiSelect component with dropdown positioning and portal rendering - Added dynamic dropdown positioning to ensure it appears correctly relative to the trigger element. - Implemented portal rendering for the dropdown to improve performance and prevent overflow issues. - Refactored MultiSelect state management for better clarity and maintainability. feat(switch): improve Switch component with GSAP animations and enhanced styling - Integrated GSAP animations for thumb transitions and glow effects to enhance user interaction. - Updated styling for the Switch component to improve visual feedback and responsiveness. feat(companies-table): add currency and language metadata display in CompaniesTable - Introduced currency and language metadata for better representation of company details. - Enhanced UI for displaying company languages and currencies with tooltips for additional context. feat(assign-to-company-modal): refactor AssignToCompanyModalContent to use MultiSelect - Replaced Select component with MultiSelect for improved user experience in selecting companies. - Streamlined state management and data handling for company assignments. feat(customers-table): enhance customer company display with tooltips and improved layout - Updated customer company display to show a maximum of two companies with a tooltip for additional companies. - Improved styling for better visual representation of customer associations with companies. feat(confirmation-modal): enhance ConfirmationModal with animations and improved accessibility - Added GSAP animations for modal entrance and exit to improve user experience. - Implemented accessibility features for better keyboard navigation and focus management. feat(status): extend Status component with pulse and shimmer effects for enhanced visual feedback - Introduced new visual effects for status indicators to improve user engagement and clarity. - Updated styles for better integration with existing UI components. feat(tooltip): enhance tooltip styling and functionality with new palettes - Implemented a new tooltip design with gradient backgrounds and shadows for improved visibility. - Updated tooltip parameters to support new styling options and enhance user experience.
83 lines
2.2 KiB
TypeScript
83 lines
2.2 KiB
TypeScript
import api from "../axios";
|
|
import { API_ENDPOINTS } from "../endpoints";
|
|
import { ApiResponse } from "../types";
|
|
import {
|
|
CreateCustomerCredentials,
|
|
CustomerListResponseSchema,
|
|
TAssignCustomerToCompanyCredentials,
|
|
TCustomersListResponse,
|
|
} from "../types/Customers";
|
|
|
|
export const customersService = {
|
|
getCustomers: async (
|
|
params?: Record<string, any>,
|
|
): Promise<ApiResponse<TCustomersListResponse>> => {
|
|
try {
|
|
const response = await api.get(API_ENDPOINTS.CUSTOMERS.READ_ALL, {
|
|
params,
|
|
});
|
|
return 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;
|
|
}
|
|
},
|
|
customerDetails: async (id: string) => {
|
|
const response = await api.get(API_ENDPOINTS.CUSTOMERS.DETAILS(id));
|
|
return response.data;
|
|
},
|
|
assignCompanyToCustomer: async ({
|
|
credentials,
|
|
id,
|
|
}: {
|
|
id: string;
|
|
credentials: TAssignCustomerToCompanyCredentials;
|
|
}): Promise<any> => {
|
|
try {
|
|
return (
|
|
await api.patch(
|
|
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;
|
|
}
|
|
},
|
|
};
|