Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ extension SelectTreatmentView {
VStack(alignment: .leading, spacing: 0){

TypographyText("시술 일정을 추가해볼게요.", style: .title1_sb_18, color: .gray1000)
.frame(height: 27.adjustedH)
.frame(height: 30.adjustedH)
TypographyText("이미 생각해둔 시술이 있나요?", style: .title1_sb_18, color: .gray1000)
.frame(height: 27.adjustedH)
.frame(height: 30.adjustedH)



Spacer()
.frame(height: 4.adjustedH)
TypographyText("시술을 선택하셨는지 확인할게요.", style: .body1_r_14, color: .gray700)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ struct TreatmentFilterView: View {
isDisabled: false
)
.padding(.horizontal, 25.adjustedW)
.padding(.bottom, 8.adjustedH)
Spacer()
.frame(height: 8.adjustedH)
ScrollView(.vertical, showsIndicators: false) {
HStack(alignment: .top,spacing: 4) {
TypographyText("◎", style: .body3_r_12, color: .gray600)
Expand All @@ -33,14 +34,15 @@ struct TreatmentFilterView: View {
color: .gray600
)
.lineLimit(2)

}

Spacer()

}
.frame(height: 34.adjustedH)
.padding(.horizontal, 25.adjustedW)

Spacer()
.frame(height: 20.adjustedH)

if viewModel.treatments.isEmpty {
Spacer()
.frame(height: 148.adjustedH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ final class NoTreatmentViewModel: ObservableObject{
}

func isDateTextFieldNotEmpty() -> Bool {
guard let scheduledDate = calendarTreatmentFlowState.selectedDate else {
return false
}

guard !year.isEmpty, !month.isEmpty, !day.isEmpty else {
Task { @MainActor in
updateWarning(state: .none)
Expand All @@ -133,14 +137,28 @@ final class NoTreatmentViewModel: ObservableObject{
return false
}


let today = Calendar.current.startOfDay(for: Date())

if date < today {
updateWarning(state: .pastDate)
return false
if date < scheduledDate {
updateWarning(state: .pastDate)
return false
}

} else {
if date < scheduledDate {
if date < today {
updateWarning(state: .pastDate)
}
updateWarning(state: .beforeProcedureDate)
return false
}
Comment on lines 141 to +156
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

도달 불가능한 분기 제거로 경고 로직 단순화

Line 149의 else는 date >= today를 보장하므로 Line 151의 date < today는 항상 false입니다. 현재 구조는 경고 업데이트 의도를 흐릴 수 있어 분기 정리를 권장합니다.

🔧 제안 수정안
-        if date < today {
-            if date < scheduledDate {
-                updateWarning(state: .pastDate)
-                return false
-            }
-            
-        } else {
-            if date < scheduledDate {
-                if date < today {
-                    updateWarning(state: .pastDate)
-                }
-                updateWarning(state: .beforeProcedureDate)
-                 return false
-            }
-        }
+        if date < today {
+            if date < scheduledDate {
+                updateWarning(state: .pastDate)
+                return false
+            }
+        } else if date < scheduledDate {
+            updateWarning(state: .beforeProcedureDate)
+            return false
+        }
🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/ViewModel/NoTreatment/NoTreatmentViewModel.swift`
around lines 141 - 156, The inner check for `date < today` inside the `else`
branch is unreachable because the `else` guarantees `date >= today`; simplify
the branching in NoTreatmentViewModel by removing that impossible condition and
collapsing logic to: if `date < today` -> call `updateWarning(state: .pastDate)`
and return false; else if `date < scheduledDate` -> call `updateWarning(state:
.beforeProcedureDate)` and return false; keep references to `date`, `today`,
`scheduledDate`, and `updateWarning(state:)` intact so behavior remains the same
but with the unreachable branch removed.

}

updateWarning(state: .none)
return true

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ final class TreatmentViewModel: ObservableObject{
}

func isDateTextFieldNotEmpty() -> Bool {
guard let scheduledDate = calendarTreatmentFlowState.selectedDate else {
return false
}

guard !year.isEmpty, !month.isEmpty, !day.isEmpty else {
Task { @MainActor in
updateWarning(state: .none)
Expand All @@ -124,14 +128,28 @@ final class TreatmentViewModel: ObservableObject{
return false
}


let today = Calendar.current.startOfDay(for: Date())

if date < today {
updateWarning(state: .pastDate)
return false
if date < scheduledDate {
updateWarning(state: .pastDate)
return false
}

} else {
if date < scheduledDate {
if date < today {
updateWarning(state: .pastDate)
}
updateWarning(state: .beforeProcedureDate)
return false
}
Comment on lines 132 to +147
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

도달 불가능한 분기 제거로 경고 로직 단순화

Line 140의 else는 date >= today 조건이므로 Line 142의 date < today는 항상 false입니다. 분기를 단순화하면 의도가 명확해집니다.

🔧 제안 수정안
-        if date < today {
-            if date < scheduledDate {
-                updateWarning(state: .pastDate)
-                return false
-            }
-            
-        } else {
-            if date < scheduledDate {
-                if date < today {
-                    updateWarning(state: .pastDate)
-                }
-                updateWarning(state: .beforeProcedureDate)
-                 return false
-            }
-        }
+        if date < today {
+            if date < scheduledDate {
+                updateWarning(state: .pastDate)
+                return false
+            }
+        } else if date < scheduledDate {
+            updateWarning(state: .beforeProcedureDate)
+            return false
+        }
🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/ViewModel/Treatment/TreatmentViewModel.swift`
around lines 132 - 147, The else branch contains an unreachable check (date <
today) and should be simplified: in the else (where date >= today) remove the
nested "if date < today" and, when date < scheduledDate, call
updateWarning(state: .beforeProcedureDate) and return false; keep the earlier
branch that sets updateWarning(state: .pastDate) when date < today && date <
scheduledDate so .pastDate logic remains intact. Reference: variables date,
today, scheduledDate and the updateWarning(state:
.pastDate)/updateWarning(state: .beforeProcedureDate) calls in
TreatmentViewModel.

}

updateWarning(state: .none)
return true

}


Expand Down