From eb708b057d19130466b10c9701869144b3461b1e Mon Sep 17 00:00:00 2001 From: poignatov Date: Tue, 20 Jan 2026 20:48:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87-?= =?UTF-8?q?=D0=B6=D0=B5=D0=BB=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=B8=20=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=81=D0=B8=D1=8F=203.22.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- play-life-web/package.json | 2 +- play-life-web/src/components/TaskForm.jsx | 18 ++--- play-life-web/src/components/TaskList.jsx | 20 ++--- .../src/components/WishlistDetail.jsx | 77 ++++++------------- 5 files changed, 41 insertions(+), 78 deletions(-) diff --git a/VERSION b/VERSION index 6075c9a..a7e7070 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.21.0 +3.22.0 diff --git a/play-life-web/package.json b/play-life-web/package.json index f9fc521..2d5b3b4 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "3.21.0", + "version": "3.22.0", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/components/TaskForm.jsx b/play-life-web/src/components/TaskForm.jsx index 580615c..d9fef54 100644 --- a/play-life-web/src/components/TaskForm.jsx +++ b/play-life-web/src/components/TaskForm.jsx @@ -643,8 +643,8 @@ function TaskForm({ onNavigate, taskId, wishlistId, isTest: isTestFromProps = fa // При создании: отправляем currentWishlistId если указан (уже число) // При редактировании: отправляем null только если была привязка (currentWishlistId) и пользователь отвязал (!wishlistInfo) // Если не было привязки или привязка осталась - не отправляем поле (undefined) - wishlist_id: taskId - ? (currentWishlistId && !wishlistInfo ? null : undefined) + wishlist_id: taskId + ? currentWishlistId // При редактировании сохраняем текущую привязку к желанию : (currentWishlistId || undefined), reward_policy: (wishlistInfo || currentWishlistId) ? rewardPolicy : undefined, rewards: rewards.map(r => ({ @@ -806,16 +806,6 @@ function TaskForm({ onNavigate, taskId, wishlistId, isTest: isTestFromProps = fa Связана с желанием: {wishlistInfo.name} - {taskId && currentWishlistId && ( - - )}
@@ -837,7 +827,7 @@ function TaskForm({ onNavigate, taskId, wishlistId, isTest: isTestFromProps = fa
)} - {!isTest && ( + {!isTest && !wishlistInfo && (
)} + {!wishlistInfo && (
{(() => { @@ -1007,6 +998,7 @@ function TaskForm({ onNavigate, taskId, wishlistId, isTest: isTestFromProps = fa ) })()}
+ )}
diff --git a/play-life-web/src/components/TaskList.jsx b/play-life-web/src/components/TaskList.jsx index a8f3227..ed7c4be 100644 --- a/play-life-web/src/components/TaskList.jsx +++ b/play-life-web/src/components/TaskList.jsx @@ -636,16 +636,16 @@ function TaskList({ onNavigate, data, loading, backgroundLoading, error, onRetry )} - {isOneTime && ( - diff --git a/play-life-web/src/components/WishlistDetail.jsx b/play-life-web/src/components/WishlistDetail.jsx index e86de53..be35598 100644 --- a/play-life-web/src/components/WishlistDetail.jsx +++ b/play-life-web/src/components/WishlistDetail.jsx @@ -170,69 +170,34 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId }) { } } - const handleUnlinkTask = async (e) => { + const handleDeleteTask = async (e) => { e.stopPropagation() if (!wishlistItem?.linked_task) return + if (!window.confirm('Удалить задачу, связанную с желанием?')) { + return + } + try { - // Загружаем текущую задачу - const taskResponse = await authFetch(`/api/tasks/${wishlistItem.linked_task.id}`) - if (!taskResponse.ok) { - throw new Error('Ошибка при загрузке задачи') - } - const taskData = await taskResponse.json() - const task = taskData.task - - // Формируем payload для обновления задачи - const payload = { - name: task.name, - reward_message: task.reward_message || null, - progression_base: task.progression_base || null, - repetition_period: task.repetition_period || null, - repetition_date: task.repetition_date || null, - wishlist_id: null, // Отвязываем от желания - rewards: (task.rewards || []).map(r => ({ - position: r.position, - project_name: r.project_name, - value: r.value, - use_progression: r.use_progression || false - })), - subtasks: (task.subtasks || []).map(st => ({ - id: st.id, - name: st.name || null, - reward_message: st.reward_message || null, - rewards: (st.rewards || []).map(r => ({ - position: r.position, - project_name: r.project_name, - value: r.value, - use_progression: r.use_progression || false - })) - })) - } - - // Обновляем задачу, отвязывая от желания - const updateResponse = await authFetch(`/api/tasks/${wishlistItem.linked_task.id}`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(payload), + // Удаляем задачу (помечаем как удалённую) + const deleteResponse = await authFetch(`/api/tasks/${wishlistItem.linked_task.id}`, { + method: 'DELETE', }) - if (!updateResponse.ok) { - const errorData = await updateResponse.json().catch(() => ({})) - throw new Error(errorData.message || errorData.error || 'Ошибка при отвязке задачи') + if (!deleteResponse.ok) { + const errorData = await deleteResponse.json().catch(() => ({})) + throw new Error(errorData.message || errorData.error || 'Ошибка при удалении задачи') } - setToastMessage({ text: 'Задача отвязана от желания', type: 'success' }) + setToastMessage({ text: 'Задача удалена', type: 'success' }) // Обновляем данные желания fetchWishlistDetail() if (onRefresh) { onRefresh() } } catch (err) { - console.error('Error unlinking task:', err) - setToastMessage({ text: err.message || 'Ошибка при отвязке задачи', type: 'error' }) + console.error('Error deleting task:', err) + setToastMessage({ text: err.message || 'Ошибка при удалении задачи', type: 'error' }) } } @@ -461,11 +426,17 @@ function WishlistDetail({ wishlistId, onNavigate, onRefresh, boardId }) {