Uecko_ERP/modules/customer-invoices/src/web/hooks/use-customer-invoices-query.tsx

23 lines
747 B
TypeScript
Raw Normal View History

2025-08-23 11:57:48 +00:00
import { useDataSource, useQueryKey } from "@erp/core/hooks";
2025-06-24 18:38:57 +00:00
import { useQuery } from "@tanstack/react-query";
2025-09-16 17:41:27 +00:00
import { ListCustomerInvoicesResponseDTO } from "../../common/dto";
2025-06-24 18:38:57 +00:00
// Obtener todas las facturas
2025-09-16 17:41:27 +00:00
export const useCustomerInvoicesQuery = (params?: any) => {
2025-06-24 18:38:57 +00:00
const dataSource = useDataSource();
const keys = useQueryKey();
2025-09-16 17:41:27 +00:00
return useQuery<ListCustomerInvoicesResponseDTO>({
2025-06-24 18:38:57 +00:00
queryKey: keys().data().resource("customer-invoices").action("list").params(params).get(),
2025-09-16 17:41:27 +00:00
queryFn: async (context) => {
2025-06-24 18:38:57 +00:00
const { signal } = context;
2025-09-16 17:41:27 +00:00
const invoices = await dataSource.getList("customer-invoices", {
2025-07-02 08:57:09 +00:00
signal,
...params,
});
2025-09-16 17:41:27 +00:00
return invoices as ListCustomerInvoicesResponseDTO;
2025-06-24 18:38:57 +00:00
},
});
};