Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
@@ -0,0 +1,19 @@
//
// UserProcedureItemRequestDTO.swift
// Cherrish-iOS
//
// Created by 어재선 on 1/21/26.
//
Comment on lines +1 to +6
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

파일 헤더 주석의 파일명이 실제 파일명과 불일치합니다.

주석에는 UserProcedureItemRequestDTO.swift로 되어 있으나, 실제 파일명은 CreateUserProcedureRequestDTO.swift입니다.

✏️ 수정 제안
 //
-//  UserProcedureItemRequestDTO.swift
+//  CreateUserProcedureRequestDTO.swift
 //  Cherrish-iOS
 //
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//
// UserProcedureItemRequestDTO.swift
// Cherrish-iOS
//
// Created by 어재선 on 1/21/26.
//
//
// CreateUserProcedureRequestDTO.swift
// Cherrish-iOS
//
// Created by 어재선 on 1/21/26.
//
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Model/CreateUserProcedureRequestDTO.swift`
around lines 1 - 6, 파일 헤더 주석의 파일명이 실제 파일명과 일치하지 않습니다: 현재 상단 주석에
`UserProcedureItemRequestDTO.swift`가 적혀 있으나 파일명은
`CreateUserProcedureRequestDTO.swift`입니다; 파일 상단의 주석 블록(헤더 코멘트)을 찾아
`UserProcedureItemRequestDTO.swift`를 `CreateUserProcedureRequestDTO.swift`로 수정하여
헤더와 실제 파일명이 일치하도록 고치세요.

Copy link
Member

Choose a reason for hiding this comment

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

이거한번만봐주세염


import Foundation

struct UserProcedureItemRequestDTO: Encodable, Decodable {
let procedureId: Int
let downtimeDays: Int
}

struct CreateUserProcedureRequestDTO: Encodable, Decodable {
Copy link
Member

Choose a reason for hiding this comment

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

리퀘스트니까 encodable만 쓰면 되겟져 ~~ ?

let scheduledAt: String
let recoveryTargetDate: String
let procedures: [UserProcedureItemRequestDTO]
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Codable 타입 별칭 사용을 권장합니다.

Encodable, Decodable을 명시적으로 나열하는 대신 Codable을 사용하면 더 간결합니다.

♻️ 리팩토링 제안
-struct UserProcedureItemRequestDTO: Encodable, Decodable {
+struct UserProcedureItemRequestDTO: Codable {
     let procedureId: Int
     let downtimeDays: Int
 }

-struct CreateUserProcedureRequestDTO: Encodable, Decodable {
+struct CreateUserProcedureRequestDTO: Codable {
     let scheduledAt: String
     let recoveryTargetDate: String
     let procedures: [UserProcedureItemRequestDTO]
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
struct UserProcedureItemRequestDTO: Encodable, Decodable {
let procedureId: Int
let downtimeDays: Int
}
struct CreateUserProcedureRequestDTO: Encodable, Decodable {
let scheduledAt: String
let recoveryTargetDate: String
let procedures: [UserProcedureItemRequestDTO]
struct UserProcedureItemRequestDTO: Codable {
let procedureId: Int
let downtimeDays: Int
}
struct CreateUserProcedureRequestDTO: Codable {
let scheduledAt: String
let recoveryTargetDate: String
let procedures: [UserProcedureItemRequestDTO]
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Model/CreateUserProcedureRequestDTO.swift`
around lines 10 - 18, Replace the repeated Encodable, Decodable declarations
with the Codable typealias on the DTOs: update both UserProcedureItemRequestDTO
and CreateUserProcedureRequestDTO to conform to Codable instead of listing
Encodable and Decodable separately, keeping existing property names and types
unchanged.

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension HomeAPI: EndPoint {
}
}

