diff --git a/src/app/actions/file-upload.ts b/src/app/actions/file-upload.ts index 4ac7d6a..44cd1db 100644 --- a/src/app/actions/file-upload.ts +++ b/src/app/actions/file-upload.ts @@ -66,7 +66,6 @@ export async function fileUpload(messageBody: initMessageBody) { export async function cancelUpload(udloadId: string) { try { - console.log('cancelUpload start'); const response = await fetch(`${API_BASE_URL}/api/v1/data`, { method: 'POST', body: JSON.stringify({ diff --git a/src/app/components/upload-section-file.tsx b/src/app/components/upload-section-file.tsx index 2c4ab4f..1276e11 100644 --- a/src/app/components/upload-section-file.tsx +++ b/src/app/components/upload-section-file.tsx @@ -100,7 +100,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile if (!extension || !ALLOWED_EXTENSIONS.includes(extension as string)) { return { isValid: false, - errorMessage: 'Неподдерживаемый формат файла.' + errorMessage: t('unsupported-file-format') }; } } @@ -110,7 +110,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile if (file.size > MAX_SIZE) { return { isValid: false, - errorMessage: 'Файл слишком большой. Максимальный размер: 1000MB' + errorMessage: t('the-file-is-too-large') }; } @@ -133,7 +133,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile img.onerror = () => { URL.revokeObjectURL(objectUrl); - reject(new Error('Не удалось загрузить фаил')); + reject(new Error(t('error-uploading-file'))); }; img.src = objectUrl; @@ -151,7 +151,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile const validation = validateFile(file); if (!validation.isValid) { - setError(validation.errorMessage || 'Неизвестная ошибка валидации'); + setError(validation.errorMessage || t('unknown-validation-error')); return; } @@ -163,7 +163,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile dimensions = await getImageDimensions(file) as { width: number, height: number }; if (dimensions.width < 150 || dimensions.height < 150 || dimensions.width > 10000 || dimensions.height > 10000) { - setError(`Размер изображения: ${dimensions.width}x${dimensions.height}. Допустимый диапазон: 150x150 - 10000x10000 пикселей.`); + setError(`${t('image-size')}: ${dimensions.width}x${dimensions.height}. ${t('acceptable-range')}: 150x150 - 10000x10000 ${t('pixels')}.`); return; } @@ -188,7 +188,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile }); } catch (err) { - setError(err instanceof Error ? err.message : 'Ошибка при обработке файла'); + setError(t('error-processing-file')); } }, []); @@ -276,7 +276,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile const chunkResponse = await chunkUpload(formData); if (chunkResponse.message_desc !== 'Chunk uploaded successfully') { - throw 'Er1' + throw 'Er1: response error' } if (chunkIndex === totalChunks - 1) { @@ -285,7 +285,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile setUploadId(null); setIsFileUploaded(true); } else { - throw 'Er2' + throw 'Er2: not all chunks was uploaded' } } @@ -298,12 +298,12 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile ); } } catch (error) { - setError('Chunk uploaded error ' + error); + setError(t('error-uploading-file')); console.error('Chunk upload error:', error); } } else { - console.log(response); - setError('file uploaded error'); + console.error(response); + setError(t('error-uploading-file')); } } @@ -391,14 +391,14 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile {fileType === "image" && (
- Разрешение изображение: 100x100 - 10000x10000 + {t('image-resolution')}: 100x100 - 10000x10000
)}- Размер файла: до {(maxFileSize / 1024 / 1024)} МБ + {t('file-size')}: {t('to')} {(maxFileSize / 1024 / 1024)} {t('mb')}
- Формат файла: {ALLOWED_EXTENSIONS.join(', ')} + {t('file-format')}: {ALLOWED_EXTENSIONS.join(', ')}
{error && ( @@ -409,7 +409,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile {selectedFile && (- Стоимость защиты: 0 + {t('cost-of-protection')}: 0
- Текущий баланс: 0 + {t('current-balance')}: 0