diff --git a/composeApp/src/commonMain/kotlin/com/example/casera/models/CustomTask.kt b/composeApp/src/commonMain/kotlin/com/example/casera/models/CustomTask.kt index d38d91d..780db19 100644 --- a/composeApp/src/commonMain/kotlin/com/example/casera/models/CustomTask.kt +++ b/composeApp/src/commonMain/kotlin/com/example/casera/models/CustomTask.kt @@ -44,6 +44,7 @@ data class TaskResponse( @SerialName("frequency_id") val frequencyId: Int? = null, val frequency: TaskFrequency? = null, @SerialName("due_date") val dueDate: String? = null, + @SerialName("next_due_date") val nextDueDate: String? = null, // For recurring tasks, updated after each completion @SerialName("estimated_cost") val estimatedCost: Double? = null, @SerialName("actual_cost") val actualCost: Double? = null, @SerialName("contractor_id") val contractorId: Int? = null, @@ -74,8 +75,11 @@ data class TaskResponse( val priorityName: String? get() = priority?.name val priorityDisplayName: String? get() = priority?.displayName + // Effective due date: use nextDueDate if set (for recurring tasks), otherwise use dueDate + val effectiveDueDate: String? get() = nextDueDate ?: dueDate + // Fields that don't exist in Go API - return null/default - val nextScheduledDate: String? get() = null // Would need calculation based on frequency + val nextScheduledDate: String? get() = nextDueDate // Now we have this from the API val showCompletedButton: Boolean get() = true // Always show complete button since status is now just in_progress boolean val daySpan: Int? get() = frequency?.days val notifyDays: Int? get() = null // Not in Go API diff --git a/iosApp/iosApp/Helpers/WidgetDataManager.swift b/iosApp/iosApp/Helpers/WidgetDataManager.swift index 3438791..4aec92f 100644 --- a/iosApp/iosApp/Helpers/WidgetDataManager.swift +++ b/iosApp/iosApp/Helpers/WidgetDataManager.swift @@ -275,7 +275,7 @@ final class WidgetDataManager { description: task.description_, priority: task.priority?.name ?? "", inProgress: task.inProgress, - dueDate: task.dueDate, + dueDate: task.effectiveDueDate, // Use effective date (nextDueDate if set, otherwise dueDate) category: task.category?.name ?? "", residenceName: "", // No longer available in API, residence lookup needed isOverdue: column.name == "overdue_tasks" diff --git a/iosApp/iosApp/Subviews/Task/DynamicTaskCard.swift b/iosApp/iosApp/Subviews/Task/DynamicTaskCard.swift index 19a1398..ce2d060 100644 --- a/iosApp/iosApp/Subviews/Task/DynamicTaskCard.swift +++ b/iosApp/iosApp/Subviews/Task/DynamicTaskCard.swift @@ -49,8 +49,8 @@ struct DynamicTaskCard: View { Spacer() - if let due_date = task.dueDate { - Label(DateUtils.formatDate(due_date), systemImage: "calendar") + if let effectiveDate = task.effectiveDueDate { + Label(DateUtils.formatDate(effectiveDate), systemImage: "calendar") .font(.caption) .foregroundColor(Color.appTextSecondary) } diff --git a/iosApp/iosApp/Subviews/Task/TaskCard.swift b/iosApp/iosApp/Subviews/Task/TaskCard.swift index 0b38802..94c356b 100644 --- a/iosApp/iosApp/Subviews/Task/TaskCard.swift +++ b/iosApp/iosApp/Subviews/Task/TaskCard.swift @@ -58,12 +58,12 @@ struct TaskCard: View { Spacer() - if let dueDate = task.dueDate { + if let effectiveDate = task.effectiveDueDate { HStack(spacing: AppSpacing.xxs) { Image(systemName: "calendar") .font(.system(size: 12, weight: .medium)) .foregroundColor(Color.appTextSecondary.opacity(0.7)) - Text(DateUtils.formatDate(dueDate)) + Text(DateUtils.formatDate(effectiveDate)) .font(.caption.weight(.medium)) .foregroundColor(Color.appTextSecondary) } @@ -262,6 +262,7 @@ struct TaskCard: View { frequencyId: 1, frequency: TaskFrequency(id: 1, name: "monthly", days: 30, displayOrder: 0), dueDate: "2024-12-15", + nextDueDate: nil, estimatedCost: 150.00, actualCost: nil, contractorId: nil, diff --git a/iosApp/iosApp/Subviews/Task/TasksSection.swift b/iosApp/iosApp/Subviews/Task/TasksSection.swift index bedf0e2..fb05fa0 100644 --- a/iosApp/iosApp/Subviews/Task/TasksSection.swift +++ b/iosApp/iosApp/Subviews/Task/TasksSection.swift @@ -96,6 +96,7 @@ struct TasksSection: View { frequencyId: 1, frequency: TaskFrequency(id: 1, name: "monthly", days: 30, displayOrder: 0), dueDate: "2024-12-15", + nextDueDate: nil, estimatedCost: 150.00, actualCost: nil, contractorId: nil, @@ -135,6 +136,7 @@ struct TasksSection: View { frequencyId: 6, frequency: TaskFrequency(id: 6, name: "once", days: nil, displayOrder: 0), dueDate: "2024-11-01", + nextDueDate: nil, estimatedCost: 200.00, actualCost: nil, contractorId: nil, diff --git a/iosApp/iosApp/Task/TaskFormView.swift b/iosApp/iosApp/Task/TaskFormView.swift index 569a3a8..2419a2b 100644 --- a/iosApp/iosApp/Task/TaskFormView.swift +++ b/iosApp/iosApp/Task/TaskFormView.swift @@ -66,10 +66,10 @@ struct TaskFormView: View { _selectedPriority = State(initialValue: task.priority) _inProgress = State(initialValue: task.inProgress) - // Parse date from string + // Parse date from string - use effective due date (nextDueDate if set, otherwise dueDate) let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd" - _dueDate = State(initialValue: formatter.date(from: task.dueDate ?? "") ?? Date()) + _dueDate = State(initialValue: formatter.date(from: task.effectiveDueDate ?? "") ?? Date()) _intervalDays = State(initialValue: "") // No longer in API _estimatedCost = State(initialValue: task.estimatedCost != nil ? String(task.estimatedCost!.doubleValue) : "")