diff --git a/Projects/App/Sources/Domain/Place/PlaceUseCase.swift b/Projects/App/Sources/Domain/Place/PlaceList/PlaceUseCase.swift similarity index 100% rename from Projects/App/Sources/Domain/Place/PlaceUseCase.swift rename to Projects/App/Sources/Domain/Place/PlaceList/PlaceUseCase.swift diff --git a/Projects/App/Sources/Domain/Review/ReviewRegisterUseCase.swift b/Projects/App/Sources/Domain/Review/ReviewRegisterUseCase.swift index 7646ed2b..dcfcbba2 100644 --- a/Projects/App/Sources/Domain/Review/ReviewRegisterUseCase.swift +++ b/Projects/App/Sources/Domain/Review/ReviewRegisterUseCase.swift @@ -51,9 +51,10 @@ extension ReviewRegisterUseCase { menuName: String? = nil, image: String? = nil, grade: Evaluation) -> AnyPublisher { - // TODO: userDefaults 에 유저 아이디 꼭!! 저장해야함 -// UserInfoManager.userInfo?.userID = 11 - let user = UserInfoManager.userInfo?.userID ?? 11 + + guard let user = UserInfoManager.userInfo?.userID else { + return Fail(error: NetworkError.unauthorized("유저 아이디를 알 수 없습니다")).eraseToAnyPublisher() + } let reviewDTO = RegisterReviewDTO(placeId: placeId, menuName: menuName, image: image, diff --git a/Projects/App/Sources/UI/Place/PlaceList/ViewModel/PlaceListViewModel.swift b/Projects/App/Sources/UI/Place/PlaceList/ViewModel/PlaceListViewModel.swift index f882a26f..f6b69918 100644 --- a/Projects/App/Sources/UI/Place/PlaceList/ViewModel/PlaceListViewModel.swift +++ b/Projects/App/Sources/UI/Place/PlaceList/ViewModel/PlaceListViewModel.swift @@ -68,10 +68,17 @@ extension PlaceListViewModel: ErrorMapper { } func initialFetch() { - placeType = .hot - prefetch(at: [1], willUpdate: false) - placeType = .whole - prefetch(at: [1]) + if placeType == .whole { + placeType = .hot + prefetch(at: [1], willUpdate: false) + placeType = .whole + prefetch(at: [1]) + } else if placeType == .hot { + placeType = .whole + prefetch(at: [1], willUpdate: false) + placeType = .hot + prefetch(at: [1]) + } } func prefetch(at rows: [Int], willUpdate: Bool = true) { diff --git a/Projects/App/Sources/UI/Review/View/ReviewRegisterViewController.swift b/Projects/App/Sources/UI/Review/View/ReviewRegisterViewController.swift index 59e00d00..92958fb0 100644 --- a/Projects/App/Sources/UI/Review/View/ReviewRegisterViewController.swift +++ b/Projects/App/Sources/UI/Review/View/ReviewRegisterViewController.swift @@ -113,6 +113,19 @@ extension ReviewRegisterViewController: UIImagePickerControllerDelegate, UINavig } .store(in: &cancelBag) + viewModel.isRegisterFail + .receive(on: DispatchQueue.main) + .sink { [weak self] errorMessage in + print(errorMessage) + let alert = UIAlertController(title: "리뷰 등록 실패", + message: errorMessage, + preferredStyle: .alert) + let okAction = UIAlertAction(title: "확인", style: .default) + alert.addAction(okAction) + self?.present(alert, animated: false) + } + .store(in: &cancelBag) + viewModel.$isRegisterPossible .receive(on: DispatchQueue.main) .sink { [weak self] isUploaded in diff --git a/Projects/App/Sources/UI/Review/View/Views/ReviewCardView.swift b/Projects/App/Sources/UI/Review/View/Views/ReviewCardView.swift index 5f88e7d9..96d7c570 100644 --- a/Projects/App/Sources/UI/Review/View/Views/ReviewCardView.swift +++ b/Projects/App/Sources/UI/Review/View/Views/ReviewCardView.swift @@ -69,7 +69,7 @@ extension ReviewCardView { .receive(on: DispatchQueue.main) .sink { [weak self] image in guard let self = self else { return } - let imageExist = !image.isEmpty + let imageExist = image != nil self.reconfigureUI(for: imageExist) self.remakeLayout(with: imageExist) } diff --git a/Projects/App/Sources/UI/Review/ViewModel/ReviewRegisterViewModel.swift b/Projects/App/Sources/UI/Review/ViewModel/ReviewRegisterViewModel.swift index 5639d57e..50e64ea7 100644 --- a/Projects/App/Sources/UI/Review/ViewModel/ReviewRegisterViewModel.swift +++ b/Projects/App/Sources/UI/Review/ViewModel/ReviewRegisterViewModel.swift @@ -23,7 +23,7 @@ final class ReviewRegisterViewModel { let placeName: String var evaluation: Evaluation = .soso var menu: String? - @Published var imageString = "" + @Published var imageString: String? @Published var isRegisterPossible = true // Output @@ -101,6 +101,7 @@ extension ReviewRegisterViewModel: ErrorMapper { guard let self = self else { return } // TODO: ReviewDTO image 배열 -> String으로 바뀌면 수정 예정 + // 나중에 유저가 여러 이미지를 한번에 등록할 수 있게 되나요? 이러면 투두 삭제 예정 var imageURL: URL? if !review.image.isEmpty { imageURL = URL(string: review.image[0] ?? "")