Merge branch 'develop' into feat/auth

This commit is contained in:
SajadMRjl
2025-08-16 02:45:21 +03:30
committed by GitHub
57 changed files with 7196 additions and 394 deletions

View File

@@ -1,17 +1,17 @@
import type { ApiResponse } from '@/types/apiResponse';
// FIXME: all the responses should extend this interface
// import type { ApiResponse } from '@/types/apiResponse';
import { useToast } from '@rkheftan/harmony-ui';
import type { AxiosError } from 'axios';
import { useState, useEffect, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
// 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 = {},
) {
@@ -51,7 +51,8 @@ export function useApi<T extends ApiResponse, P extends any[]>(
}
},
[apiFunction, navigate, t, toast],
);
)
// If the 'immediate' option is true, execute the function on mount
useEffect(() => {