var queryParameters: [String: String]? {
var queryParameters: [String: Any]? {
switch self {
case .fetchDashboard:
return nil
Expand Down
43 changes: 34 additions & 9 deletions Cherrish-iOS/Cherrish-iOS/Data/Network/EndPoint/TreatmentAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import Alamofire
enum TreatmentAPI: EndPoint {
case fetchCategories(userId: Int)
case fetchProcedures(userId: Int, id: Int? = nil, text: String? = nil)
case createUserProcedure(userId: Int, request: CreateUserProcedureRequestDTO)

var basePath: String {
switch self {
case .fetchCategories:
return "/api"

case .fetchProcedures:
return "/api"
case .createUserProcedure:
return "/api"
}
}

Expand All @@ -28,6 +30,8 @@ enum TreatmentAPI: EndPoint {
return "/worries"
case .fetchProcedures:
return "/procedures"
case .createUserProcedure:
return "/user-procedures"
}
}

Expand All @@ -37,6 +41,8 @@ enum TreatmentAPI: EndPoint {
return .get
case .fetchProcedures:
return .get
case .createUserProcedure:
return .post
}
}

Expand All @@ -46,6 +52,9 @@ enum TreatmentAPI: EndPoint {
return .withAuth(userID: userId)
case .fetchProcedures(let userId, _, _):
return .withAuth(userID: userId)
case .createUserProcedure(let userId, _):
return .withAuth(userID: userId)

}
}

Expand All @@ -56,6 +65,8 @@ enum TreatmentAPI: EndPoint {
return URLEncoding.default
case .fetchProcedures:
return URLEncoding.default
case .createUserProcedure:
return JSONEncoding.default
}
}

Expand All @@ -65,22 +76,36 @@ enum TreatmentAPI: EndPoint {
return nil
case .fetchProcedures(_, let id, let text):
var params: [String: Any] = [:]
if let id = id {
params["worryId"] = id
}
if let text = text {
params["keyword"] = "\(text)"
}
return params
if let id = id {
params["worryId"] = id
}
if let text = text {
params["keyword"] = "\(text)"
}
return params
case .createUserProcedure:
return nil
}
}


