v3.5.3: Убрана группировка бесконечных задач, добавлена иконка бесконечности, улучшен UI модального окна переноса
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 35s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 35s
This commit is contained in:
@@ -78,9 +78,21 @@ function TaskForm({ onNavigate, taskId }) {
|
||||
setRewardMessage(data.task.reward_message || '')
|
||||
setProgressionBase(data.task.progression_base ? String(data.task.progression_base) : '')
|
||||
|
||||
// Парсим repetition_date если он есть (приоритет над repetition_period)
|
||||
if (data.task.repetition_date) {
|
||||
const dateStr = data.task.repetition_date.trim()
|
||||
// Проверяем, является ли задача бесконечной (оба поля = 0)
|
||||
const periodStr = data.task.repetition_period ? data.task.repetition_period.trim() : ''
|
||||
const dateStr = data.task.repetition_date ? data.task.repetition_date.trim() : ''
|
||||
const isPeriodZero = periodStr && (periodStr === '0 day' || periodStr.startsWith('0 '))
|
||||
const isDateZero = dateStr && (dateStr === '0 week' || dateStr.startsWith('0 '))
|
||||
const isInfinite = isPeriodZero && isDateZero
|
||||
|
||||
if (isInfinite) {
|
||||
// Бесконечная задача: показываем 0 в форме
|
||||
setRepetitionPeriodValue('0')
|
||||
setRepetitionPeriodType('day')
|
||||
setRepetitionMode('after')
|
||||
console.log('Loading infinite task: both repetition_period and repetition_date are 0')
|
||||
} else if (data.task.repetition_date) {
|
||||
// Парсим repetition_date если он есть (приоритет над repetition_period)
|
||||
console.log('Parsing repetition_date:', dateStr) // Отладка
|
||||
|
||||
// Формат: "N unit" где unit = week, month, year
|
||||
@@ -415,15 +427,26 @@ function TaskForm({ onNavigate, taskId }) {
|
||||
|
||||
if (repetitionPeriodValue && repetitionPeriodValue.trim() !== '') {
|
||||
const valueStr = repetitionPeriodValue.trim()
|
||||
const value = parseInt(valueStr, 10)
|
||||
|
||||
if (repetitionMode === 'each') {
|
||||
// Проверяем, является ли значение нулевым (бесконечная задача)
|
||||
const isZero = !isNaN(value) && value === 0
|
||||
|
||||
if (isZero) {
|
||||
// Бесконечная задача: устанавливаем оба поля в 0
|
||||
// Для repetition_period используем "0 day"
|
||||
repetitionPeriod = '0 day'
|
||||
// Для repetition_date используем "0 week" (можно использовать любой тип, но week - наиболее универсальный)
|
||||
repetitionDate = '0 week'
|
||||
console.log('Creating infinite task: repetition_period=0 day, repetition_date=0 week')
|
||||
} else if (repetitionMode === 'each') {
|
||||
// Режим "Каждое" - сохраняем как repetition_date
|
||||
// Формат: "N unit" где unit = week, month, year
|
||||
repetitionDate = `${valueStr} ${repetitionPeriodType}`
|
||||
repetitionPeriod = null // Убеждаемся, что repetition_period = null
|
||||
console.log('Sending repetition_date:', repetitionDate)
|
||||
} else {
|
||||
// Режим "Через" - сохраняем как repetition_period (INTERVAL)
|
||||
const value = parseInt(valueStr, 10)
|
||||
if (!isNaN(value) && value >= 0) {
|
||||
const typeMap = {
|
||||
'minute': 'minute',
|
||||
@@ -435,12 +458,24 @@ function TaskForm({ onNavigate, taskId }) {
|
||||
}
|
||||
const unit = typeMap[repetitionPeriodType] || 'day'
|
||||
repetitionPeriod = `${value} ${unit}`
|
||||
repetitionDate = null // Убеждаемся, что repetition_date = null
|
||||
console.log('Sending repetition_period:', repetitionPeriod, 'from value:', repetitionPeriodValue, 'type:', repetitionPeriodType)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('No repetition to send (value:', repetitionPeriodValue, 'type:', repetitionPeriodType, 'mode:', repetitionMode, ')')
|
||||
}
|
||||
|
||||
// Валидация: если repetition_period != null, то repetition_date == null и наоборот, кроме случая когда они оба == 0
|
||||
if (repetitionPeriod && repetitionDate) {
|
||||
const isPeriodZero = repetitionPeriod.trim() === '0 day' || repetitionPeriod.trim().startsWith('0 ')
|
||||
const isDateZero = repetitionDate.trim() === '0 week' || repetitionDate.trim().startsWith('0 ')
|
||||
if (!isPeriodZero || !isDateZero) {
|
||||
setError('Нельзя одновременно использовать repetition_period и repetition_date, кроме случая бесконечной задачи (оба = 0)')
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const payload = {
|
||||
name: name.trim(),
|
||||
|
||||
Reference in New Issue
Block a user