Facturas de cliente

This commit is contained in:
David Arranz 2025-09-11 17:38:33 +02:00
parent edecf0121b
commit 84636276cc
4 changed files with 20 additions and 8 deletions

View File

@ -41,9 +41,15 @@ export const createAxiosDataSource = (client: AxiosInstance): IDataSource => {
return {
getBaseUrl: () => (client as AxiosInstance).getUri(),
getList: async <T>(resource: string, params?: Record<string, any>) => {
const res = await (client as AxiosInstance).get<T[]>(resource, params);
return res.data;
getList: async <T, R>(resource: string, params?: Record<string, any>): Promise<R> => {
const { pagination } = params as any;
const res = await (client as AxiosInstance).get<T[]>(resource, {
params: {
...pagination,
},
});
return <R>res.data;
},
getOne: async <T>(resource: string, id: string | number) => {
@ -51,9 +57,9 @@ export const createAxiosDataSource = (client: AxiosInstance): IDataSource => {
return res.data;
},
getMany: async <T>(resource: string, ids: Array<string | number>) => {
getMany: async <T, R>(resource: string, ids: Array<string | number>): Promise<R> => {
const res = await (client as AxiosInstance).get<T[]>(`${resource}`, { params: { ids } });
return res.data;
return <R>res.data;
},
createOne: async <T>(resource: string, data: Partial<T>) => {

View File

@ -14,9 +14,9 @@ export interface ICustomParams {
export interface IDataSource {
getBaseUrl(): string;
getList<T>(resource: string, params?: Record<string, any>): Promise<T>;
getList<T, R>(resource: string, params?: Record<string, any>): Promise<R>;
getOne<T>(resource: string, id: string | number): Promise<T>;
getMany<T>(resource: string, ids: Array<string | number>): Promise<T>;
getMany<T, R>(resource: string, ids: Array<string | number>): Promise<R>;
createOne<T>(resource: string, data: Partial<T>): Promise<T>;
updateOne<T>(resource: string, id: string | number, data: Partial<T>): Promise<T>;
deleteOne<T>(resource: string, id: string | number): Promise<void>;

View File

@ -18,7 +18,11 @@ import { CustomerInvoiceStatusBadge } from "./customer-invoice-status-badge";
// Create new GridExample component
export const CustomerInvoicesListGrid = () => {
const { t } = useTranslation();
const { data, isLoading, isPending, isError, error } = useCustomerInvoicesQuery({});
const { data, isLoading, isPending, isError, error } = useCustomerInvoicesQuery({
pagination: {
pageSize: 9999,
},
});
// Column Definitions: Defines & controls grid columns.
const [colDefs] = useState<ColDef[]>([
@ -75,6 +79,7 @@ export const CustomerInvoicesListGrid = () => {
]);
const gridOptions: GridOptions = {
rowModelType: "clientSide",
columnDefs: colDefs,
defaultColDef: {
editable: false,

View File

@ -11,6 +11,7 @@ export const useCustomerInvoicesQuery = (params: any) => {
queryKey: keys().data().resource("customer-invoices").action("list").params(params).get(),
queryFn: (context) => {
console.log(dataSource.getBaseUrl());
console.log(params);
const { signal } = context;
return dataSource.getList<CustomerInvoiceListResponseDTO>("customer-invoices", {
signal,