Uecko_ERP/modules/customers/src/web/hooks/use-customers-query.tsx

22 lines
698 B
TypeScript
Raw Normal View History

2025-08-23 11:57:48 +00:00
import { useDataSource, useQueryKey } from "@erp/core/hooks";
2025-08-11 17:49:52 +00:00
import { useQuery } from "@tanstack/react-query";
import { CustomerListResponsetDTO } from "../../common/dto";
2025-07-17 18:04:00 +00:00
2025-08-11 17:49:52 +00:00
// Obtener todas las facturas
export const useCustomersQuery = (params: any) => {
2025-07-17 18:04:00 +00:00
const dataSource = useDataSource();
const keys = useQueryKey();
2025-08-11 17:49:52 +00:00
return useQuery<CustomerListResponsetDTO>({
2025-07-17 18:04:00 +00:00
queryKey: keys().data().resource("customers").action("list").params(params).get(),
queryFn: (context) => {
2025-08-11 17:49:52 +00:00
console.log(dataSource.getBaseUrl());
2025-07-17 18:04:00 +00:00
const { signal } = context;
2025-08-11 17:49:52 +00:00
return dataSource.getList<CustomerListResponsetDTO>("customers", {
2025-07-17 18:04:00 +00:00
signal,
...params,
});
},
});
};