27 lines
564 B
TypeScript
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,
|
|
};
|
|
};
|