Uecko_ERP/modules/customers/src/common/features/get-customer/controllers/use-get-customer-controller.ts
2026-07-03 09:37:12 +02:00

27 lines
564 B
TypeScript

import { useCustomerGetQuery } from "../../../../web/shared";
import { buildCustomerData } from "../utils";
export const useGetCustomerController = (customerId: string, options?: { enabled?: boolean }) => {
const {
data,
isLoading,
isError: isLoadError,
error: loadError,
refetch,
} = useCustomerGetQuery({
id: customerId,
enabled: options?.enabled ?? true,
});
const customerData = data ? buildCustomerData(data) : undefined;
return {
customerData,
isLoading,
isLoadError,
loadError,
refetch,
};
};