diff --git a/src/app/components/upload-section-file.tsx b/src/app/components/upload-section-file.tsx index 2708418..d708db6 100644 --- a/src/app/components/upload-section-file.tsx +++ b/src/app/components/upload-section-file.tsx @@ -38,7 +38,6 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile const [uploadId, setUploadId] = useState(null); const [isFileUploaded, setIsFileUploaded] = useState(false); const [uploadProgress, setUploadProgress] = useState(0); - const [isUploading, setIsUploading] = useState(false); const t = useTranslations('Global'); let SUPPORTED_FORMATS: string[] = []; @@ -152,7 +151,10 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile return; } setUploadProgress(0); + + setUploadId(null); setError(null); + setIsFileUploaded(false) const validation = validateFile(file); @@ -246,12 +248,11 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile }; const handlerFileUpload = useCallback(async (file: SelectedFile): Promise => { - // Защита от повторного вызова - if (isUploading) return; + if (uploadId) { + return; + }; - // Сбрасываем состояния setError(null); - setIsUploading(true); try { const extension = file.name.split('.').pop(); @@ -327,10 +328,9 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile if (error.cause) console.error('Error cause:', error.cause); } } finally { - setIsUploading(false); setUploadId(null); } - }, [isUploading, fileType]); // Добавьте зависимости + }, [uploadId, fileType]); useEffect(() => { // Обработка закрытия вкладки @@ -480,12 +480,12 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile {isFileUploaded ? t('close') : t('cancel')}