From 16b886081b53604a077b2c7431d412b2c95911da Mon Sep 17 00:00:00 2001 From: SlimusMinus Date: Mon, 26 Oct 2026 23:27:40 +0300 Subject: [PATCH] Desktop: drag and drop profile photo; share drop-zone hook with post form Co-Authored-By: Claude Opus 5.5 --- src/components/profile/ProfileFormFields.jsx | 22 +++++- src/components/profile/ProfileModal.jsx | 15 ++++ src/components/profile/ProfileModal.test.jsx | 78 ++++++++++++++++++++ src/hooks/useFileDropZone.js | 58 +++++++++++++++ src/hooks/useImageUpload.js | 14 +++- src/locales/en.json | 3 + src/locales/ru.json | 3 + src/pages/CreateUpdatePost.jsx | 49 ++---------- src/styles/modal.css | 12 +++ 9 files changed, 209 insertions(+), 45 deletions(-) create mode 100644 src/components/profile/ProfileModal.test.jsx create mode 100644 src/hooks/useFileDropZone.js diff --git a/src/components/profile/ProfileFormFields.jsx b/src/components/profile/ProfileFormFields.jsx index bfaa04e..53f401a 100644 --- a/src/components/profile/ProfileFormFields.jsx +++ b/src/components/profile/ProfileFormFields.jsx @@ -24,15 +24,24 @@ function ImageUpload({ fileInputRef, onFileChange, onRemove, + // Перетаскивание фото (десктоп): обработчики зоны и «файл над зоной». + // Пустые props — перетаскивание выключено (мобильная раскладка). + dropZoneProps = {}, + dragOver = false, }) { const { t } = useTranslation(); + const dropEnabled = Object.keys(dropZoneProps).length > 0; return ( -
+
{displayImage ? (
profile + {dragOver && {t('profile.dropReplace')}}