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 && (
@@ -424,10 +424,10 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile {selectedFile.size}

- Стоимость защиты: 0 + {t('cost-of-protection')}: 0

- Текущий баланс: 0 + {t('current-balance')}: 0

@@ -457,12 +457,12 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile {isFileUploaded ? t('close') : t('cancel')} diff --git a/src/app/styles/pages-styles.scss b/src/app/styles/pages-styles.scss index 2fbc548..d51c2f9 100644 --- a/src/app/styles/pages-styles.scss +++ b/src/app/styles/pages-styles.scss @@ -489,6 +489,12 @@ border-radius: 15px; background: #fff; padding: 10px; + border: 2px solid transparent; + transition: all 0.3s ease-in; + + &.done { + border-color: #00a63e; + } &-file-info { text-align: left; diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index f8b9c34..b7ce4cc 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -129,7 +129,22 @@ "upload-for-protection": "Upload {fileType} for protection", "image": "image", "file-has-no-extension": "File has no extension", - "have-unsaved-changes": "You have unsaved changes. Are you sure you want to delete this page?" + "have-unsaved-changes": "You have unsaved changes. Are you sure you want to delete this page?", + "image-size": "Image size", + "acceptable-range": "Acceptable range", + "pixels": "pixels", + "error-processing-file": "Error processing file", + "error-uploading-file": "Error uploading file", + "unknown-validation-error": "Unknown validation error", + "unsupported-file-format": "Unsupported file format.", + "the-file-is-too-large": "The file is too large", + "cost-of-protection": "Cost of protection", + "current-balance": "Current balance", + "image-resolution": "Image resolution", + "file-size": "File size", + "file-format": "File format", + "mb": "MB", + "to": "to" }, "Login-register-form": { "and": "and", diff --git a/src/i18n/messages/ru.json b/src/i18n/messages/ru.json index cea5324..bd067a2 100644 --- a/src/i18n/messages/ru.json +++ b/src/i18n/messages/ru.json @@ -129,7 +129,22 @@ "upload-for-protection": "Загрузить {fileType} для защиты", "image": "изображений", "file-has-no-extension": "Файл не имеет расширения", - "have-unsaved-changes": "У вас есть несохраненные изменения. Вы уверены, что хотите покинуть страницу?" + "have-unsaved-changes": "У вас есть несохраненные изменения. Вы уверены, что хотите покинуть страницу?", + "image-size": "Размер изображения", + "acceptable-range": "Допустимый диапазон", + "pixels": "пикселей", + "error-processing-file": "Ошибка при обработке файла", + "error-uploading-file": "Ошибка при загрузке файла", + "unknown-validation-error": "Неизвестная ошибка валидации", + "unsupported-file-format": "Неподдерживаемый формат файла.", + "the-file-is-too-large": "Файл слишком большой", + "cost-of-protection": "Стоимость защиты", + "current-balance": "Текущий баланс", + "image-resolution": "Разрешение изображение", + "file-size": "Размер файла", + "file-format": "Формат файла", + "mb": "МБ", + "to": "до" }, "Login-register-form": { "and": "и",