var bodyParameters: Alamofire.Parameters? {
switch self {
case .fetchCategories:
return .none
case .fetchProcedures:
return .none
case .createUserProcedure(_, let request):
return [
"scheduledAt": request.scheduledAt,
"recoveryTargetDate": request.recoveryTargetDate,
"procedures": request.procedures.map {
[
"procedureId": $0.procedureId,
"downtimeDays": $0.downtimeDays
]
}
]
Comment on lines +98 to +108
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

DTO의 Encodable 준수를 활용하는 것을 고려하세요

CreateUserProcedureRequestDTO가 이미 Encodable을 준수하므로, 수동으로 딕셔너리를 생성하는 대신 직접 인코딩하는 것이 더 안전하고 유지보수하기 쉽습니다. 현재 방식은 DTO 구조가 변경될 때 두 곳을 수정해야 합니다.

♻️ 대안 제안

Alamofire와 함께 사용할 수 있도록 DTO를 Parameters로 변환하는 헬퍼를 만들거나, JSONParameterEncoder를 사용하는 것을 고려하세요:

// 옵션 1: DTO에 extension 추가
extension CreateUserProcedureRequestDTO {
    var asParameters: Parameters {
        guard let data = try? JSONEncoder().encode(self),
              let dict = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else {
            return [:]
        }
        return dict
    }
}

// 옵션 2: bodyParameters에서 사용
case .createUserProcedure(_, let request):
    return request.asParameters
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Network/EndPoint/TreatmentAPI.swift` around
lines 98 - 108, The manual dictionary construction in the TreatmentAPI case
.createUserProcedure should be replaced by encoding the existing
CreateUserProcedureRequestDTO to a Parameters-style dictionary to avoid
duplication; add an extension on CreateUserProcedureRequestDTO (or a helper)
that encodes self with JSONEncoder and converts to [String: Any] (e.g.,
asParameters) and then return request.asParameters from the createUserProcedure
case, or alternatively use Alamofire's JSONParameterEncoder when building the
request so the body is derived from the DTO rather than hand-constructed.

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import Foundation

struct DefaultTreatmentRepository: TreatmentInterface {


private let networkService: NetworkService
private let userDefaultService: UserDefaultService

Expand All @@ -32,9 +34,24 @@ struct DefaultTreatmentRepository: TreatmentInterface {
let response = try await networkService.request(TreatmentAPI.fetchProcedures(userId: userId,id: id, text: keyword), decodingType: ProceduresResponseDTO.self)
return response.procedures.map { $0.toEntity() }
}

func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws {
let userId: Int = userDefaultService.load(key: .userID) ?? 1
let request = CreateUserProcedureRequestDTO(
scheduledAt: scheduledDate,
recoveryTargetDate: recoveryDate,
procedures: treatments.compactMap { $0.toRequestDTO() }
)
let _ = try await networkService.request(TreatmentAPI.createUserProcedure(userId: userId, request: request), decodingType: UserProcedureItemRequestDTO.self)
}
Comment on lines +45 to +59
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, find and read the TreatmentRepository.swift file to understand the full context
find . -name "TreatmentRepository.swift" -type f

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 139


🏁 Script executed:

# Search for TreatmentInterface protocol definition
rg -n "protocol TreatmentInterface" --type swift -A 20

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 729


🏁 Script executed:

# Search for UserProcedureItemRequestDTO definition
rg -n "struct UserProcedureItemRequestDTO\|class UserProcedureItemRequestDTO" --type swift -A 5

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 52


🏁 Script executed:

# Search for response DTOs related to user procedures
rg -n "UserProcedure.*ResponseDTO\|UserProcedure.*Response\|.*ProcedureResponse" --type swift -A 5

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 52


🏁 Script executed:

# Search for TreatmentEntity and its toRequestDTO method
rg -n "func toRequestDTO" --type swift -B 2 -A 10

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 1048


🏁 Script executed:

# Search for MockTreatmentRepository
rg -n "class MockTreatmentRepository\|struct MockTreatmentRepository" --type swift -A 30

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 52


🏁 Script executed:

# Find UserProcedureItemRequestDTO definition with broader search
rg -n "UserProcedureItemRequestDTO" --type swift -B 2 -A 5

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 3706


🏁 Script executed:

# Read the full TreatmentRepository.swift file
cat -n ./Cherrish-iOS/Cherrish-iOS/Data/Repository/TreatmentRepository.swift

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 3175


🏁 Script executed:

# Search for MockTreatmentRepository without exact class/struct syntax
rg -n "MockTreatmentRepository" --type swift -B 2 -A 20

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 2471


🏁 Script executed:

# Search for any DTO that contains "Procedure" in name
rg -n "struct.*Procedure.*DTO\|class.*Procedure.*DTO" --type swift -A 3

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 52


procedures 배열이 비어서 전송될 수 있습니다.

compactMap { $0.toRequestDTO() }setDowntime이 nil인 모든 treatment를 필터링합니다. 모든 treatment의 setDowntime이 nil이면 빈 procedures 배열이 생성되어 API 요청이 전송됩니다. 이에 대한 유효성 검사 또는 에러 처리를 추가해야 합니다.

또한 Line 45의 응답 타입으로 UserProcedureItemRequestDTO를 사용하고 있는데, 이는 요청용 DTO입니다. 서버 응답에 맞는 별도의 Response DTO를 정의하고 사용해야 합니다.

추가로 MockTreatmentRepository의 createUserProcedure 메서드(Line 51)에 async throws 키워드가 누락되어 있습니다. TreatmentInterface 프로토콜 요구사항과 일치시켜주세요.

🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Repository/TreatmentRepository.swift` around
lines 38 - 46, createUserProcedure currently uses treatments.compactMap {
$0.toRequestDTO() } which drops any treatments whose setDowntime is nil and can
produce an empty procedures array; add validation in createUserProcedure to
check the resulting procedures array and throw (or return) a clear error before
calling networkService.request when procedures.isEmpty, and surface that error
to callers; replace the incorrect decodingType UserProcedureItemRequestDTO with
a dedicated response DTO (e.g., UserProcedureItemResponseDTO) that matches the
server response and update the request call (TreatmentAPI.createUserProcedure)
to decode that response type; finally, make
MockTreatmentRepository.createUserProcedure conform by adding the missing async
throws signature so it matches the TreatmentInterface protocol.

}

struct MockTreatmentRepository: TreatmentInterface {

func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) {

}
Comment on lines +64 to +66
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

MockTreatmentRepository.createUserProcedure 메서드 시그니처가 프로토콜과 불일치합니다.

DefaultTreatmentRepositorycreateUserProcedureasync throws로 선언되어 있으나, Mock 구현체는 이를 누락하고 있습니다. 프로토콜 TreatmentInterface의 요구사항과 일치시켜야 합니다.

🐛 수정 제안
-    func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) {
-        
+    func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws {
+        // Mock implementation - no-op
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) {
}
func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws {
// Mock implementation - no-op
}
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Data/Repository/TreatmentRepository.swift` around
lines 51 - 53, MockTreatmentRepository.createUserProcedure has a different
signature than the protocol and DefaultTreatmentRepository; update
MockTreatmentRepository.createUserProcedure to match the protocol's declaration
by adding async throws to its signature (so it matches TreatmentInterface and
DefaultTreatmentRepository), and ensure its implementation returns/throws
appropriately for the mock behavior.


func fetchTreatment(id: Int?, keyword: String?) async throws -> [TreatmentEntity] {
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ final class DomainDependencyAssembler: DependencyAssembler {
return
}

guard let treatmentCategoryRepository = DIContainer.shared.resolve(type: TreatmentInterface.self) else {
return
}

DIContainer.shared.register(type: FetchProcedureCountOfMonth.self) {
return DefaultFetchProcedureCountOfMonth(repository: calendarRepository)
}
Expand Down Expand Up @@ -76,5 +72,9 @@ final class DomainDependencyAssembler: DependencyAssembler {
DIContainer.shared.register(type: FetchUserInfoUseCase.self) {
return DefaultFetchUserInfoUserCase(repository: myPageRepository)
}

DIContainer.shared .register(type: CreateUserProcedureUseCase.self) {
return DefaultCreateUserProcedureUseCase(repository: treatmentRepository)
}
Comment on lines +76 to +78
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

포맷팅 수정 필요

DIContainer.shared .register 사이에 불필요한 공백이 있습니다.

🧹 포맷팅 수정
-        DIContainer.shared .register(type: CreateUserProcedureUseCase.self) {
+        DIContainer.shared.register(type: CreateUserProcedureUseCase.self) {
             return DefaultCreateUserProcedureUseCase(repository: treatmentRepository)
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
DIContainer.shared .register(type: CreateUserProcedureUseCase.self) {
return DefaultCreateUserProcedureUseCase(repository: treatmentRepository)
}
DIContainer.shared.register(type: CreateUserProcedureUseCase.self) {
return DefaultCreateUserProcedureUseCase(repository: treatmentRepository)
}
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Domain/DomainDependencyAssembler.swift` around
lines 76 - 78, Remove the stray whitespace between DIContainer.shared and
.register in the registration call so it reads as
DIContainer.shared.register(...); locate the registration for
CreateUserProcedureUseCase that returns
DefaultCreateUserProcedureUseCase(repository: treatmentRepository) and fix the
spacing around the dot to match surrounding calls.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ import Foundation
protocol TreatmentInterface {
func fetchCategories() async throws -> [TreatmentCategoryEntity]
func fetchTreatment(id: Int?, keyword: String?) async throws -> [TreatmentEntity]
func createUserProcedure(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws
}
10 changes: 9 additions & 1 deletion Cherrish-iOS/Cherrish-iOS/Domain/Model/TreatmentEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@ struct TreatmentEntity: Identifiable, Equatable, Hashable {
}
}


extension TreatmentEntity {
func toRequestDTO() -> UserProcedureItemRequestDTO? {
guard let downtime = setDowntime else { return nil }
return UserProcedureItemRequestDTO(
procedureId: id,
downtimeDays: downtime
)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// CreateUserProcedureUseCase.swift
// Cherrish-iOS
//
// Created by 어재선 on 1/21/26.
//

import Foundation

protocol CreateUserProcedureUseCase {
func excute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws
}
Comment on lines +10 to +12
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

오타: excuteexecute

메서드 이름에 오타가 있습니다. 관련 코드 스니펫에서 확인된 NoTreatmentViewModelTreatmentViewModel의 호출부도 함께 수정이 필요합니다.

✏️ 수정 제안
 protocol CreateUserProcedureUseCase {
-    func excute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws
+    func execute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
protocol CreateUserProcedureUseCase {
func excute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws
}
protocol CreateUserProcedureUseCase {
func execute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws
}
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Domain/UseCase/CreateUserProcedureUseCase.swift`
around lines 10 - 12, Rename the misspelled protocol method excute to execute in
CreateUserProcedureUseCase and update all call sites to the new name;
specifically change the protocol declaration (CreateUserProcedureUseCase) and
adjust any invocations in NoTreatmentViewModel and TreatmentViewModel to call
execute(scheduledDate:recoveryDate:treatments:) so signatures stay consistent
and compilation errors are resolved.

Copy link
Member

Choose a reason for hiding this comment

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

오타 고쳐주세욤


struct DefaultCreateUserProcedureUseCase: CreateUserProcedureUseCase {

private let repository: TreatmentInterface

init(repository: TreatmentInterface) {
self.repository = repository
}

func excute(scheduledDate: String, recoveryDate: String, treatments: [TreatmentEntity]) async throws {
return try await repository.createUserProcedure(scheduledDate: scheduledDate, recoveryDate: recoveryDate, treatments: treatments)
}
Copy link
Member

Choose a reason for hiding this comment

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

개행 한번만요!

}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ extension CalendarView {
.foregroundStyle(.gray600)
.frame(width: 24.adjustedW, height: 24.adjustedH)
.onTapGesture {
viewModel.confirmDate()
calendarCoordinator.push(.selectTreatment)
}
case .selectedProcedure:
Expand Down Expand Up @@ -252,9 +253,11 @@ extension CalendarView {
leadingIcon: Image(.plus),
trailingIcon: nil,
action: {
viewModel.confirmDate()
calendarCoordinator.push(
.selectTreatment
)

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 260의 불필요한 공백을 제거해 주세요.

🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/CalendarMain/CalendarView.swift`
around lines 256 - 260, 해당 블록에서 viewModel.confirmDate() 호출 후
calendarCoordinator.push(.selectTreatment) 호출 다음에 있는 불필요한 공백 라인(현재 빈 줄)을 제거하세요;
즉 CalendarView.swift의 해당 코드 블록에서 calendarCoordinator.push(.selectTreatment) 뒤에
있는 빈 줄을 삭제하여 불필요한 공백을 없애면 됩니다.

}
)
.padding(.horizontal, 24)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@ final class CalendarViewModel: ObservableObject {
private let fetchProcedureCountOfMonthUseCase: FetchProcedureCountOfMonth
private let fetchTodayProcedureListUseCase: FetchTodayProcedureListUseCase
private let fetchProcedureDowntimeUseCase: FetchProcedureDowntimeUseCase
private let calendarTreatmentFlowState: CalendarTreatmentFlowState

init(
fetchProcedureCountOfMonthUseCase: FetchProcedureCountOfMonth,
fetchTodayProcedureListUseCase: FetchTodayProcedureListUseCase,
fetchProcedureDowntimeUseCase: FetchProcedureDowntimeUseCase
fetchProcedureDowntimeUseCase: FetchProcedureDowntimeUseCase,
calendarTreatmentFlowState: CalendarTreatmentFlowState
) {
self.fetchProcedureCountOfMonthUseCase = fetchProcedureCountOfMonthUseCase
self.fetchTodayProcedureListUseCase = fetchTodayProcedureListUseCase
self.calendarTreatmentFlowState = calendarTreatmentFlowState
self.fetchProcedureDowntimeUseCase = fetchProcedureDowntimeUseCase
}

func confirmDate() {
calendarTreatmentFlowState.selectedDaet = selectedDate
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# CalendarTreatmentFlowState 및 관련 프로퍼티 검색
rg -n "selectedDaet|selectedDate" --type swift

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 1889


🏁 Script executed:

#!/bin/bash
# CalendarTreatmentFlowState 파일 찾기 및 프로퍼티 정의 확인
fd -e swift | xargs rg -l "CalendarTreatmentFlowState" | head -5

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 554


🏁 Script executed:

#!/bin/bash
# sendDateToTreatmentView 메서드 검색 - 코드 중복 확인
rg -n "sendDateToTreatmentView|confirmDate" --type swift -A 3

Repository: TEAM-Cherrish/Cherrish-iOS

Length of output: 2139


selectedDaet 오타 및 중복 메서드 정리 필요

CalendarTreatmentFlowState의 프로퍼티명이 selectedDaet로 정의되어 있습니다. 이는 selectedDate의 오타로 보이며, 현재 CalendarViewModel의 selectedDate 프로퍼티와 네이밍이 불일치합니다. CalendarTreatmentFlowState의 프로퍼티명을 selectedDate로 수정하세요.

또한 confirmDate()sendDateToTreatmentView() 메서드가 동일한 구현을 가지고 있으므로 중복을 제거하세요.

🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/CalendarMain/CalendarViewModel.swift`
around lines 43 - 45, Rename the typo property selectedDaet to selectedDate in
CalendarTreatmentFlowState and update all references to the new name (search for
selectedDaet usages), then in CalendarViewModel change the assignment in
confirmDate() to use calendarTreatmentFlowState.selectedDate = selectedDate;
finally remove the duplicate method sendDateToTreatmentView() (or make it call
confirmDate()) so only one implementation remains (update any call sites to the
single method name to avoid breakage).

Copy link
Member

Choose a reason for hiding this comment

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

이거 한번만 봐주세용


func select(date: Date) {
selectedDate = date
}
Expand Down Expand Up @@ -94,6 +101,10 @@ final class CalendarViewModel: ObservableObject {
return procedureList.isEmpty
}

func sendDateToTreatmentView() {
calendarTreatmentFlowState.selectedDaet = selectedDate
}

@MainActor
func fetchProcedureCountsOfMonth() async throws {
let calendar = Calendar.current
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// CalendarTreatmentFlowState.swift
// Cherrish-iOS
//
// Created by 이나연 on 1/21/26.
//

import Foundation

final class CalendarTreatmentFlowState: ObservableObject {
@Published var selectedDaet: Date?
}
Comment on lines +10 to +12
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

오타 수정 필요: selectedDaetselectedDate

프로퍼티 이름에 오타가 있습니다. selectedDaetselectedDate로 수정해야 합니다. 이 오타가 다른 파일(NoTreatmentViewModel, TreatmentViewModel 등)에도 전파되므로 일괄 수정이 필요합니다.

🔧 수정 제안
 final class CalendarTreatmentFlowState: ObservableObject {
-    `@Published` var selectedDaet: Date?
+    `@Published` var selectedDate: Date?
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
final class CalendarTreatmentFlowState: ObservableObject {
@Published var selectedDaet: Date?
}
final class CalendarTreatmentFlowState: ObservableObject {
`@Published` var selectedDate: Date?
}
🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/CalendarTreatmentFlowState.swift`
around lines 10 - 12, Rename the mistyped property selectedDaet to selectedDate
in CalendarTreatmentFlowState and update every reference to it across the
codebase (e.g., NoTreatmentViewModel, TreatmentViewModel and any other
consumers) to use CalendarTreatmentFlowState.selectedDate; ensure you update
both declaration and all usages (getters, setters, bindings, initializers) and
run the build to catch any remaining references.

Copy link
Contributor

Choose a reason for hiding this comment

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

확인해주세영

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ struct NoTreatmentView: View {
switch viewModel.state {
case .treatmentSelectedCategory:
TreatmentSelectedCategory(viewModel: viewModel)
.padding(.horizontal, 34.adjustedW)
.id(String(describing: viewModel.state))

case .targetDdaySetting:
Expand All @@ -72,7 +71,6 @@ struct NoTreatmentView: View {
month: $viewModel.month,
day: $viewModel.day
)
.padding(.horizontal, 34.adjustedW)
.id(String(describing: viewModel.state))

case .treatmentFilter:
Expand Down Expand Up @@ -113,7 +111,15 @@ struct NoTreatmentView: View {
leadingIcon: nil,
trailingIcon: nil
) {
viewModel.next()
if viewModel.state == .downTimeSetting {
Task {
try await viewModel.createUserProcedure()
tabBarCoordinator.isTabbarHidden = false
calendarCoordinator.popToRoot()
}
} else {
viewModel.next()
}
Comment on lines +117 to +130
Copy link
Member

Choose a reason for hiding this comment

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

do {
try await ~
} catch {
CherrishLogger.error(error)
} 이렇게 써주면 조을것 같아요

Comment on lines +117 to +130
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

API 실패 시에도 화면이 전환됩니다.

do/catch 블록이 추가되었지만, tabBarCoordinator.isTabbarHidden = falsecalendarCoordinator.popToRoot()do 블록 외부에 있어 API 호출 실패 시에도 화면이 전환됩니다. 사용자에게 에러 피드백 없이 화면이 닫히면 혼란을 줄 수 있습니다.

🔧 수정 제안
 if viewModel.state == .downTimeSetting {
     Task {
         do {
             try await viewModel.createUserProcedure()
+            tabBarCoordinator.isTabbarHidden = false
+            calendarCoordinator.popToRoot()
         } catch {
             CherrishLogger.error(error)
+            // TODO: 사용자에게 에러 표시 (예: Alert, Toast 등)
         }
-      
-        tabBarCoordinator.isTabbarHidden = false
-        calendarCoordinator.popToRoot()
     }
 } else {
     viewModel.next()
 }
🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/View/NoTreatment/NoTreatmentView.swift`
around lines 117 - 130, The navigation lines run regardless of API success; wrap
tabBarCoordinator.isTabbarHidden = false and calendarCoordinator.popToRoot() so
they only execute on successful createUserProcedure(): inside the Task's do
block, after await viewModel.createUserProcedure(), perform the two navigation
calls; in the catch block log the error (CherrishLogger.error(error)) and
present or propagate an error UI/state instead of allowing the function to
continue to navigation; ensure viewModel.next() remains in the else branch for
non-.downTimeSetting flows.

}
.padding(.horizontal, 25.adjustedW)
}
Expand Down Expand Up @@ -160,7 +166,7 @@ private struct TreatmentSelectedCategory: View {

Spacer()
}

.padding(.horizontal, 34.adjustedW)
Spacer()
.frame(height: 40.adjustedH)
ScrollView(.vertical, showsIndicators:false) {
Expand All @@ -182,7 +188,7 @@ private struct TreatmentSelectedCategory: View {
)
)
}
}
} .padding(.horizontal, 34.adjustedW)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,15 @@ struct TreatmentView: View {
leadingIcon: nil,
trailingIcon: nil
) {
viewModel.next()
if viewModel.state == .downTimeSetting {
Task {
try await viewModel.createUserProcedure()
tabBarCoordinator.isTabbarHidden = false
calendarCoordinator.popToRoot()
}
} else {
viewModel.next()
}
Comment on lines +113 to +126
Copy link
Member

Choose a reason for hiding this comment

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

여기도~

Comment on lines +113 to +126
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

API 호출 성공 시에만 화면 전환이 실행되어야 합니다.

do-catch 블록이 추가되었지만, tabBarCoordinator.isTabbarHidden = falsecalendarCoordinator.popToRoot()do 블록 외부에 있어서 API 호출 실패 시에도 화면 전환이 실행됩니다.

🐛 수정 제안
 if viewModel.state == .downTimeSetting {
     Task {
         do {
             try await viewModel.createUserProcedure()
+            tabBarCoordinator.isTabbarHidden = false
+            calendarCoordinator.popToRoot()
         } catch {
             CherrishLogger.error(error)
+            // TODO: 사용자에게 에러 상태 표시
         }
-        
-        tabBarCoordinator.isTabbarHidden = false
-        calendarCoordinator.popToRoot()
     }
 } else {
     viewModel.next()
 }
🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/View/Treatment/TreatmentView.swift`
around lines 113 - 126, The screen transition is executed even when the API call
fails because tabBarCoordinator.isTabbarHidden = false and
calendarCoordinator.popToRoot() are outside the do block; update the Task in
TreatmentView so that those two calls are moved inside the do block immediately
after successful await viewModel.createUserProcedure(), and keep the catch block
to call CherrishLogger.error(error) without performing the transitions; ensure
the else branch still calls viewModel.next() as before.

}
.padding(.horizontal, 25.adjustedW)
}
Expand Down
Loading