Исправления формы желаний, очистка кода
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 46s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 46s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "play-life-web",
|
||||
"version": "3.10.2",
|
||||
"version": "3.10.3",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -668,6 +668,7 @@ function AppContent() {
|
||||
}
|
||||
// Обновляем список желаний при возврате из экрана редактирования
|
||||
if (activeTab === 'wishlist-form' && tab === 'wishlist') {
|
||||
setTabParams({}) // Очищаем параметры при закрытии формы
|
||||
setWishlistRefreshTrigger(prev => prev + 1)
|
||||
}
|
||||
// Загрузка данных произойдет в useEffect при изменении activeTab
|
||||
|
||||
@@ -484,19 +484,6 @@ function TaskList({ onNavigate, data, loading, backgroundLoading, error, onRetry
|
||||
// Одноразовая задача: когда оба поля null/undefined
|
||||
const isOneTime = (task.repetition_period == null || task.repetition_period === undefined) &&
|
||||
(task.repetition_date == null || task.repetition_date === undefined)
|
||||
|
||||
// Отладка для задачи "Ролик"
|
||||
if (task.name === 'Ролик') {
|
||||
console.log('Task "Ролик":', {
|
||||
name: task.name,
|
||||
repetition_period: task.repetition_period,
|
||||
repetition_date: task.repetition_date,
|
||||
next_show_at: task.next_show_at,
|
||||
hasZeroPeriod,
|
||||
hasZeroDate,
|
||||
isInfinite
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -65,24 +65,44 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex }) {
|
||||
}
|
||||
}, [wishlistId, tasks, projects])
|
||||
|
||||
// Сброс формы при размонтировании компонента
|
||||
// Сброс формы при размонтировании компонента или при изменении wishlistId на undefined
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
resetForm()
|
||||
}
|
||||
}, [])
|
||||
}, [wishlistId])
|
||||
|
||||
// Открываем форму редактирования условия, если передан editConditionIndex
|
||||
useEffect(() => {
|
||||
if (editConditionIndex !== undefined && editConditionIndex !== null && unlockConditions.length > editConditionIndex) {
|
||||
setEditingConditionIndex(editConditionIndex)
|
||||
setShowConditionForm(true)
|
||||
} else if (editConditionIndex === undefined || editConditionIndex === null) {
|
||||
// Закрываем форму условия, если editConditionIndex сброшен
|
||||
setEditingConditionIndex(null)
|
||||
setShowConditionForm(false)
|
||||
}
|
||||
}, [editConditionIndex, unlockConditions])
|
||||
|
||||
const loadWishlist = async () => {
|
||||
setLoadingWishlist(true)
|
||||
try {
|
||||
// Сначала очищаем форму, чтобы удалить старые данные
|
||||
setName('')
|
||||
setPrice('')
|
||||
setLink('')
|
||||
setImageUrl(null)
|
||||
setImageFile(null)
|
||||
setUnlockConditions([])
|
||||
setError('')
|
||||
setShowCropper(false)
|
||||
setCrop({ x: 0, y: 0 })
|
||||
setZoom(1)
|
||||
setCroppedAreaPixels(null)
|
||||
setShowConditionForm(false)
|
||||
setEditingConditionIndex(null)
|
||||
setToastMessage(null)
|
||||
|
||||
const response = await authFetch(`${API_URL}/${wishlistId}`)
|
||||
if (!response.ok) {
|
||||
throw new Error('Ошибка загрузки желания')
|
||||
@@ -102,6 +122,8 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex }) {
|
||||
start_date: cond.start_date || null,
|
||||
display_order: idx,
|
||||
})))
|
||||
} else {
|
||||
setUnlockConditions([])
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
|
||||
Reference in New Issue
Block a user