From 5812819e2aab7b49eeb63ed1b6aa4f380a9548e9 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Mon, 27 Feb 2023 23:04:02 +0900 Subject: [PATCH 01/28] =?UTF-8?q?feat=20::=20=EC=9E=94=EB=A5=98=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EA=B3=B5=EC=A7=80=20=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?api=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RemainApplyView.swift | 3 +++ .../Sources/RemainApplyViewModel.swift | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift index 14c27428..d2aaa9f4 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift @@ -63,5 +63,8 @@ struct RemainApplyView: View { message: viewModel.toastMessage, style: .error ) + .onAppear { + viewModel.fetchRemainsAvailableTime() + } } } diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index ae6297e8..7f6a55d7 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -16,12 +16,16 @@ final class RemainApplyViewModel: BaseViewModel { @Published var isShowingToast = false @Published var toastMessage = "잔류 신청 시간이 아닙니다." - var startTime = "화 18:00" - var endTime = "목 18:00" + @Published var remainsAvailableTime: RemainsAvailableTimeEntity? + var rangeString: String { - let text = "잔류 신청 시간은 " + startTime + - " ~ " + endTime + " 까지 입니다." - return text + if let time = remainsAvailableTime { + let text = "잔류 신청 시간은 " + time.startDayOfWeek.rawValue + " " + time.startAt.toSmallDMSTimeString() + + " ~ " + time.endDayOfWeek.rawValue + time.endAt.toSmallDMSTimeString() + " 까지 입니다." + return text + } else { + return "null" + } } private let fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase @@ -41,6 +45,11 @@ final class RemainApplyViewModel: BaseViewModel { self.remainingApplicationsChangesUseCase = remainingApplicationsChangesUseCase } - func onAppear() { + func fetchRemainsAvailableTime() { + addCancellable( + fetchRemainsAvailableTimeUseCase.execute() + ) { [weak self] remainsAvailableTime in + self?.remainsAvailableTime = remainsAvailableTime + } } } From 9dc2f4513f58216d9c02be6ae93ac81437cec78d Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Mon, 27 Feb 2023 23:44:04 +0900 Subject: [PATCH 02/28] =?UTF-8?q?fix=20::=20=EC=97=90=EB=9F=AC=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Modules/ErrorModule/Sources/DmsError.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Modules/ErrorModule/Sources/DmsError.swift b/Projects/Modules/ErrorModule/Sources/DmsError.swift index faf71f41..e1f2a9d2 100644 --- a/Projects/Modules/ErrorModule/Sources/DmsError.swift +++ b/Projects/Modules/ErrorModule/Sources/DmsError.swift @@ -140,7 +140,7 @@ extension DmsError: LocalizedError { return "신청 불가능한 시간대입니다" case .unavailableSex: - return "신청 불가능한 성별입니다" + return "신청할 수 없는 학년 혹은 성별입니다" // MARK: - Remains case .forbiddenRemainPeriod: From 2b9b1484d1b380cf3cd00f2315c8f5c3427fc750 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Mon, 27 Feb 2023 23:44:40 +0900 Subject: [PATCH 03/28] =?UTF-8?q?feat=20::=20WeekType=20=ED=95=9C=EA=B5=AD?= =?UTF-8?q?=EC=96=B4=EB=A1=9C=20=EB=B0=94=EA=BE=B8=EB=8A=94=20=ED=95=A8?= =?UTF-8?q?=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Enum/WeekType.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Projects/Services/DataMappingModule/Sources/Enum/WeekType.swift b/Projects/Services/DataMappingModule/Sources/Enum/WeekType.swift index b28a3bad..7584208d 100644 --- a/Projects/Services/DataMappingModule/Sources/Enum/WeekType.swift +++ b/Projects/Services/DataMappingModule/Sources/Enum/WeekType.swift @@ -8,4 +8,23 @@ public enum WeekType: String, Decodable { case friday = "FRIDAY" case satuday = "SATURDAY" case sunday = "SUNDAY" + + public func displayString() -> String { + switch self { + case .monday: + return "월" + case .tuesday: + return "화" + case .wednesday: + return "수" + case .thursday: + return "목" + case .friday: + return "금" + case .satuday: + return "토" + case .sunday: + return "일" + } + } } From b434f0744dd14bdb933fe0dae3e46babfa02882f Mon Sep 17 00:00:00 2001 From: baegteun Date: Mon, 27 Feb 2023 23:45:25 +0900 Subject: [PATCH 04/28] =?UTF-8?q?feat=20::=20Date=20=ED=8F=AC=EB=A7=A4?= =?UTF-8?q?=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RemainApplyFeature/Sources/RemainApplyViewModel.swift | 7 ++++--- .../Response/FetchRemainsAvailableTimeResponseDTO.swift | 4 ++-- .../Sources/Entities/RemainsAvailableTimeEntity.swift | 8 ++++---- .../FetchRemainsAvailableTimeDataTransfer.swift | 5 +++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 7f6a55d7..52557303 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -20,11 +20,12 @@ final class RemainApplyViewModel: BaseViewModel { var rangeString: String { if let time = remainsAvailableTime { - let text = "잔류 신청 시간은 " + time.startDayOfWeek.rawValue + " " + time.startAt.toSmallDMSTimeString() + - " ~ " + time.endDayOfWeek.rawValue + time.endAt.toSmallDMSTimeString() + " 까지 입니다." + let startString = "\(time.startDayOfWeek.rawValue) \(time.startAt.toSmallDMSTimeString())" + let endString = "\(time.endDayOfWeek.rawValue) \(time.endAt.toSmallDMSTimeString())" + let text = "잔류 신청 시간은 \(startString) ~ \(endString) 까지 입니다." return text } else { - return "null" + return "" } } diff --git a/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift b/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift index aaa91494..fa646009 100644 --- a/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift +++ b/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift @@ -20,8 +20,8 @@ public struct FetchRemainsAvailableTimeResponseDTO: Decodable { enum CodingKeys: String, CodingKey { case startDayOfWeek = "start_day_of_week" - case startAt = "start_at" + case startAt = "start_time" case endDayOfWeek = "end_day_of_week" - case endAt = "end_at" + case endAt = "end_time" } } diff --git a/Projects/Services/DomainModule/Sources/Entities/RemainsAvailableTimeEntity.swift b/Projects/Services/DomainModule/Sources/Entities/RemainsAvailableTimeEntity.swift index b7a05197..f154aad9 100644 --- a/Projects/Services/DomainModule/Sources/Entities/RemainsAvailableTimeEntity.swift +++ b/Projects/Services/DomainModule/Sources/Entities/RemainsAvailableTimeEntity.swift @@ -4,9 +4,9 @@ import DataMappingModule public struct RemainsAvailableTimeEntity: Equatable, Hashable { public init( startDayOfWeek: WeekType, - startAt: String, + startAt: Date, endDayOfWeek: WeekType, - endAt: String + endAt: Date ) { self.startDayOfWeek = startDayOfWeek self.startAt = startAt @@ -15,7 +15,7 @@ public struct RemainsAvailableTimeEntity: Equatable, Hashable { } public let startDayOfWeek: WeekType - public let startAt: String + public let startAt: Date public let endDayOfWeek: WeekType - public let endAt: String + public let endAt: Date } diff --git a/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchRemainsAvailableTimeDataTransfer.swift b/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchRemainsAvailableTimeDataTransfer.swift index 6edfc8c8..f792e8e6 100644 --- a/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchRemainsAvailableTimeDataTransfer.swift +++ b/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchRemainsAvailableTimeDataTransfer.swift @@ -1,13 +1,14 @@ import DataMappingModule import DomainModule +import Utility public extension FetchRemainsAvailableTimeResponseDTO { func toDomain() -> RemainsAvailableTimeEntity { RemainsAvailableTimeEntity( startDayOfWeek: startDayOfWeek, - startAt: startAt, + startAt: startAt.toDMSTime(), endDayOfWeek: endDayOfWeek, - endAt: endAt + endAt: endAt.toDMSTime() ) } } From 87c0680ec1bf8d7d88992e2a4a7e8744282cc9bc Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Mon, 27 Feb 2023 23:48:13 +0900 Subject: [PATCH 05/28] fix :: conflicts --- .../FetchRemainsAvailableTimeResponseDTO.swift | 16 ++++++++-------- .../Entities/RemainsAvailableTimeEntity.swift | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift b/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift index fa646009..8e4c459e 100644 --- a/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift +++ b/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift @@ -3,25 +3,25 @@ import Foundation public struct FetchRemainsAvailableTimeResponseDTO: Decodable { public init( startDayOfWeek: WeekType, - startAt: String, + startTime: Date, endDayOfWeek: WeekType, - endAt: String + endTime: Date ) { self.startDayOfWeek = startDayOfWeek - self.startAt = startAt + self.startTime = startTime self.endDayOfWeek = endDayOfWeek - self.endAt = endAt + self.endTime = endTime } public let startDayOfWeek: WeekType - public let startAt: String + public let startTime: Date public let endDayOfWeek: WeekType - public let endAt: String + public let endTime: Date enum CodingKeys: String, CodingKey { case startDayOfWeek = "start_day_of_week" - case startAt = "start_time" + case startTime = "start_time" case endDayOfWeek = "end_day_of_week" - case endAt = "end_time" + case endTime = "end_time" } } diff --git a/Projects/Services/DomainModule/Sources/Entities/RemainsAvailableTimeEntity.swift b/Projects/Services/DomainModule/Sources/Entities/RemainsAvailableTimeEntity.swift index f154aad9..a6701fa4 100644 --- a/Projects/Services/DomainModule/Sources/Entities/RemainsAvailableTimeEntity.swift +++ b/Projects/Services/DomainModule/Sources/Entities/RemainsAvailableTimeEntity.swift @@ -4,18 +4,18 @@ import DataMappingModule public struct RemainsAvailableTimeEntity: Equatable, Hashable { public init( startDayOfWeek: WeekType, - startAt: Date, + startTime: Date, endDayOfWeek: WeekType, - endAt: Date + endTime: Date ) { self.startDayOfWeek = startDayOfWeek - self.startAt = startAt + self.startTime = startTime self.endDayOfWeek = endDayOfWeek - self.endAt = endAt + self.endTime = endTime } public let startDayOfWeek: WeekType - public let startAt: Date + public let startTime: Date public let endDayOfWeek: WeekType - public let endAt: Date + public let endTime: Date } From 103e9338a19ce223b7003ccd87f944f189898b76 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Mon, 27 Feb 2023 23:55:19 +0900 Subject: [PATCH 06/28] =?UTF-8?q?feat=20::=20=EC=9E=94=EB=A5=98=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EA=B3=B5=EC=A7=80=20api=20=EC=97=B0?= =?UTF-8?q?=EB=8F=99=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RemainApplyFeature/Sources/RemainApplyViewModel.swift | 4 ++-- .../Response/FetchRemainsAvailableTimeResponseDTO.swift | 8 ++++---- .../FetchRemainsAvailableTimeDataTransfer.swift | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 52557303..ca7f54f1 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -20,8 +20,8 @@ final class RemainApplyViewModel: BaseViewModel { var rangeString: String { if let time = remainsAvailableTime { - let startString = "\(time.startDayOfWeek.rawValue) \(time.startAt.toSmallDMSTimeString())" - let endString = "\(time.endDayOfWeek.rawValue) \(time.endAt.toSmallDMSTimeString())" + let startString = "\(time.startDayOfWeek.displayString()) \(time.startTime.toSmallDMSTimeString())" + let endString = "\(time.endDayOfWeek.displayString()) \(time.endTime.toSmallDMSTimeString())" let text = "잔류 신청 시간은 \(startString) ~ \(endString) 까지 입니다." return text } else { diff --git a/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift b/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift index 8e4c459e..0b5e4ae9 100644 --- a/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift +++ b/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchRemainsAvailableTimeResponseDTO.swift @@ -3,9 +3,9 @@ import Foundation public struct FetchRemainsAvailableTimeResponseDTO: Decodable { public init( startDayOfWeek: WeekType, - startTime: Date, + startTime: String, endDayOfWeek: WeekType, - endTime: Date + endTime: String ) { self.startDayOfWeek = startDayOfWeek self.startTime = startTime @@ -14,9 +14,9 @@ public struct FetchRemainsAvailableTimeResponseDTO: Decodable { } public let startDayOfWeek: WeekType - public let startTime: Date + public let startTime: String public let endDayOfWeek: WeekType - public let endTime: Date + public let endTime: String enum CodingKeys: String, CodingKey { case startDayOfWeek = "start_day_of_week" diff --git a/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchRemainsAvailableTimeDataTransfer.swift b/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchRemainsAvailableTimeDataTransfer.swift index f792e8e6..3cebec25 100644 --- a/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchRemainsAvailableTimeDataTransfer.swift +++ b/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchRemainsAvailableTimeDataTransfer.swift @@ -6,9 +6,9 @@ public extension FetchRemainsAvailableTimeResponseDTO { func toDomain() -> RemainsAvailableTimeEntity { RemainsAvailableTimeEntity( startDayOfWeek: startDayOfWeek, - startAt: startAt.toDMSTime(), + startTime: startTime.toDMSTime(), endDayOfWeek: endDayOfWeek, - endAt: endAt.toDMSTime() + endTime: endTime.toDMSTime() ) } } From 6d3310dc7a6aa7c18684465af6a3381c425d90c2 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 02:03:21 +0900 Subject: [PATCH 07/28] =?UTF-8?q?feat=20::=20Select=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EB=B0=8F=20list=20api=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/RemainApplyListCellView.swift | 103 +++++------------- .../Sources/RemainApplyViewModel.swift | 14 ++- 2 files changed, 42 insertions(+), 75 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift index 2f510032..224f923f 100644 --- a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift @@ -5,74 +5,38 @@ import SwiftUI struct RemainApplyListCellView: View { @StateObject var viewModel: RemainApplyViewModel - let dummy1 = RemainOptionEntity( - id: "0", - title: "금요 귀가", - description: """ - 금요일 일과가 모두 끝나고 - 8시 30분 이후부터9시 30분까지 귀가하고 - 일요일 6시 30분 부터 9시 30분까지 귀사해야 합니다. - - 혹시나 개인 일정으로 부득이하기 금요일이 아닌, 토요일 - 또는 일요일에 귀가해야 하는 학생들은 사감 선생님께 - 말씀부탁드립니다. - """ - ) - let dummy2 = RemainOptionEntity( - id: "1", - title: "토요 귀가", - description: """ - 금요일 일과가 모두 끝나고 - 8시 30분 이후부터9시 30분까지 귀가하고 - 일요일 6시 30분 부터 9시 30분까지 귀사해야 합니다. - - 혹시나 개인 일정으로 부득이하기 금요일이 아닌, 토요일 - 또는 일요일에 귀가해야 하는 학생들은 사감 선생님께 - 말씀부탁드립니다. - """ - ) - let dummy3 = RemainOptionEntity( - id: "2", - title: "잔류", - description: """ - 금요일 일과가 모두 끝나고 - 8시 30분 이후부터9시 30분까지 귀가하고 - 일요일 6시 30분 부터 9시 30분까지 귀사해야 합니다. - - 혹시나 개인 일정으로 부득이하기 금요일이 아닌, 토요일 - 또는 일요일에 귀가해야 하는 학생들은 사감 선생님께 - 말씀부탁드립니다. - """ - ) - var body: some View { VStack(spacing: 12) { - remainApplyListCellView(list: dummy1, applyType: .friday) - - remainApplyListCellView(list: dummy2, applyType: .saturday) - - remainApplyListCellView(list: dummy3, applyType: .stay) + ForEach(viewModel.remainApplicationList.remainOptions, id: \.self) { remainApplication in + remainApplyListCellView(list: remainApplication) + } + } + .onAppear { + viewModel.fetchRemainApplicationList() } } @ViewBuilder - // swiftlint:disable function_body_length - func remainApplyListCellView(list: RemainOptionEntity, applyType: ApplyType) -> some View { - VStack { + func remainApplyListCellView(list: RemainOptionEntity) -> some View { + var isSelected: Bool = { + list == viewModel.selectedEntity + }() + VStack(alignment: .leading) { HStack(alignment: .center) { Button(action: { - viewModel.selectedType = list.title - viewModel.selectedNum = Int(list.id) ?? 10 + if !isSelected { + viewModel.selectedEntity = list + } }, label: { HStack { Text(list.title) - .dmsFont(.title(.title2), color: viewModel.selectedNum == applyType.rawValue + .dmsFont(.title(.title2), color: isSelected ? .System.primary : .GrayScale.gray7) .frame(height: 32) .padding(.vertical, 14) .padding(.horizontal, 20) - if viewModel.isAlreadyApplied == true && viewModel.appliedNum == applyType.rawValue { + if list.isApplied { Text("신청 완료") .dmsFont(.etc(.button), color: .PrimaryVariant.primary) .frame(height: 22) @@ -85,41 +49,34 @@ struct RemainApplyListCellView: View { Spacer() - Image(systemName: viewModel.isDetailTapped == true && viewModel.selectedNum == applyType.rawValue - ? "chevron.up" : "chevron.down") - .foregroundColor(viewModel.selectedNum == applyType.rawValue + Image(systemName: isSelected ? "chevron.up" : "chevron.down") + .foregroundColor(isSelected ? .System.primary : .GrayScale.gray7) .padding(.trailing, 25) .onTapGesture { - viewModel.selectedNum = applyType.rawValue - viewModel.selectedType = list.title - viewModel.isDetailTapped.toggle() +// viewModel.selectedNum = applyType.rawValue +// viewModel.selectedType = list.title +// viewModel.isDetailTapped.toggle() } }) } - if viewModel.isDetailTapped == true && viewModel.selectedNum == applyType.rawValue { - Text(list.description) - .multilineTextAlignment(.leading) - .dmsFont(.body(.body3), color: .GrayScale.gray9) - .padding([.horizontal, .bottom], 20) - } +// if viewModel.isDetailTapped == true && viewModel.selectedNum == applyType.rawValue { +// Text(list.description) +// .multilineTextAlignment(.leading) +// .dmsFont(.body(.body3), color: .GrayScale.gray9) +// .padding([.horizontal, .bottom], 20) +// } } .background(Color.System.surface) .cornerRadius(10) .overlay( RoundedRectangle(cornerRadius: 10) .inset(by: 1) - .stroke(viewModel.selectedNum == applyType.rawValue ? - Color.System.primary : .clear, lineWidth: 1.5) + .stroke(isSelected ? + Color.System.primary : .clear, + lineWidth: 1.5) ) .padding(.bottom, 12) .dmsShadow(style: .surface) } - // swiftlint:enable function_body_length -} - -enum ApplyType: Int { - case friday = 0 - case saturday - case stay } diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index ca7f54f1..76a66fe2 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -10,13 +10,15 @@ final class RemainApplyViewModel: BaseViewModel { @AppStorage("isApplied") var isAlreadyApplied: Bool = false @Published var appliedState: String = "" @AppStorage("appliedNum") var appliedNum: Int = 10 - @Published var isDetailTapped: Bool = false @Published var isApplicationTime = true @Published var isShowingToast = false - @Published var toastMessage = "잔류 신청 시간이 아닙니다." + @Published var toastMessage = "" @Published var remainsAvailableTime: RemainsAvailableTimeEntity? + @Published var remainApplicationList = RemainApplicationListEntity(remainOptions: []) + @Published var selectedRemainOptionEntity: SelectedRemainOptionEntity? + @Published var selectedEntity: RemainOptionEntity? var rangeString: String { if let time = remainsAvailableTime { @@ -53,4 +55,12 @@ final class RemainApplyViewModel: BaseViewModel { self?.remainsAvailableTime = remainsAvailableTime } } + + func fetchRemainApplicationList() { + addCancellable( + fetchRemainApplicationListUseCase.execute() + ) { [weak self] remainApplicationList in + self?.remainApplicationList = remainApplicationList + } + } } From d14bee4811c78732015408ed38a1a83414132dcc Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 02:04:04 +0900 Subject: [PATCH 08/28] =?UTF-8?q?fix=20::=20=EB=AA=85=EC=84=B8=EC=84=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FetchListRemainApplicationItemsResponseDTO.swift | 4 ---- .../Remains/Response/RemainOptionResponseDTO.swift | 12 +++++++++++- .../Entities/RemainApplicationListEntity.swift | 3 --- .../Sources/Entities/RemainOptionEntity.swift | 5 ++++- .../FetchListRemainAppItemsDataTransfer.swift | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchListRemainApplicationItemsResponseDTO.swift b/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchListRemainApplicationItemsResponseDTO.swift index 0c5833dd..528c37bd 100644 --- a/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchListRemainApplicationItemsResponseDTO.swift +++ b/Projects/Services/DataMappingModule/Sources/Remains/Response/FetchListRemainApplicationItemsResponseDTO.swift @@ -2,18 +2,14 @@ import Foundation public struct FetchRemainAppListResponseDTO: Decodable { public init( - selectedOption: String, remainOptions: [RemainOptionResponseDTO] ) { - self.selectedOption = selectedOption self.remainOptions = remainOptions } - public let selectedOption: String public let remainOptions: [RemainOptionResponseDTO] enum CodingKeys: String, CodingKey { - case selectedOption = "selected_option" case remainOptions = "remain_options" } } diff --git a/Projects/Services/DataMappingModule/Sources/Remains/Response/RemainOptionResponseDTO.swift b/Projects/Services/DataMappingModule/Sources/Remains/Response/RemainOptionResponseDTO.swift index e36f4692..2082ab6a 100644 --- a/Projects/Services/DataMappingModule/Sources/Remains/Response/RemainOptionResponseDTO.swift +++ b/Projects/Services/DataMappingModule/Sources/Remains/Response/RemainOptionResponseDTO.swift @@ -4,14 +4,24 @@ public struct RemainOptionResponseDTO: Decodable { public init( id: String, title: String, - description: String + description: String, + isApplied: Bool ) { self.id = id self.title = title self.description = description + self.isApplied = isApplied } public let id: String public let title: String public let description: String + public let isApplied: Bool + + enum CodingKeys: String, CodingKey { + case id + case title + case description + case isApplied = "is_applied" + } } diff --git a/Projects/Services/DomainModule/Sources/Entities/RemainApplicationListEntity.swift b/Projects/Services/DomainModule/Sources/Entities/RemainApplicationListEntity.swift index 49e9ea89..b32f55bf 100644 --- a/Projects/Services/DomainModule/Sources/Entities/RemainApplicationListEntity.swift +++ b/Projects/Services/DomainModule/Sources/Entities/RemainApplicationListEntity.swift @@ -2,13 +2,10 @@ import Foundation public struct RemainApplicationListEntity: Equatable, Hashable { public init( - selectedOption: String, remainOptions: [RemainOptionEntity] ) { - self.selectedOption = selectedOption self.remainOptions = remainOptions } - public let selectedOption: String public let remainOptions: [RemainOptionEntity] } diff --git a/Projects/Services/DomainModule/Sources/Entities/RemainOptionEntity.swift b/Projects/Services/DomainModule/Sources/Entities/RemainOptionEntity.swift index 0bda16ec..dc38756c 100644 --- a/Projects/Services/DomainModule/Sources/Entities/RemainOptionEntity.swift +++ b/Projects/Services/DomainModule/Sources/Entities/RemainOptionEntity.swift @@ -4,14 +4,17 @@ public struct RemainOptionEntity: Equatable, Hashable { public init( id: String, title: String, - description: String + description: String, + isApplied: Bool ) { self.id = id self.title = title self.description = description + self.isApplied = isApplied } public let id: String public let title: String public let description: String + public let isApplied: Bool } diff --git a/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchListRemainAppItemsDataTransfer.swift b/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchListRemainAppItemsDataTransfer.swift index 8eb69c30..63b4a1ba 100644 --- a/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchListRemainAppItemsDataTransfer.swift +++ b/Projects/Services/NetworkModule/Sources/Remains/Remote/Impl/DataTransfer/FetchListRemainAppItemsDataTransfer.swift @@ -4,7 +4,6 @@ import DomainModule public extension FetchRemainAppListResponseDTO { func toDomain() -> RemainApplicationListEntity { RemainApplicationListEntity( - selectedOption: selectedOption, remainOptions: remainOptions.map { $0.toDomain() } ) } @@ -15,7 +14,8 @@ public extension RemainOptionResponseDTO { RemainOptionEntity( id: id, title: title, - description: description + description: description, + isApplied: isApplied ) } } From 9487ac5ad88d18c79bf2efd1469654e40bcd53a0 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 02:15:02 +0900 Subject: [PATCH 09/28] =?UTF-8?q?feat=20::=20=ED=81=B4=EB=A6=AD=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/RemainApplyListCellView.swift | 9 ++++++--- .../Sources/RemainApplyViewModel.swift | 3 ++- .../Entities/SelectedRemainOptionEntity.swift | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 Projects/Services/DomainModule/Sources/Entities/SelectedRemainOptionEntity.swift diff --git a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift index 224f923f..30bc2102 100644 --- a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift @@ -18,15 +18,18 @@ struct RemainApplyListCellView: View { @ViewBuilder func remainApplyListCellView(list: RemainOptionEntity) -> some View { - var isSelected: Bool = { - list == viewModel.selectedEntity + let isSelected: Bool = { + list == viewModel.selectedRemainOptionEntity?.selectedEntity }() VStack(alignment: .leading) { HStack(alignment: .center) { Button(action: { if !isSelected { - viewModel.selectedEntity = list + viewModel.selectedRemainOptionEntity?.selectedEntity = list + print("삽입") } + print(isSelected) + print(list, viewModel.selectedRemainOptionEntity?.selectedEntity) }, label: { HStack { Text(list.title) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 76a66fe2..80fdb88b 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -18,7 +18,8 @@ final class RemainApplyViewModel: BaseViewModel { @Published var remainsAvailableTime: RemainsAvailableTimeEntity? @Published var remainApplicationList = RemainApplicationListEntity(remainOptions: []) @Published var selectedRemainOptionEntity: SelectedRemainOptionEntity? - @Published var selectedEntity: RemainOptionEntity? + // 이부분에 옵셔널 처리가 아닌 값처리를 해주면 값이 잘 바껴요 +// @Published var selectedEntity: RemainOptionEntity? var rangeString: String { if let time = remainsAvailableTime { diff --git a/Projects/Services/DomainModule/Sources/Entities/SelectedRemainOptionEntity.swift b/Projects/Services/DomainModule/Sources/Entities/SelectedRemainOptionEntity.swift new file mode 100644 index 00000000..fc2651ea --- /dev/null +++ b/Projects/Services/DomainModule/Sources/Entities/SelectedRemainOptionEntity.swift @@ -0,0 +1,14 @@ +import Foundation + +public struct SelectedRemainOptionEntity: Equatable, Hashable { + public init( + selectedEntity: RemainOptionEntity, + isShowingDetail: Bool + ) { + self.selectedEntity = selectedEntity + self.isShowingDetail = isShowingDetail + } + + public var selectedEntity: RemainOptionEntity + public var isShowingDetail: Bool +} From 488c36ff841e5ab97e430507bd093709df2bb2e9 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 12:54:45 +0900 Subject: [PATCH 10/28] =?UTF-8?q?feat=20::=20=EC=9E=94=EB=A5=98=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20api=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DI/Remains/AppComponent+Remains.swift | 8 +-- .../StudyRooms/AppComponent+StudyRooms.swift | 4 ++ .../ApplyPage/ApplyPageComponent.swift | 8 ++- .../Sources/ApplyPage/ApplyPageView.swift | 31 +++----- .../ApplyPage/ApplyPageViewModel.swift | 49 +++++++++++++ .../Component/ApplyListCellView.swift | 22 +++--- .../Component/RemainApplyListCellView.swift | 70 ++++++++++--------- .../Component/RemainApplyListView.swift | 26 +++++++ .../Sources/RemainApplyView.swift | 40 +++++------ .../Sources/RemainApplyViewModel.swift | 27 ++++--- .../StudyRoomDetail/StudyRoomDetailView.swift | 1 - .../StudyRoomDetailViewModel.swift | 7 -- .../APIKit/Sources/StudyRoomsAPI.swift | 5 +- .../MyStudyRoomApplicationItemsDTO.swift | 10 +++ ...MyRemainApplicationItemsUseCaseImpl.swift} | 2 +- ...ft => FetchRemainAppListUseCaseImpl.swift} | 2 +- ...etchRemainsAvailableTimeUseCaseImpl.swift} | 2 +- ...iningApplicationsChangesUseCaseImpl.swift} | 2 +- .../Impl/StudyRoomsRepositoryImpl.swift | 4 ++ ...tudyRoomApplicationItemsUserCaseImpl.swift | 16 +++++ .../Entities/MyStudyRoomAppItemsEntity.swift | 10 +++ .../Entities/SelectedRemainOptionEntity.swift | 14 ---- .../Repository/StudyRoomsRepository.swift | 1 + .../FetchMyStudyRoomAppItemsUserCase.swift | 7 ++ ...tudyRoomApplicationItemsDataTransfer.swift | 11 +++ .../Impl/RemoteStudyRoomsDataSourceImpl.swift | 7 ++ .../Remote/RemoteStudyRoomsDataSource.swift | 1 + 27 files changed, 255 insertions(+), 132 deletions(-) create mode 100644 Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift create mode 100644 Projects/Services/DataMappingModule/Sources/StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift rename Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/{FetchMyRemainApplicationItemsUseCaselmpl.swift => FetchMyRemainApplicationItemsUseCaseImpl.swift} (87%) rename Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/{FetchRemainAppListUseCaselmpl.swift => FetchRemainAppListUseCaseImpl.swift} (86%) rename Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/{FetchRemainsAvailableTimeUseCaselmpl.swift => FetchRemainsAvailableTimeUseCaseImpl.swift} (86%) rename Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/{RemainingApplicationsChangesUseCaselmpl.swift => RemainingApplicationsChangesUseCaseImpl.swift} (87%) create mode 100644 Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomApplicationItemsUserCaseImpl.swift create mode 100644 Projects/Services/DomainModule/Sources/Entities/MyStudyRoomAppItemsEntity.swift delete mode 100644 Projects/Services/DomainModule/Sources/Entities/SelectedRemainOptionEntity.swift create mode 100644 Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUserCase.swift create mode 100644 Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/DataTransfer/FehtchMyStudyRoomApplicationItemsDataTransfer.swift diff --git a/Projects/App/Sources/Application/DI/Remains/AppComponent+Remains.swift b/Projects/App/Sources/Application/DI/Remains/AppComponent+Remains.swift index d77b72cf..f7881e34 100644 --- a/Projects/App/Sources/Application/DI/Remains/AppComponent+Remains.swift +++ b/Projects/App/Sources/Application/DI/Remains/AppComponent+Remains.swift @@ -18,25 +18,25 @@ public extension AppComponent { var remainingApplicationsChangesUseCase: any RemainingApplicationsChangesUseCase { shared { - RemainingApplicationsChangesUseCaselmpl(remainsRepository: remainsRepository) + RemainingApplicationsChangesUseCaseImpl(remainsRepository: remainsRepository) } } var fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase { shared { - FetchMyRemainApplicationItemsUseCaselmpl(remainsRepository: remainsRepository) + FetchMyRemainApplicationItemsUseCaseImpl(remainsRepository: remainsRepository) } } var fetchRemainApplicationListUseCase: any FetchRemainApplicationListUseCase { shared { - FetchRemainAppListUseCaselmpl(remainsRepository: remainsRepository) + FetchRemainAppListUseCaseImpl(remainsRepository: remainsRepository) } } var fetchRemainsAvailableTimeUseCase: any FetchRemainsAvailableTimeUseCase { shared { - FetchRemainsAvailableTimeUseCaselmpl(remainsRepository: remainsRepository) + FetchRemainsAvailableTimeUseCaseImpl(remainsRepository: remainsRepository) } } } diff --git a/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift b/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift index 8799561e..a928278c 100644 --- a/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift +++ b/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift @@ -35,4 +35,8 @@ public extension AppComponent { var cancelStudyRoomSeatUseCase: any CancelStudyRoomSeatUseCase { CancelStudyRoomSeatUseCaseImpl(studyRoomsRepository: studyRoomsRepository) } + + var fehtchMyStudyRoomApplicationItemsUserCase: any FetchMyStudyRoomAppItemsUserCase { + FehtchMyStudyRoomApplicationItemsUserCaseImpl(studyRoomsRepository: studyRoomsRepository) + } } diff --git a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageComponent.swift b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageComponent.swift index 96368444..a4fa4d29 100644 --- a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageComponent.swift +++ b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageComponent.swift @@ -2,8 +2,11 @@ import SwiftUI import StudyRoomFeature import RemainApplyFeature import NeedleFoundation +import DomainModule public protocol ApplyPageDependency: Dependency { + var fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase { get } + var fetchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase { get } var studyRoomListComponent: StudyRoomListComponent { get } var remainApplyComponent: RemainApplyComponent { get } } @@ -11,7 +14,10 @@ public protocol ApplyPageDependency: Dependency { public final class ApplyPageComponent: Component { public func makeView() -> some View { ApplyPageView( - viewModel: ApplyPageViewModel(), + viewModel: .init( + fetchMyRemainApplicationItemsUseCase: dependency.fetchMyRemainApplicationItemsUseCase, + fehtchMyStudyRoomApplicationItemsUserCase: dependency.fetchMyStudyRoomAppItemsUserCase + ), studyRoomListComponent: dependency.studyRoomListComponent, remainApplyComponent: dependency.remainApplyComponent ) diff --git a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageView.swift b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageView.swift index 81c291ef..47265920 100644 --- a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageView.swift +++ b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageView.swift @@ -3,8 +3,6 @@ import RemainApplyFeature import SwiftUI struct ApplyPageView: View { - @AppStorage("StudyRoomState") var studyRoomState: String? - @AppStorage("RemainState") var remainState: String? @StateObject var viewModel: ApplyPageViewModel @Environment(\.tabbarHidden) var tabbarHidden @@ -32,25 +30,25 @@ struct ApplyPageView: View { Spacer() .frame(height: 5) - applyListCellView( + ApplyListCellView( name: "자습실", content: """ 자습실 사용이 필요한 경우, 자습실 신청을 통해서 원하는 자리를 신청해 보세요. """, buttonTitle: "자습실 신청하기", - applyState: studyRoomState, + applyState: viewModel.studyRoomState, onTapped: { viewModel.isNavigateToStudy.toggle() } ) - applyListCellView( + ApplyListCellView( name: "잔류", content: """ 주말 기숙사 잔류 여부를 확인하고, 잔류 신청을 통해서 잔류 또는 귀가를 신청해 보세요. """, buttonTitle: "잔류 신청하기", - applyState: remainState, + applyState: viewModel.remainState, onTapped: { viewModel.isNavigateToRemain.toggle() } @@ -62,6 +60,10 @@ struct ApplyPageView: View { .navigationTitle("신청") .navigationBarTitleDisplayMode(.inline) .dmsBackground() + .onAppear { + viewModel.fehtchMyStudyRoomApplicationItems() + viewModel.fetchMyRemainApplicationItems() + } .onChange(of: viewModel.isNavigateToStudy) { newValue in withAnimation { tabbarHidden.wrappedValue = newValue @@ -83,21 +85,4 @@ struct ApplyPageView: View { .navigationViewStyle(.stack) } } - - @ViewBuilder - func applyListCellView( - name: String, - content: String, - buttonTitle: String, - applyState: String?, - onTapped: @escaping () -> Void - ) -> some View { - ApplyListCellView( - name: name, - content: content, - buttonTitle: buttonTitle, - applyState: applyState, - onTapped: onTapped - ) - } } diff --git a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageViewModel.swift b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageViewModel.swift index 5bb8fbb2..29684b64 100644 --- a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageViewModel.swift +++ b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageViewModel.swift @@ -1,7 +1,56 @@ import BaseFeature +import DomainModule +import DataMappingModule import Combine +import SwiftUI final class ApplyPageViewModel: BaseViewModel { @Published var isNavigateToStudy: Bool = false @Published var isNavigateToRemain: Bool = false + + @Published var myRemainApplicationItem: MyRemainApplicationItemsEntity? + @Published var myStudyRoomApplicationItems: MyStudyRoomAppItemsEntity? + + private let fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase + private let fehtchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase + + var remainState: String? { + if let item = myRemainApplicationItem { + return item.title + } else { + return nil + } + } + + var studyRoomState: String? { + if let item = myStudyRoomApplicationItems { + return item.floor + "층 " + item.name + } else { + return nil + } + } + + public init( + fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase, + fehtchMyStudyRoomApplicationItemsUserCase: any FetchMyStudyRoomAppItemsUserCase + ) { + self.fetchMyRemainApplicationItemsUseCase = fetchMyRemainApplicationItemsUseCase + self.fehtchMyStudyRoomAppItemsUserCase = fehtchMyStudyRoomApplicationItemsUserCase + } + + func fetchMyRemainApplicationItems() { + addCancellable( + fetchMyRemainApplicationItemsUseCase.execute() + ) { [weak self] myRemainApplicationItem in + self?.myRemainApplicationItem = myRemainApplicationItem + } + } + + func fehtchMyStudyRoomApplicationItems() { + addCancellable( + fehtchMyStudyRoomAppItemsUserCase.execute() + ) { [weak self] myStudyRoomApplicationItems in + self?.myStudyRoomApplicationItems = myStudyRoomApplicationItems + } + } } diff --git a/Projects/Features/ApplyFeature/Sources/ApplyPage/Component/ApplyListCellView.swift b/Projects/Features/ApplyFeature/Sources/ApplyPage/Component/ApplyListCellView.swift index 1ddc6420..24a96377 100644 --- a/Projects/Features/ApplyFeature/Sources/ApplyPage/Component/ApplyListCellView.swift +++ b/Projects/Features/ApplyFeature/Sources/ApplyPage/Component/ApplyListCellView.swift @@ -4,8 +4,6 @@ import RemainApplyFeature import DesignSystem struct ApplyListCellView: View { - @AppStorage("StudyRoomState") var studyRoomState: String? - @AppStorage("RemainState") var remainState: String? var name: String var content: String var buttonTitle: String @@ -37,15 +35,17 @@ struct ApplyListCellView: View { Spacer() - Text(applyState ?? "") - .dmsFont(.etc(.button), color: .PrimaryVariant.primary) - .frame(height: 22) - .padding(.vertical, 6) - .padding(.horizontal, 14) - .background(Color.PrimaryVariant.lighten2) - .cornerRadius(24) - .padding(.trailing, 16) - .padding(.top, -2) + if applyState != nil { + Text(applyState ?? "") + .dmsFont(.etc(.button), color: .PrimaryVariant.primary) + .frame(height: 22) + .padding(.vertical, 6) + .padding(.horizontal, 14) + .background(Color.PrimaryVariant.lighten2) + .cornerRadius(24) + .padding(.trailing, 16) + .padding(.top, -2) + } } Text(content) diff --git a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift index 30bc2102..2417f648 100644 --- a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift @@ -1,35 +1,32 @@ -import DesignSystem -import DomainModule import SwiftUI +import DomainModule +import DesignSystem struct RemainApplyListCellView: View { - @StateObject var viewModel: RemainApplyViewModel - - var body: some View { - VStack(spacing: 12) { - ForEach(viewModel.remainApplicationList.remainOptions, id: \.self) { remainApplication in - remainApplyListCellView(list: remainApplication) - } - } - .onAppear { - viewModel.fetchRemainApplicationList() - } + @State private var isShowingDetail = false + @Binding var selectedObject: RemainOptionEntity? + var list: RemainOptionEntity + let isSelected: Bool + let action: () -> Void + public init( + list: RemainOptionEntity, + isSelected: Bool, + action: @escaping () -> Void, + selectedObject: Binding + ) { + self.list = list + self.isSelected = isSelected + self.action = action + _selectedObject = selectedObject } - - @ViewBuilder - func remainApplyListCellView(list: RemainOptionEntity) -> some View { - let isSelected: Bool = { - list == viewModel.selectedRemainOptionEntity?.selectedEntity - }() + var body: some View { VStack(alignment: .leading) { HStack(alignment: .center) { Button(action: { if !isSelected { - viewModel.selectedRemainOptionEntity?.selectedEntity = list - print("삽입") + action() + selectedObject = list } - print(isSelected) - print(list, viewModel.selectedRemainOptionEntity?.selectedEntity) }, label: { HStack { Text(list.title) @@ -52,23 +49,28 @@ struct RemainApplyListCellView: View { Spacer() - Image(systemName: isSelected ? "chevron.up" : "chevron.down") + Image(systemName: "chevron.down") .foregroundColor(isSelected ? .System.primary : .GrayScale.gray7) - .padding(.trailing, 25) + .rotationEffect( + isShowingDetail + ? Angle.degrees(180) + : .degrees(0) + ) + .padding(25) .onTapGesture { -// viewModel.selectedNum = applyType.rawValue -// viewModel.selectedType = list.title -// viewModel.isDetailTapped.toggle() + withAnimation { + isShowingDetail.toggle() + } } }) } -// if viewModel.isDetailTapped == true && viewModel.selectedNum == applyType.rawValue { -// Text(list.description) -// .multilineTextAlignment(.leading) -// .dmsFont(.body(.body3), color: .GrayScale.gray9) -// .padding([.horizontal, .bottom], 20) -// } + if isShowingDetail { + Text(list.description) + .multilineTextAlignment(.leading) + .dmsFont(.body(.body3), color: .GrayScale.gray9) + .padding([.horizontal, .bottom], 20) + } } .background(Color.System.surface) .cornerRadius(10) diff --git a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift new file mode 100644 index 00000000..072a9e87 --- /dev/null +++ b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift @@ -0,0 +1,26 @@ +import DesignSystem +import DomainModule +import SwiftUI + +struct RemainApplyListView: View { + @StateObject var viewModel: RemainApplyViewModel + @Binding var selectedObject: RemainOptionEntity? + + var body: some View { + VStack(spacing: 12) { + ForEach(viewModel.remainApplicationList.remainOptions, id: \.self) { remainApplication in + RemainApplyListCellView( + list: remainApplication, + isSelected: remainApplication == selectedObject, + action: { + selectedObject = remainApplication + }, + selectedObject: $selectedObject + ) + } + } + .onAppear { + viewModel.fetchRemainApplicationList() + } + } +} diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift index d2aaa9f4..34323cf1 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift @@ -1,10 +1,13 @@ import DesignSystem +import DomainModule import SwiftUI struct RemainApplyView: View { - @AppStorage("RemainState") var remainState: String? @StateObject var viewModel: RemainApplyViewModel @Environment(\.dismiss) var dismiss + @State private var selectedObject: RemainOptionEntity? + + @State private var isEnabled: Bool = false init( viewModel: RemainApplyViewModel @@ -18,39 +21,27 @@ struct RemainApplyView: View { .frame(height: 1) ScrollView(showsIndicators: false) { - if viewModel.isApplicationTime { - RemainApplyNoticeView(notice: viewModel.rangeString) - } - RemainApplyListCellView(viewModel: viewModel) + RemainApplyNoticeView(notice: viewModel.rangeString) + RemainApplyListView(viewModel: viewModel, selectedObject: $selectedObject) .padding(.horizontal, 24) } DMSWideButton( text: { - if viewModel.isAlreadyApplied && (viewModel.selectedType == viewModel.appliedState) { + if isEnabled { return "신청 완료" - } else if viewModel.isAlreadyApplied && (viewModel.selectedType != viewModel.appliedState) { - return viewModel.selectedType + "로 변경하기" + } else if viewModel.myRemainsApplicationItems?.title == selectedObject?.title { + return selectedObject?.title ?? "nul" + "로 변경하기" } else { - return viewModel.selectedType + " 신청하기" + return selectedObject?.title ?? "nul" + " 신청하기" } }(), style: .contained, - color: { - if viewModel.isAlreadyApplied && (viewModel.selectedType == viewModel.appliedState) { - return .System.primary.opacity(0.5) - } else if viewModel.selectedType.isEmpty { - return .clear - } else { - return .System.primary - } - }(), + color: .PrimaryVariant.primary, action: { - viewModel.appliedState = viewModel.selectedType - viewModel.isAlreadyApplied = (viewModel.isErrorOcuured ? false : true) - viewModel.appliedNum = viewModel.selectedNum - remainState = viewModel.appliedState + viewModel.remainingApplicationsChanges(id: selectedObject?.id ?? "") }) + .disabled(isEnabled) .padding(.bottom, 71) .padding(.horizontal, 24) } @@ -64,7 +55,10 @@ struct RemainApplyView: View { style: .error ) .onAppear { - viewModel.fetchRemainsAvailableTime() + isEnabled = { + selectedObject?.isApplied ?? false + }() + viewModel.fetchMyRemainApplicationItems() } } } diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 80fdb88b..48827d71 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -5,21 +5,13 @@ import Combine import SwiftUI final class RemainApplyViewModel: BaseViewModel { - @Published var selectedNum: Int = 10 - @Published var selectedType: String = "" - @AppStorage("isApplied") var isAlreadyApplied: Bool = false - @Published var appliedState: String = "" - @AppStorage("appliedNum") var appliedNum: Int = 10 - @Published var isApplicationTime = true @Published var isShowingToast = false @Published var toastMessage = "" @Published var remainsAvailableTime: RemainsAvailableTimeEntity? @Published var remainApplicationList = RemainApplicationListEntity(remainOptions: []) - @Published var selectedRemainOptionEntity: SelectedRemainOptionEntity? - // 이부분에 옵셔널 처리가 아닌 값처리를 해주면 값이 잘 바껴요 -// @Published var selectedEntity: RemainOptionEntity? + @Published var myRemainsApplicationItems: MyRemainApplicationItemsEntity? var rangeString: String { if let time = remainsAvailableTime { @@ -64,4 +56,21 @@ final class RemainApplyViewModel: BaseViewModel { self?.remainApplicationList = remainApplicationList } } + + func remainingApplicationsChanges(id: String) { + addCancellable( + remainingApplicationsChangesUseCase.execute(id: id), + onReceiveValue: { + + } + ) + } + + func fetchMyRemainApplicationItems() { + addCancellable( + fetchMyRemainApplicationItemsUseCase.execute() + ) { [weak self] myRemainsApplicationItems in + self?.myRemainsApplicationItems = myRemainsApplicationItems + } + } } diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailView.swift index 468a1d99..16dc309a 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailView.swift @@ -4,7 +4,6 @@ import DomainModule import SwiftUI struct StudyRoomDetailView: View { - @AppStorage("StudyRoomState") var studyRoomState: String? @StateObject var viewModel: StudyRoomDetailViewModel @Environment(\.dismiss) var dismiss @Environment(\.tabbarHidden) var tabbarHidden diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift index 73cb9a87..a628dfc1 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift @@ -13,7 +13,6 @@ final class StudyRoomDetailViewModel: BaseViewModel { @Published var isShowingToast = false @Published var toastMessage = "" @Published var selectedSeat: SeatEntity? - @AppStorage("StudyRoomState") var studyRoomState: String? let studyRoomEntity: StudyRoomEntity @@ -103,9 +102,6 @@ final class StudyRoomDetailViewModel: BaseViewModel { self?.isShowingToast = true self?.toastMessage = "자습실 신청이 완료되었습니다." self?.selectedSeat = nil - } onReceiveError: { [weak self] error in - self?.toastMessage = error.localizedDescription - self?.studyRoomState = nil } } @@ -116,9 +112,6 @@ final class StudyRoomDetailViewModel: BaseViewModel { self?.fetchDetailStudyRoom() self?.isShowingToast = true self?.toastMessage = "자습실 취소가 완료되었습니다." - self?.studyRoomState = nil - } onReceiveError: { [weak self] error in - self?.toastMessage = error.localizedDescription } } diff --git a/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift b/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift index 5f297335..679ed2e6 100644 --- a/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift +++ b/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift @@ -7,6 +7,7 @@ public enum StudyRoomsAPI { case fetchSeatTypes case fetchStudyRoomList case fetchDetailStudyRoom(roomID: String) + case fetchMyStudyRoomApplicationItems case applyStudyRoomSeat(seatID: String) case cancelStudyRoomSeat } @@ -35,12 +36,14 @@ extension StudyRoomsAPI: DmsAPI { case .cancelStudyRoomSeat: return "/seats" + case .fetchMyStudyRoomApplicationItems: + return "/my" } } public var method: Moya.Method { switch self { - case .fetchStudyAvailableTime, .fetchSeatTypes, .fetchStudyRoomList, .fetchDetailStudyRoom: + case .fetchStudyAvailableTime, .fetchSeatTypes, .fetchStudyRoomList, .fetchDetailStudyRoom, .fetchMyStudyRoomApplicationItems: return .get case .applyStudyRoomSeat: diff --git a/Projects/Services/DataMappingModule/Sources/StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift b/Projects/Services/DataMappingModule/Sources/StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift new file mode 100644 index 00000000..e59e34dd --- /dev/null +++ b/Projects/Services/DataMappingModule/Sources/StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift @@ -0,0 +1,10 @@ +import Foundation + +public struct FehtchMyStudyRoomApplicationItemsDTO: Decodable { + public init(floor: String, name: String) { + self.floor = floor + self.name = name + } + public let floor: String + public let name: String +} diff --git a/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchMyRemainApplicationItemsUseCaselmpl.swift b/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchMyRemainApplicationItemsUseCaseImpl.swift similarity index 87% rename from Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchMyRemainApplicationItemsUseCaselmpl.swift rename to Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchMyRemainApplicationItemsUseCaseImpl.swift index cd36364a..05007cd7 100644 --- a/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchMyRemainApplicationItemsUseCaselmpl.swift +++ b/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchMyRemainApplicationItemsUseCaseImpl.swift @@ -3,7 +3,7 @@ import DataMappingModule import DomainModule import ErrorModule -public struct FetchMyRemainApplicationItemsUseCaselmpl: FetchMyRemainApplicationItemsUseCase { +public struct FetchMyRemainApplicationItemsUseCaseImpl: FetchMyRemainApplicationItemsUseCase { private let remainsRepository: any RemainsRepository public init(remainsRepository: any RemainsRepository) { diff --git a/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainAppListUseCaselmpl.swift b/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainAppListUseCaseImpl.swift similarity index 86% rename from Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainAppListUseCaselmpl.swift rename to Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainAppListUseCaseImpl.swift index 2e4248f8..b64bb5c6 100644 --- a/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainAppListUseCaselmpl.swift +++ b/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainAppListUseCaseImpl.swift @@ -3,7 +3,7 @@ import DataMappingModule import DomainModule import ErrorModule -public struct FetchRemainAppListUseCaselmpl: FetchRemainApplicationListUseCase { +public struct FetchRemainAppListUseCaseImpl: FetchRemainApplicationListUseCase { private let remainsRepository: any RemainsRepository public init(remainsRepository: any RemainsRepository) { diff --git a/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainsAvailableTimeUseCaselmpl.swift b/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainsAvailableTimeUseCaseImpl.swift similarity index 86% rename from Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainsAvailableTimeUseCaselmpl.swift rename to Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainsAvailableTimeUseCaseImpl.swift index 01c5e6cb..5b1ba281 100644 --- a/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainsAvailableTimeUseCaselmpl.swift +++ b/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/FetchRemainsAvailableTimeUseCaseImpl.swift @@ -3,7 +3,7 @@ import DataMappingModule import DomainModule import ErrorModule -public struct FetchRemainsAvailableTimeUseCaselmpl: FetchRemainsAvailableTimeUseCase { +public struct FetchRemainsAvailableTimeUseCaseImpl: FetchRemainsAvailableTimeUseCase { private let remainsRepository: any RemainsRepository public init(remainsRepository: any RemainsRepository) { diff --git a/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/RemainingApplicationsChangesUseCaselmpl.swift b/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/RemainingApplicationsChangesUseCaseImpl.swift similarity index 87% rename from Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/RemainingApplicationsChangesUseCaselmpl.swift rename to Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/RemainingApplicationsChangesUseCaseImpl.swift index 5692f444..ffe85fd5 100644 --- a/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/RemainingApplicationsChangesUseCaselmpl.swift +++ b/Projects/Services/DataModule/Sources/Remains/UserCases/lmpl/RemainingApplicationsChangesUseCaseImpl.swift @@ -3,7 +3,7 @@ import DataMappingModule import DomainModule import ErrorModule -public struct RemainingApplicationsChangesUseCaselmpl: RemainingApplicationsChangesUseCase { +public struct RemainingApplicationsChangesUseCaseImpl: RemainingApplicationsChangesUseCase { private let remainsRepository: any RemainsRepository public init(remainsRepository: any RemainsRepository) { diff --git a/Projects/Services/DataModule/Sources/StudyRooms/Repositories/Impl/StudyRoomsRepositoryImpl.swift b/Projects/Services/DataModule/Sources/StudyRooms/Repositories/Impl/StudyRoomsRepositoryImpl.swift index 3d8c08df..304177a7 100644 --- a/Projects/Services/DataModule/Sources/StudyRooms/Repositories/Impl/StudyRoomsRepositoryImpl.swift +++ b/Projects/Services/DataModule/Sources/StudyRooms/Repositories/Impl/StudyRoomsRepositoryImpl.swift @@ -34,4 +34,8 @@ public struct StudyRoomsRepositoryImpl: StudyRoomsRepository { public func cancelStudyRoomSeat() -> AnyPublisher { remoteStudyRoomsDataSource.cancelStudyRoomSeat() } + + public func fehtchMyStudyRoomApplicationItems() -> AnyPublisher { + remoteStudyRoomsDataSource.fetchMyRemainApplicationItems() + } } diff --git a/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomApplicationItemsUserCaseImpl.swift b/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomApplicationItemsUserCaseImpl.swift new file mode 100644 index 00000000..e6bd5fff --- /dev/null +++ b/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomApplicationItemsUserCaseImpl.swift @@ -0,0 +1,16 @@ +import Combine +import DataMappingModule +import DomainModule +import ErrorModule + +public struct FehtchMyStudyRoomApplicationItemsUserCaseImpl: FetchMyStudyRoomAppItemsUserCase { + private let studyRoomsRepository: any StudyRoomsRepository + + public init(studyRoomsRepository: any StudyRoomsRepository) { + self.studyRoomsRepository = studyRoomsRepository + } + + public func execute() -> AnyPublisher { + studyRoomsRepository.fehtchMyStudyRoomApplicationItems() + } +} diff --git a/Projects/Services/DomainModule/Sources/Entities/MyStudyRoomAppItemsEntity.swift b/Projects/Services/DomainModule/Sources/Entities/MyStudyRoomAppItemsEntity.swift new file mode 100644 index 00000000..a2172197 --- /dev/null +++ b/Projects/Services/DomainModule/Sources/Entities/MyStudyRoomAppItemsEntity.swift @@ -0,0 +1,10 @@ +import Foundation + +public struct MyStudyRoomAppItemsEntity: Equatable, Hashable { + public init(floor: String, name: String) { + self.floor = floor + self.name = name + } + public let floor: String + public let name: String +} diff --git a/Projects/Services/DomainModule/Sources/Entities/SelectedRemainOptionEntity.swift b/Projects/Services/DomainModule/Sources/Entities/SelectedRemainOptionEntity.swift deleted file mode 100644 index fc2651ea..00000000 --- a/Projects/Services/DomainModule/Sources/Entities/SelectedRemainOptionEntity.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Foundation - -public struct SelectedRemainOptionEntity: Equatable, Hashable { - public init( - selectedEntity: RemainOptionEntity, - isShowingDetail: Bool - ) { - self.selectedEntity = selectedEntity - self.isShowingDetail = isShowingDetail - } - - public var selectedEntity: RemainOptionEntity - public var isShowingDetail: Bool -} diff --git a/Projects/Services/DomainModule/Sources/StudyRooms/Repository/StudyRoomsRepository.swift b/Projects/Services/DomainModule/Sources/StudyRooms/Repository/StudyRoomsRepository.swift index 923beb0c..4656aa5b 100644 --- a/Projects/Services/DomainModule/Sources/StudyRooms/Repository/StudyRoomsRepository.swift +++ b/Projects/Services/DomainModule/Sources/StudyRooms/Repository/StudyRoomsRepository.swift @@ -9,4 +9,5 @@ public protocol StudyRoomsRepository { func fetchDetailStudyRoom(roomID: String) -> AnyPublisher func applyStudyRoomSeat(seatID: String) -> AnyPublisher func cancelStudyRoomSeat() -> AnyPublisher + func fehtchMyStudyRoomApplicationItems() -> AnyPublisher } diff --git a/Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUserCase.swift b/Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUserCase.swift new file mode 100644 index 00000000..15f5dc49 --- /dev/null +++ b/Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUserCase.swift @@ -0,0 +1,7 @@ +import Combine +import DataMappingModule +import ErrorModule + +public protocol FetchMyStudyRoomAppItemsUserCase { + func execute() -> AnyPublisher +} diff --git a/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/DataTransfer/FehtchMyStudyRoomApplicationItemsDataTransfer.swift b/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/DataTransfer/FehtchMyStudyRoomApplicationItemsDataTransfer.swift new file mode 100644 index 00000000..31ef6f28 --- /dev/null +++ b/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/DataTransfer/FehtchMyStudyRoomApplicationItemsDataTransfer.swift @@ -0,0 +1,11 @@ +import DataMappingModule +import DomainModule + +public extension FehtchMyStudyRoomApplicationItemsDTO { + func toDomain() -> MyStudyRoomAppItemsEntity { + MyStudyRoomAppItemsEntity( + floor: floor, + name: name + ) + } +} diff --git a/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift b/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift index 404dba43..6d520e43 100644 --- a/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift +++ b/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift @@ -5,6 +5,13 @@ import DomainModule import ErrorModule public final class RemoteStudyRoomsDataSourceImpl: BaseRemoteDataSource, RemoteStudyRoomsDataSource { + public func fetchMyRemainApplicationItems() -> + AnyPublisher { + request(.fetchMyStudyRoomApplicationItems, dto: FehtchMyStudyRoomApplicationItemsDTO.self) + .map { $0.toDomain() } + .eraseToAnyPublisher() + } + public func fetchStudyAvailableTime() -> AnyPublisher { request(.fetchStudyAvailableTime, dto: FetchStudyAvailableTimeResponseDTO.self) .map { $0.toDomain() } diff --git a/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/RemoteStudyRoomsDataSource.swift b/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/RemoteStudyRoomsDataSource.swift index a82aaf77..464986e9 100644 --- a/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/RemoteStudyRoomsDataSource.swift +++ b/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/RemoteStudyRoomsDataSource.swift @@ -12,4 +12,5 @@ public protocol RemoteStudyRoomsDataSource { func fetchDetailStudyRoom(roomID: String) -> AnyPublisher func applyStudyRoomSeat(seatID: String) -> AnyPublisher func cancelStudyRoomSeat() -> AnyPublisher + func fetchMyRemainApplicationItems() -> AnyPublisher } From 0ea6b40d71c2d0dc12a3cbe5a9b7b269a880286d Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 14:45:43 +0900 Subject: [PATCH 11/28] =?UTF-8?q?feat=20::=20=EC=9E=94=EB=A5=98=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20api=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudyRooms/AppComponent+StudyRooms.swift | 6 +-- .../Sources/Application/NeedleGenerated.swift | 1 + .../ApplyPage/ApplyPageComponent.swift | 8 +-- .../Sources/ApplyPage/ApplyPageView.swift | 4 +- .../ApplyPage/ApplyPageViewModel.swift | 52 +++++++++---------- .../Component/RemainApplyListCellView.swift | 6 +-- .../Component/RemainApplyListView.swift | 8 ++- .../Sources/RemainApplyView.swift | 24 +++------ .../Sources/RemainApplyViewModel.swift | 25 +++++++-- .../APIKit/Sources/StudyRoomsAPI.swift | 3 +- ...htchMyStudyRoomAppItemsUserCaseImpl.swift} | 2 +- 11 files changed, 66 insertions(+), 73 deletions(-) rename Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/{FehtchMyStudyRoomApplicationItemsUserCaseImpl.swift => FehtchMyStudyRoomAppItemsUserCaseImpl.swift} (81%) diff --git a/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift b/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift index a928278c..21ef4b5c 100644 --- a/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift +++ b/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift @@ -35,8 +35,8 @@ public extension AppComponent { var cancelStudyRoomSeatUseCase: any CancelStudyRoomSeatUseCase { CancelStudyRoomSeatUseCaseImpl(studyRoomsRepository: studyRoomsRepository) } - - var fehtchMyStudyRoomApplicationItemsUserCase: any FetchMyStudyRoomAppItemsUserCase { - FehtchMyStudyRoomApplicationItemsUserCaseImpl(studyRoomsRepository: studyRoomsRepository) + + var fehtchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase { + FetchMyStudyRoomAppItemsUserCaseImpl(studyRoomsRepository: studyRoomsRepository) } } diff --git a/Projects/App/Sources/Application/NeedleGenerated.swift b/Projects/App/Sources/Application/NeedleGenerated.swift index b034507e..10e096a3 100644 --- a/Projects/App/Sources/Application/NeedleGenerated.swift +++ b/Projects/App/Sources/Application/NeedleGenerated.swift @@ -534,6 +534,7 @@ extension AppComponent: Registration { localTable["fetchDetailStudyRoomUseCase-any FetchDetailStudyRoomUseCase"] = { [unowned self] in self.fetchDetailStudyRoomUseCase as Any } localTable["applyStudyRoomSeatUseCase-any ApplyStudyRoomSeatUseCase"] = { [unowned self] in self.applyStudyRoomSeatUseCase as Any } localTable["cancelStudyRoomSeatUseCase-any CancelStudyRoomSeatUseCase"] = { [unowned self] in self.cancelStudyRoomSeatUseCase as Any } + localTable["fehtchMyStudyRoomAppItemsUserCase-any FetchMyStudyRoomAppItemsUserCase"] = { [unowned self] in self.fehtchMyStudyRoomAppItemsUserCase as Any } localTable["localAuthDataSource-any LocalAuthDataSource"] = { [unowned self] in self.localAuthDataSource as Any } localTable["remoteAuthDataSource-any RemoteAuthDataSource"] = { [unowned self] in self.remoteAuthDataSource as Any } localTable["authRepository-any AuthRepository"] = { [unowned self] in self.authRepository as Any } diff --git a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageComponent.swift b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageComponent.swift index a4fa4d29..96368444 100644 --- a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageComponent.swift +++ b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageComponent.swift @@ -2,11 +2,8 @@ import SwiftUI import StudyRoomFeature import RemainApplyFeature import NeedleFoundation -import DomainModule public protocol ApplyPageDependency: Dependency { - var fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase { get } - var fetchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase { get } var studyRoomListComponent: StudyRoomListComponent { get } var remainApplyComponent: RemainApplyComponent { get } } @@ -14,10 +11,7 @@ public protocol ApplyPageDependency: Dependency { public final class ApplyPageComponent: Component { public func makeView() -> some View { ApplyPageView( - viewModel: .init( - fetchMyRemainApplicationItemsUseCase: dependency.fetchMyRemainApplicationItemsUseCase, - fehtchMyStudyRoomApplicationItemsUserCase: dependency.fetchMyStudyRoomAppItemsUserCase - ), + viewModel: ApplyPageViewModel(), studyRoomListComponent: dependency.studyRoomListComponent, remainApplyComponent: dependency.remainApplyComponent ) diff --git a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageView.swift b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageView.swift index 47265920..193697cc 100644 --- a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageView.swift +++ b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageView.swift @@ -61,8 +61,8 @@ struct ApplyPageView: View { .navigationBarTitleDisplayMode(.inline) .dmsBackground() .onAppear { - viewModel.fehtchMyStudyRoomApplicationItems() - viewModel.fetchMyRemainApplicationItems() +// viewModel.fehtchMyStudyRoomApplicationItems() +// viewModel.fetchMyRemainApplicationItems() } .onChange(of: viewModel.isNavigateToStudy) { newValue in withAnimation { diff --git a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageViewModel.swift b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageViewModel.swift index 29684b64..4ba224c4 100644 --- a/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageViewModel.swift +++ b/Projects/Features/ApplyFeature/Sources/ApplyPage/ApplyPageViewModel.swift @@ -11,8 +11,8 @@ final class ApplyPageViewModel: BaseViewModel { @Published var myRemainApplicationItem: MyRemainApplicationItemsEntity? @Published var myStudyRoomApplicationItems: MyStudyRoomAppItemsEntity? - private let fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase - private let fehtchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase +// private let fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase +// private let fehtchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase var remainState: String? { if let item = myRemainApplicationItem { @@ -29,28 +29,28 @@ final class ApplyPageViewModel: BaseViewModel { return nil } } - - public init( - fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase, - fehtchMyStudyRoomApplicationItemsUserCase: any FetchMyStudyRoomAppItemsUserCase - ) { - self.fetchMyRemainApplicationItemsUseCase = fetchMyRemainApplicationItemsUseCase - self.fehtchMyStudyRoomAppItemsUserCase = fehtchMyStudyRoomApplicationItemsUserCase - } - - func fetchMyRemainApplicationItems() { - addCancellable( - fetchMyRemainApplicationItemsUseCase.execute() - ) { [weak self] myRemainApplicationItem in - self?.myRemainApplicationItem = myRemainApplicationItem - } - } - - func fehtchMyStudyRoomApplicationItems() { - addCancellable( - fehtchMyStudyRoomAppItemsUserCase.execute() - ) { [weak self] myStudyRoomApplicationItems in - self?.myStudyRoomApplicationItems = myStudyRoomApplicationItems - } - } +// +// public init( +// fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase, +// fehtchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase +// ) { +// self.fetchMyRemainApplicationItemsUseCase = fetchMyRemainApplicationItemsUseCase +// self.fehtchMyStudyRoomAppItemsUserCase = fehtchMyStudyRoomAppItemsUserCase +// } + +// func fetchMyRemainApplicationItems() { +// addCancellable( +// fetchMyRemainApplicationItemsUseCase.execute() +// ) { [weak self] myRemainApplicationItem in +// self?.myRemainApplicationItem = myRemainApplicationItem +// } +// } +// +// func fehtchMyStudyRoomApplicationItems() { +// addCancellable( +// fehtchMyStudyRoomAppItemsUserCase.execute() +// ) { [weak self] myStudyRoomApplicationItems in +// self?.myStudyRoomApplicationItems = myStudyRoomApplicationItems +// } +// } } diff --git a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift index 2417f648..da9775d2 100644 --- a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListCellView.swift @@ -4,20 +4,17 @@ import DesignSystem struct RemainApplyListCellView: View { @State private var isShowingDetail = false - @Binding var selectedObject: RemainOptionEntity? var list: RemainOptionEntity let isSelected: Bool let action: () -> Void public init( list: RemainOptionEntity, isSelected: Bool, - action: @escaping () -> Void, - selectedObject: Binding + action: @escaping () -> Void ) { self.list = list self.isSelected = isSelected self.action = action - _selectedObject = selectedObject } var body: some View { VStack(alignment: .leading) { @@ -25,7 +22,6 @@ struct RemainApplyListCellView: View { Button(action: { if !isSelected { action() - selectedObject = list } }, label: { HStack { diff --git a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift index 072a9e87..85f934da 100644 --- a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift @@ -4,18 +4,16 @@ import SwiftUI struct RemainApplyListView: View { @StateObject var viewModel: RemainApplyViewModel - @Binding var selectedObject: RemainOptionEntity? var body: some View { VStack(spacing: 12) { ForEach(viewModel.remainApplicationList.remainOptions, id: \.self) { remainApplication in RemainApplyListCellView( list: remainApplication, - isSelected: remainApplication == selectedObject, + isSelected: remainApplication.id == viewModel.selectedEntity?.id, action: { - selectedObject = remainApplication - }, - selectedObject: $selectedObject + viewModel.selectedEntity = remainApplication + } ) } } diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift index 34323cf1..9ac6ca4a 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift @@ -5,9 +5,6 @@ import SwiftUI struct RemainApplyView: View { @StateObject var viewModel: RemainApplyViewModel @Environment(\.dismiss) var dismiss - @State private var selectedObject: RemainOptionEntity? - - @State private var isEnabled: Bool = false init( viewModel: RemainApplyViewModel @@ -22,28 +19,21 @@ struct RemainApplyView: View { ScrollView(showsIndicators: false) { RemainApplyNoticeView(notice: viewModel.rangeString) - RemainApplyListView(viewModel: viewModel, selectedObject: $selectedObject) + RemainApplyListView(viewModel: viewModel) .padding(.horizontal, 24) } DMSWideButton( - text: { - if isEnabled { - return "신청 완료" - } else if viewModel.myRemainsApplicationItems?.title == selectedObject?.title { - return selectedObject?.title ?? "nul" + "로 변경하기" - } else { - return selectedObject?.title ?? "nul" + " 신청하기" - } - }(), + text: viewModel.buttonTitle, style: .contained, color: .PrimaryVariant.primary, action: { - viewModel.remainingApplicationsChanges(id: selectedObject?.id ?? "") + viewModel.remainingApplicationsChanges(id: viewModel.selectedEntity?.id ?? "") }) - .disabled(isEnabled) + .disabled(viewModel.selectedEntity?.title == viewModel.myRemainsApplicationItems?.title) .padding(.bottom, 71) .padding(.horizontal, 24) + .opacity(viewModel.selectedEntity == nil ? 0 : 1) } .navigationTitle("잔류 신청") .navigationBarTitleDisplayMode(.inline) @@ -55,9 +45,7 @@ struct RemainApplyView: View { style: .error ) .onAppear { - isEnabled = { - selectedObject?.isApplied ?? false - }() + viewModel.fetchRemainsAvailableTime() viewModel.fetchMyRemainApplicationItems() } } diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 48827d71..4d9359f4 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -12,6 +12,7 @@ final class RemainApplyViewModel: BaseViewModel { @Published var remainsAvailableTime: RemainsAvailableTimeEntity? @Published var remainApplicationList = RemainApplicationListEntity(remainOptions: []) @Published var myRemainsApplicationItems: MyRemainApplicationItemsEntity? + @Published var selectedEntity: RemainOptionEntity? var rangeString: String { if let time = remainsAvailableTime { @@ -24,6 +25,20 @@ final class RemainApplyViewModel: BaseViewModel { } } + var buttonTitle: String { + if let selectedEntity = self.selectedEntity { + if selectedEntity.title == myRemainsApplicationItems?.title { + return "신청 완료" + } else if myRemainsApplicationItems == nil { + return selectedEntity.title + " 신청하기" + } else { + return selectedEntity.title + "로 변경하기" + } + } else { + return "" + } + } + private let fetchMyRemainApplicationItemsUseCase: any FetchMyRemainApplicationItemsUseCase private let fetchRemainApplicationListUseCase: any FetchRemainApplicationListUseCase private let fetchRemainsAvailableTimeUseCase: any FetchRemainsAvailableTimeUseCase @@ -59,11 +74,11 @@ final class RemainApplyViewModel: BaseViewModel { func remainingApplicationsChanges(id: String) { addCancellable( - remainingApplicationsChangesUseCase.execute(id: id), - onReceiveValue: { - - } - ) + remainingApplicationsChangesUseCase.execute(id: id) + ) { _ in + self.fetchMyRemainApplicationItems() + self.fetchRemainApplicationList() + } } func fetchMyRemainApplicationItems() { diff --git a/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift b/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift index 679ed2e6..aace896f 100644 --- a/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift +++ b/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift @@ -43,7 +43,8 @@ extension StudyRoomsAPI: DmsAPI { public var method: Moya.Method { switch self { - case .fetchStudyAvailableTime, .fetchSeatTypes, .fetchStudyRoomList, .fetchDetailStudyRoom, .fetchMyStudyRoomApplicationItems: + case .fetchStudyAvailableTime, .fetchSeatTypes, + .fetchStudyRoomList, .fetchDetailStudyRoom, .fetchMyStudyRoomApplicationItems: return .get case .applyStudyRoomSeat: diff --git a/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomApplicationItemsUserCaseImpl.swift b/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomAppItemsUserCaseImpl.swift similarity index 81% rename from Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomApplicationItemsUserCaseImpl.swift rename to Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomAppItemsUserCaseImpl.swift index e6bd5fff..8963a6e7 100644 --- a/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomApplicationItemsUserCaseImpl.swift +++ b/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomAppItemsUserCaseImpl.swift @@ -3,7 +3,7 @@ import DataMappingModule import DomainModule import ErrorModule -public struct FehtchMyStudyRoomApplicationItemsUserCaseImpl: FetchMyStudyRoomAppItemsUserCase { +public struct FetchMyStudyRoomAppItemsUserCaseImpl: FetchMyStudyRoomAppItemsUserCase { private let studyRoomsRepository: any StudyRoomsRepository public init(studyRoomsRepository: any StudyRoomsRepository) { From c0bc12e82ec80af66f2aa0babcea9d5cac46489b Mon Sep 17 00:00:00 2001 From: "Reswo._" <102791216+HongSJae@users.noreply.github.com> Date: Tue, 28 Feb 2023 15:08:31 +0900 Subject: [PATCH 12/28] =?UTF-8?q?fix=20::=20~=20!=3D=20nil=20->=20if=20let?= =?UTF-8?q?=20=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: baegteun --- .../Sources/ApplyPage/Component/ApplyListCellView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/Features/ApplyFeature/Sources/ApplyPage/Component/ApplyListCellView.swift b/Projects/Features/ApplyFeature/Sources/ApplyPage/Component/ApplyListCellView.swift index 24a96377..ded968fd 100644 --- a/Projects/Features/ApplyFeature/Sources/ApplyPage/Component/ApplyListCellView.swift +++ b/Projects/Features/ApplyFeature/Sources/ApplyPage/Component/ApplyListCellView.swift @@ -35,8 +35,8 @@ struct ApplyListCellView: View { Spacer() - if applyState != nil { - Text(applyState ?? "") + if let applyState { + Text(applyState) .dmsFont(.etc(.button), color: .PrimaryVariant.primary) .frame(height: 22) .padding(.vertical, 6) From 00b8af5969c4c6247c2fb93382a58b985acbc8ce Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:11:55 +0900 Subject: [PATCH 13/28] =?UTF-8?q?fix=20::=20=EC=98=A4=ED=83=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/DI/StudyRooms/AppComponent+StudyRooms.swift | 4 ++-- Projects/App/Sources/Application/NeedleGenerated.swift | 2 +- .../UseCases/Impl/FehtchMyStudyRoomAppItemsUserCaseImpl.swift | 2 +- ...msUserCase.swift => FetchMyStudyRoomAppItemsUseCase.swift} | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename Projects/Services/DomainModule/Sources/StudyRooms/UseCases/{FetchMyStudyRoomAppItemsUserCase.swift => FetchMyStudyRoomAppItemsUseCase.swift} (72%) diff --git a/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift b/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift index 21ef4b5c..b40487a4 100644 --- a/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift +++ b/Projects/App/Sources/Application/DI/StudyRooms/AppComponent+StudyRooms.swift @@ -36,7 +36,7 @@ public extension AppComponent { CancelStudyRoomSeatUseCaseImpl(studyRoomsRepository: studyRoomsRepository) } - var fehtchMyStudyRoomAppItemsUserCase: any FetchMyStudyRoomAppItemsUserCase { - FetchMyStudyRoomAppItemsUserCaseImpl(studyRoomsRepository: studyRoomsRepository) + var fehtchMyStudyRoomAppItemsUseCase: any FetchMyStudyRoomAppItemsUseCase { + FetchMyStudyRoomAppItemsUseCaseImpl(studyRoomsRepository: studyRoomsRepository) } } diff --git a/Projects/App/Sources/Application/NeedleGenerated.swift b/Projects/App/Sources/Application/NeedleGenerated.swift index 10e096a3..666cd00f 100644 --- a/Projects/App/Sources/Application/NeedleGenerated.swift +++ b/Projects/App/Sources/Application/NeedleGenerated.swift @@ -534,7 +534,7 @@ extension AppComponent: Registration { localTable["fetchDetailStudyRoomUseCase-any FetchDetailStudyRoomUseCase"] = { [unowned self] in self.fetchDetailStudyRoomUseCase as Any } localTable["applyStudyRoomSeatUseCase-any ApplyStudyRoomSeatUseCase"] = { [unowned self] in self.applyStudyRoomSeatUseCase as Any } localTable["cancelStudyRoomSeatUseCase-any CancelStudyRoomSeatUseCase"] = { [unowned self] in self.cancelStudyRoomSeatUseCase as Any } - localTable["fehtchMyStudyRoomAppItemsUserCase-any FetchMyStudyRoomAppItemsUserCase"] = { [unowned self] in self.fehtchMyStudyRoomAppItemsUserCase as Any } + localTable["fehtchMyStudyRoomAppItemsUserCase-any FetchMyStudyRoomAppItemsUserCase"] = { [unowned self] in self.fehtchMyStudyRoomAppItemsUseCase as Any } localTable["localAuthDataSource-any LocalAuthDataSource"] = { [unowned self] in self.localAuthDataSource as Any } localTable["remoteAuthDataSource-any RemoteAuthDataSource"] = { [unowned self] in self.remoteAuthDataSource as Any } localTable["authRepository-any AuthRepository"] = { [unowned self] in self.authRepository as Any } diff --git a/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomAppItemsUserCaseImpl.swift b/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomAppItemsUserCaseImpl.swift index 8963a6e7..231889cf 100644 --- a/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomAppItemsUserCaseImpl.swift +++ b/Projects/Services/DataModule/Sources/StudyRooms/UseCases/Impl/FehtchMyStudyRoomAppItemsUserCaseImpl.swift @@ -3,7 +3,7 @@ import DataMappingModule import DomainModule import ErrorModule -public struct FetchMyStudyRoomAppItemsUserCaseImpl: FetchMyStudyRoomAppItemsUserCase { +public struct FetchMyStudyRoomAppItemsUseCaseImpl: FetchMyStudyRoomAppItemsUseCase { private let studyRoomsRepository: any StudyRoomsRepository public init(studyRoomsRepository: any StudyRoomsRepository) { diff --git a/Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUserCase.swift b/Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUseCase.swift similarity index 72% rename from Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUserCase.swift rename to Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUseCase.swift index 15f5dc49..dca93fb2 100644 --- a/Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUserCase.swift +++ b/Projects/Services/DomainModule/Sources/StudyRooms/UseCases/FetchMyStudyRoomAppItemsUseCase.swift @@ -2,6 +2,6 @@ import Combine import DataMappingModule import ErrorModule -public protocol FetchMyStudyRoomAppItemsUserCase { +public protocol FetchMyStudyRoomAppItemsUseCase { func execute() -> AnyPublisher } From e7b8fdbd813916d138153e440b847703164d82f1 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:13:11 +0900 Subject: [PATCH 14/28] =?UTF-8?q?fix=20::=20switch=20=EC=8A=A4=ED=83=80?= =?UTF-8?q?=EC=9D=BC=20=EA=B0=80=EC=9D=B4=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/App/Sources/Application/NeedleGenerated.swift | 2 +- .../Services/DataMappingModule/Sources/Enum/WeekType.swift | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Projects/App/Sources/Application/NeedleGenerated.swift b/Projects/App/Sources/Application/NeedleGenerated.swift index 666cd00f..3c7a4d47 100644 --- a/Projects/App/Sources/Application/NeedleGenerated.swift +++ b/Projects/App/Sources/Application/NeedleGenerated.swift @@ -534,7 +534,7 @@ extension AppComponent: Registration { localTable["fetchDetailStudyRoomUseCase-any FetchDetailStudyRoomUseCase"] = { [unowned self] in self.fetchDetailStudyRoomUseCase as Any } localTable["applyStudyRoomSeatUseCase-any ApplyStudyRoomSeatUseCase"] = { [unowned self] in self.applyStudyRoomSeatUseCase as Any } localTable["cancelStudyRoomSeatUseCase-any CancelStudyRoomSeatUseCase"] = { [unowned self] in self.cancelStudyRoomSeatUseCase as Any } - localTable["fehtchMyStudyRoomAppItemsUserCase-any FetchMyStudyRoomAppItemsUserCase"] = { [unowned self] in self.fehtchMyStudyRoomAppItemsUseCase as Any } + localTable["fehtchMyStudyRoomAppItemsUseCase-any FetchMyStudyRoomAppItemsUseCase"] = { [unowned self] in self.fehtchMyStudyRoomAppItemsUseCase as Any } localTable["localAuthDataSource-any LocalAuthDataSource"] = { [unowned self] in self.localAuthDataSource as Any } localTable["remoteAuthDataSource-any RemoteAuthDataSource"] = { [unowned self] in self.remoteAuthDataSource as Any } localTable["authRepository-any AuthRepository"] = { [unowned self] in self.authRepository as Any } diff --git a/Projects/Services/DataMappingModule/Sources/Enum/WeekType.swift b/Projects/Services/DataMappingModule/Sources/Enum/WeekType.swift index 7584208d..47e6355e 100644 --- a/Projects/Services/DataMappingModule/Sources/Enum/WeekType.swift +++ b/Projects/Services/DataMappingModule/Sources/Enum/WeekType.swift @@ -13,16 +13,22 @@ public enum WeekType: String, Decodable { switch self { case .monday: return "월" + case .tuesday: return "화" + case .wednesday: return "수" + case .thursday: return "목" + case .friday: return "금" + case .satuday: return "토" + case .sunday: return "일" } From 5746753e78d7e109749963bf29d21886e3820c0a Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:14:15 +0900 Subject: [PATCH 15/28] =?UTF-8?q?fix=20::=20=EC=A4=84=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Projects/Services/DataMappingModule/Sources/StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift b/Projects/Services/DataMappingModule/Sources/StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift index e59e34dd..de434a2e 100644 --- a/Projects/Services/DataMappingModule/Sources/StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift +++ b/Projects/Services/DataMappingModule/Sources/StudyRooms/Response/MyStudyRoomApplicationItemsDTO.swift @@ -5,6 +5,7 @@ public struct FehtchMyStudyRoomApplicationItemsDTO: Decodable { self.floor = floor self.name = name } + public let floor: String public let name: String } From 3cad4e42084663be293d723fbea520ea0ded611f Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:15:46 +0900 Subject: [PATCH 16/28] =?UTF-8?q?fix=20::=20=EC=A4=84=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Services/APIKit/Sources/StudyRoomsAPI.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift b/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift index aace896f..5ba53ad5 100644 --- a/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift +++ b/Projects/Services/APIKit/Sources/StudyRoomsAPI.swift @@ -36,6 +36,7 @@ extension StudyRoomsAPI: DmsAPI { case .cancelStudyRoomSeat: return "/seats" + case .fetchMyStudyRoomApplicationItems: return "/my" } From c4f3a632b5d6bc85aa795491d2a6b12f1ab1e582 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:27:41 +0900 Subject: [PATCH 17/28] =?UTF-8?q?fix=20::=20=ED=83=80=EC=9E=85=20=EB=AA=85?= =?UTF-8?q?=EC=8B=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift b/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift index 6d520e43..9fbc654e 100644 --- a/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift +++ b/Projects/Services/NetworkModule/Sources/StudyRooms/Remote/Impl/RemoteStudyRoomsDataSourceImpl.swift @@ -5,8 +5,7 @@ import DomainModule import ErrorModule public final class RemoteStudyRoomsDataSourceImpl: BaseRemoteDataSource, RemoteStudyRoomsDataSource { - public func fetchMyRemainApplicationItems() -> - AnyPublisher { + public func fetchMyRemainApplicationItems() -> AnyPublisher { request(.fetchMyStudyRoomApplicationItems, dto: FehtchMyStudyRoomApplicationItemsDTO.self) .map { $0.toDomain() } .eraseToAnyPublisher() From 75cfc9a9f0ecdc164e6665e3b29123c7c0533b84 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:28:57 +0900 Subject: [PATCH 18/28] fix :: retain cycle --- .../RemainApplyFeature/Sources/RemainApplyViewModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 4d9359f4..e79a16c2 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -75,7 +75,7 @@ final class RemainApplyViewModel: BaseViewModel { func remainingApplicationsChanges(id: String) { addCancellable( remainingApplicationsChangesUseCase.execute(id: id) - ) { _ in + ) { [weak self] _ in self.fetchMyRemainApplicationItems() self.fetchRemainApplicationList() } From 5de8570280ec65753e9f8ac13c94afdcbd28ad4b Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:30:10 +0900 Subject: [PATCH 19/28] fix :: retain cycle --- .../RemainApplyFeature/Sources/RemainApplyViewModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index e79a16c2..7d463f96 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -76,8 +76,8 @@ final class RemainApplyViewModel: BaseViewModel { addCancellable( remainingApplicationsChangesUseCase.execute(id: id) ) { [weak self] _ in - self.fetchMyRemainApplicationItems() - self.fetchRemainApplicationList() + self?.fetchMyRemainApplicationItems() + self?.fetchRemainApplicationList() } } From 723fdc17a7e7efc930c2e92d3b67633303769d3e Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:48:35 +0900 Subject: [PATCH 20/28] =?UTF-8?q?fix=20::=20=EC=A4=84=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Entities/MyStudyRoomAppItemsEntity.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Projects/Services/DomainModule/Sources/Entities/MyStudyRoomAppItemsEntity.swift b/Projects/Services/DomainModule/Sources/Entities/MyStudyRoomAppItemsEntity.swift index a2172197..adefdcc1 100644 --- a/Projects/Services/DomainModule/Sources/Entities/MyStudyRoomAppItemsEntity.swift +++ b/Projects/Services/DomainModule/Sources/Entities/MyStudyRoomAppItemsEntity.swift @@ -5,6 +5,7 @@ public struct MyStudyRoomAppItemsEntity: Equatable, Hashable { self.floor = floor self.name = name } + public let floor: String public let name: String } From 5bd239d151d4d9530b41107c6e0f1da9263181b7 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:48:46 +0900 Subject: [PATCH 21/28] =?UTF-8?q?fix=20::=20=EC=BD=94=EB=93=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RemainApplyFeature/Sources/RemainApplyViewModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 7d463f96..0c03062e 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -26,7 +26,7 @@ final class RemainApplyViewModel: BaseViewModel { } var buttonTitle: String { - if let selectedEntity = self.selectedEntity { + if let selectedEntity { if selectedEntity.title == myRemainsApplicationItems?.title { return "신청 완료" } else if myRemainsApplicationItems == nil { From bae276afec63944d0698e2830b3894743b09f909 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:52:32 +0900 Subject: [PATCH 22/28] =?UTF-8?q?fix=20::=20comment=20=EB=8C=80=EB=A1=9C?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RemainApplyViewModel.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 0c03062e..1aa7c5ca 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -76,8 +76,16 @@ final class RemainApplyViewModel: BaseViewModel { addCancellable( remainingApplicationsChangesUseCase.execute(id: id) ) { [weak self] _ in - self?.fetchMyRemainApplicationItems() - self?.fetchRemainApplicationList() + let remainOptions = self?.remainApplicationList.remainOptions + .map { + return RemainOptionEntity( + id: $0.id, + title: $0.title, + description: $0.description, + isApplied: id == $0.id + ) + } + self?.remainApplicationList = RemainApplicationListEntity(remainOptions: remainOptions ?? []) } } From 04ff7eae5f08f4ee3162842813739cf2e68cb4e3 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 15:59:37 +0900 Subject: [PATCH 23/28] =?UTF-8?q?fix=20::=20=ED=95=A8=EC=88=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RemainApplyFeature/Sources/RemainApplyView.swift | 9 ++++++++- .../Sources/RemainApplyViewModel.swift | 7 ++++--- .../Entities/MyRemainApplicationItemsEntity.swift | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift index 9ac6ca4a..fca807f9 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift @@ -28,7 +28,14 @@ struct RemainApplyView: View { style: .contained, color: .PrimaryVariant.primary, action: { - viewModel.remainingApplicationsChanges(id: viewModel.selectedEntity?.id ?? "") + viewModel.remainingApplicationsChanges( + entity: viewModel.selectedEntity ?? RemainOptionEntity( + id: "", + title: "", + description: "", + isApplied: false + ) + ) }) .disabled(viewModel.selectedEntity?.title == viewModel.myRemainsApplicationItems?.title) .padding(.bottom, 71) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 1aa7c5ca..af2d0179 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -72,9 +72,9 @@ final class RemainApplyViewModel: BaseViewModel { } } - func remainingApplicationsChanges(id: String) { + func remainingApplicationsChanges(entity: RemainOptionEntity) { addCancellable( - remainingApplicationsChangesUseCase.execute(id: id) + remainingApplicationsChangesUseCase.execute(id: entity.id) ) { [weak self] _ in let remainOptions = self?.remainApplicationList.remainOptions .map { @@ -82,10 +82,11 @@ final class RemainApplyViewModel: BaseViewModel { id: $0.id, title: $0.title, description: $0.description, - isApplied: id == $0.id + isApplied: entity.id == $0.id ) } self?.remainApplicationList = RemainApplicationListEntity(remainOptions: remainOptions ?? []) + self?.myRemainsApplicationItems?.title = entity.title } } diff --git a/Projects/Services/DomainModule/Sources/Entities/MyRemainApplicationItemsEntity.swift b/Projects/Services/DomainModule/Sources/Entities/MyRemainApplicationItemsEntity.swift index 779001c2..61fa0146 100644 --- a/Projects/Services/DomainModule/Sources/Entities/MyRemainApplicationItemsEntity.swift +++ b/Projects/Services/DomainModule/Sources/Entities/MyRemainApplicationItemsEntity.swift @@ -4,5 +4,5 @@ public struct MyRemainApplicationItemsEntity: Equatable, Hashable { public init(title: String) { self.title = title } - public let title: String + public var title: String } From c9ae9e287c7086d41471e6565cdc583bfe7d3642 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 16:00:40 +0900 Subject: [PATCH 24/28] =?UTF-8?q?fix=20::=20=EB=93=A4=EC=97=AC=EC=93=B0?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RemainApplyViewModel.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index af2d0179..24667645 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -77,14 +77,14 @@ final class RemainApplyViewModel: BaseViewModel { remainingApplicationsChangesUseCase.execute(id: entity.id) ) { [weak self] _ in let remainOptions = self?.remainApplicationList.remainOptions - .map { - return RemainOptionEntity( - id: $0.id, - title: $0.title, - description: $0.description, - isApplied: entity.id == $0.id - ) - } + .map { + return RemainOptionEntity( + id: $0.id, + title: $0.title, + description: $0.description, + isApplied: entity.id == $0.id + ) + } self?.remainApplicationList = RemainApplicationListEntity(remainOptions: remainOptions ?? []) self?.myRemainsApplicationItems?.title = entity.title } From 669b95999cd89031633026218c1d3f932da256ae Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 16:01:23 +0900 Subject: [PATCH 25/28] =?UTF-8?q?fix=20::=20LazyStack=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Component/RemainApplyListView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift index 85f934da..baedb2c6 100644 --- a/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/Component/RemainApplyListView.swift @@ -6,7 +6,7 @@ struct RemainApplyListView: View { @StateObject var viewModel: RemainApplyViewModel var body: some View { - VStack(spacing: 12) { + LazyVStack(spacing: 12) { ForEach(viewModel.remainApplicationList.remainOptions, id: \.self) { remainApplication in RemainApplyListCellView( list: remainApplication, From 97d37f7934db07984b332aa96a347a742bbb5ff4 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 16:02:29 +0900 Subject: [PATCH 26/28] =?UTF-8?q?fix=20::=20error=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift index a628dfc1..db161fc1 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift @@ -102,6 +102,8 @@ final class StudyRoomDetailViewModel: BaseViewModel { self?.isShowingToast = true self?.toastMessage = "자습실 신청이 완료되었습니다." self?.selectedSeat = nil + } onReceiveError: { [weak self] error in + self?.toastMessage = error.localizedDescription } } From 55e4127850511a4c75904ebeb65beed8f30f0b8e Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 16:10:56 +0900 Subject: [PATCH 27/28] =?UTF-8?q?fix=20::=20viewmodel=20=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=ED=95=A8=EC=88=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 이렇게 하는게 맞나 잘 모르겠네요..? --- .../Sources/RemainApplyView.swift | 9 +-------- .../Sources/RemainApplyViewModel.swift | 13 ++++++++++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift index fca807f9..12f0eef3 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift @@ -28,14 +28,7 @@ struct RemainApplyView: View { style: .contained, color: .PrimaryVariant.primary, action: { - viewModel.remainingApplicationsChanges( - entity: viewModel.selectedEntity ?? RemainOptionEntity( - id: "", - title: "", - description: "", - isApplied: false - ) - ) + viewModel.changeRemainApply() }) .disabled(viewModel.selectedEntity?.title == viewModel.myRemainsApplicationItems?.title) .padding(.bottom, 71) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index 24667645..c394162b 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -72,7 +72,18 @@ final class RemainApplyViewModel: BaseViewModel { } } - func remainingApplicationsChanges(entity: RemainOptionEntity) { + func changeRemainApply() { + remainingApplicationsChanges( + entity: selectedEntity ?? RemainOptionEntity( + id: "", + title: "", + description: "", + isApplied: false + ) + ) + } + + private func remainingApplicationsChanges(entity: RemainOptionEntity) { addCancellable( remainingApplicationsChangesUseCase.execute(id: entity.id) ) { [weak self] _ in From 4c441265d68de64139bfac7dcdf6a2be17f74e23 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Tue, 28 Feb 2023 21:04:42 +0900 Subject: [PATCH 28/28] =?UTF-8?q?feat=20::=20toast=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/RemainApplyView.swift | 10 +++++--- .../Sources/RemainApplyViewModel.swift | 25 ++++++++++++------- .../StudyRoomDetail/StudyRoomDetailView.swift | 1 + .../StudyRoomDetailViewModel.swift | 2 ++ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift index 12f0eef3..c3d1a636 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyView.swift @@ -40,13 +40,17 @@ struct RemainApplyView: View { .dmsBackground() .dmsBackButton(dismiss: dismiss) .dmsToast( - isShowing: $viewModel.isErrorOcuured, + isShowing: $viewModel.isShowingToast, message: viewModel.toastMessage, style: .error ) + .dmsToast( + isShowing: $viewModel.isShowingToast, + message: viewModel.toastMessage, + style: .success + ) .onAppear { - viewModel.fetchRemainsAvailableTime() - viewModel.fetchMyRemainApplicationItems() + viewModel.onAppear() } } } diff --git a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift index c394162b..09a1d812 100644 --- a/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift +++ b/Projects/Features/RemainApplyFeature/Sources/RemainApplyViewModel.swift @@ -56,7 +56,7 @@ final class RemainApplyViewModel: BaseViewModel { self.remainingApplicationsChangesUseCase = remainingApplicationsChangesUseCase } - func fetchRemainsAvailableTime() { + private func fetchRemainsAvailableTime() { addCancellable( fetchRemainsAvailableTimeUseCase.execute() ) { [weak self] remainsAvailableTime in @@ -73,14 +73,11 @@ final class RemainApplyViewModel: BaseViewModel { } func changeRemainApply() { - remainingApplicationsChanges( - entity: selectedEntity ?? RemainOptionEntity( - id: "", - title: "", - description: "", - isApplied: false + if let selectedEntity { + remainingApplicationsChanges( + entity: selectedEntity ) - ) + } } private func remainingApplicationsChanges(entity: RemainOptionEntity) { @@ -98,14 +95,24 @@ final class RemainApplyViewModel: BaseViewModel { } self?.remainApplicationList = RemainApplicationListEntity(remainOptions: remainOptions ?? []) self?.myRemainsApplicationItems?.title = entity.title + self?.toastMessage = "잔류 신청이 완료되었습니다." + self?.isShowingToast = true + } onReceiveError: { [weak self] _ in + self?.isShowingToast = true + self?.toastMessage = "잔류 신청 시간이 아닙니다." } } - func fetchMyRemainApplicationItems() { + private func fetchMyRemainApplicationItems() { addCancellable( fetchMyRemainApplicationItemsUseCase.execute() ) { [weak self] myRemainsApplicationItems in self?.myRemainsApplicationItems = myRemainsApplicationItems } } + + func onAppear() { + fetchRemainsAvailableTime() + fetchMyRemainApplicationItems() + } } diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailView.swift b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailView.swift index 16dc309a..4899764c 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailView.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailView.swift @@ -42,6 +42,7 @@ struct StudyRoomDetailView: View { .navigationBarTitleDisplayMode(.inline) .dmsBackground() .dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) + .dmsToast(isShowing: $viewModel.isShowingToast, message: viewModel.toastMessage, style: .success) .onAppear { viewModel.onAppear() } diff --git a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift index db161fc1..da5af48b 100644 --- a/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift +++ b/Projects/Features/StudyRoomFeature/Sources/StudyRoomDetail/StudyRoomDetailViewModel.swift @@ -114,6 +114,8 @@ final class StudyRoomDetailViewModel: BaseViewModel { self?.fetchDetailStudyRoom() self?.isShowingToast = true self?.toastMessage = "자습실 취소가 완료되었습니다." + } onReceiveError: { [weak self] error in + self?.toastMessage = error.localizedDescription } }