26 lines
826 B
TypeScript
26 lines
826 B
TypeScript
import { AxiosInstance } from 'axios';
|
|
import { FilterOptions } from '../types';
|
|
export interface ApiServiceConfig {
|
|
baseURL: string;
|
|
defaultHeaders?: Record<string, string>;
|
|
timeout?: number;
|
|
}
|
|
export interface UseApiServiceReturn<T> {
|
|
data: T[];
|
|
loading: boolean;
|
|
error: string | null;
|
|
total: number;
|
|
hasMore: boolean;
|
|
client: AxiosInstance;
|
|
getAll: (filters?: FilterOptions) => Promise<T[]>;
|
|
getById: (id: string) => Promise<T>;
|
|
create: (data: Partial<T>) => Promise<T>;
|
|
update: (id: string, data: Partial<T>) => Promise<T>;
|
|
delete: (id: string) => Promise<void>;
|
|
clearError: () => void;
|
|
refresh: () => Promise<void>;
|
|
}
|
|
export declare const useApiService: <T extends {
|
|
id: string;
|
|
}>(config: ApiServiceConfig, endpoint: string) => UseApiServiceReturn<T>;
|