feat: Добавление компонентов ErrorBoundary и NetworkErrorHandler для улучшения обработки ошибок в приложении. Увеличение таймаута запросов до 30 секунд и улучшение логики повторных попыток с детализированными уведомлениями об ошибках.
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m43s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m43s
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { useState } from 'react';
|
||||
import { IconRefresh } from '@tabler/icons-react';
|
||||
|
||||
/**
|
||||
* RetryButton - кнопка для повторной попытки с индикацией загрузки
|
||||
*/
|
||||
function RetryButton({
|
||||
onRetry,
|
||||
loading: externalLoading,
|
||||
disabled,
|
||||
className = 'btn btn-primary',
|
||||
children = 'Повторить',
|
||||
showIcon = true,
|
||||
...props
|
||||
}) {
|
||||
const [internalLoading, setInternalLoading] = useState(false);
|
||||
const loading = externalLoading !== undefined ? externalLoading : internalLoading;
|
||||
|
||||
const handleClick = async () => {
|
||||
if (loading || disabled) return;
|
||||
|
||||
try {
|
||||
setInternalLoading(true);
|
||||
await onRetry();
|
||||
} finally {
|
||||
setInternalLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`${className}${loading ? ' btn-loading' : ''}`}
|
||||
disabled={disabled || loading}
|
||||
onClick={handleClick}
|
||||
{...props}
|
||||
>
|
||||
{showIcon && !loading && <IconRefresh className="icon" />}
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default RetryButton;
|
||||
|
||||
Reference in New Issue
Block a user