Facturas de cliente
This commit is contained in:
parent
edecf0121b
commit
84636276cc
@ -41,9 +41,15 @@ export const createAxiosDataSource = (client: AxiosInstance): IDataSource => {
|
|||||||
return {
|
return {
|
||||||
getBaseUrl: () => (client as AxiosInstance).getUri(),
|
getBaseUrl: () => (client as AxiosInstance).getUri(),
|
||||||
|
|
||||||
getList: async <T>(resource: string, params?: Record<string, any>) => {
|
getList: async <T, R>(resource: string, params?: Record<string, any>): Promise<R> => {
|
||||||
const res = await (client as AxiosInstance).get<T[]>(resource, params);
|
const { pagination } = params as any;
|
||||||
return res.data;
|
|
||||||
|
const res = await (client as AxiosInstance).get<T[]>(resource, {
|
||||||
|
params: {
|
||||||
|
...pagination,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return <R>res.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
getOne: async <T>(resource: string, id: string | number) => {
|
getOne: async <T>(resource: string, id: string | number) => {
|
||||||
@ -51,9 +57,9 @@ export const createAxiosDataSource = (client: AxiosInstance): IDataSource => {
|
|||||||
return res.data;
|
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 } });
|
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>) => {
|
createOne: async <T>(resource: string, data: Partial<T>) => {
|
||||||
|
|||||||
@ -14,9 +14,9 @@ export interface ICustomParams {
|
|||||||
|
|
||||||
export interface IDataSource {
|
export interface IDataSource {
|
||||||
getBaseUrl(): string;
|
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>;
|
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>;
|
createOne<T>(resource: string, data: Partial<T>): Promise<T>;
|
||||||
updateOne<T>(resource: string, id: string | number, 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>;
|
deleteOne<T>(resource: string, id: string | number): Promise<void>;
|
||||||
|
|||||||
@ -18,7 +18,11 @@ import { CustomerInvoiceStatusBadge } from "./customer-invoice-status-badge";
|
|||||||
// Create new GridExample component
|
// Create new GridExample component
|
||||||
export const CustomerInvoicesListGrid = () => {
|
export const CustomerInvoicesListGrid = () => {
|
||||||
const { t } = useTranslation();
|
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.
|
// Column Definitions: Defines & controls grid columns.
|
||||||
const [colDefs] = useState<ColDef[]>([
|
const [colDefs] = useState<ColDef[]>([
|
||||||
@ -75,6 +79,7 @@ export const CustomerInvoicesListGrid = () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const gridOptions: GridOptions = {
|
const gridOptions: GridOptions = {
|
||||||
|
rowModelType: "clientSide",
|
||||||
columnDefs: colDefs,
|
columnDefs: colDefs,
|
||||||
defaultColDef: {
|
defaultColDef: {
|
||||||
editable: false,
|
editable: false,
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export const useCustomerInvoicesQuery = (params: any) => {
|
|||||||
queryKey: keys().data().resource("customer-invoices").action("list").params(params).get(),
|
queryKey: keys().data().resource("customer-invoices").action("list").params(params).get(),
|
||||||
queryFn: (context) => {
|
queryFn: (context) => {
|
||||||
console.log(dataSource.getBaseUrl());
|
console.log(dataSource.getBaseUrl());
|
||||||
|
console.log(params);
|
||||||
const { signal } = context;
|
const { signal } = context;
|
||||||
return dataSource.getList<CustomerInvoiceListResponseDTO>("customer-invoices", {
|
return dataSource.getList<CustomerInvoiceListResponseDTO>("customer-invoices", {
|
||||||
signal,
|
signal,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user