fix: build error for checking packages

This commit is contained in:
Sajad Mirjalili
2025-08-15 22:54:38 +03:30
parent 7bc3bae045
commit 7f09cee021
6 changed files with 111 additions and 758 deletions

View File

@@ -1,20 +1,17 @@
import { useState, useEffect, useCallback } from 'react';
import { type ApiResponse } from '@/types/apiResponse';
// Define options for the hook
interface UseApiOptions {
// If true, the API call will be executed immediately on mount
immediate?: boolean;
}
export function useApi<T extends ApiResponse, P extends any[]>(
export function useApi<T, P extends any[]>(
apiFunction: (...args: P) => Promise<{ data: T }>,
options: UseApiOptions = {},
) {
const [data, setData] = useState<T | null>(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<unknown>(null);
const execute = useCallback(
async (...args: P) => {
setLoading(true);