From 19d08db127dc6c36bea51ccf764dc3573dcf8396 Mon Sep 17 00:00:00 2001 From: minhokim Date: Thu, 23 Jan 2025 00:25:38 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20#181=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EA=B0=92=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../App/Sources/MainTab/MainTabPath.swift | 21 ++++++---- .../Sources/PokitCategorySettingFeature.swift | 41 ++++++++++++++----- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/Projects/App/Sources/MainTab/MainTabPath.swift b/Projects/App/Sources/MainTab/MainTabPath.swift index 11fba4db..5bfef4d9 100644 --- a/Projects/App/Sources/MainTab/MainTabPath.swift +++ b/Projects/App/Sources/MainTab/MainTabPath.swift @@ -83,9 +83,7 @@ public extension MainTabFeature { let .path(.element(_, action: .카테고리상세(.delegate(.포킷수정(category))))): state.path.append(.포킷추가및수정(PokitCategorySettingFeature.State( type: .수정, - categoryId: category.id, - categoryImage: category.categoryImage, - categoryName: category.categoryName + category: category ))) return .none @@ -235,14 +233,23 @@ public extension MainTabFeature { return .none case let .path(.element(_, action: .링크공유(.delegate(.공유받은_카테고리_추가(sharedCategory))))): - state.path.append(.포킷추가및수정(PokitCategorySettingFeature.State( - type: .공유추가, - categoryId: sharedCategory.categoryId, + let category = BaseCategoryItem( + id: sharedCategory.categoryId, + userId: 0, + categoryName: sharedCategory.categoryName, categoryImage: BaseCategoryImage( imageId: sharedCategory.categoryImageId, imageURL: sharedCategory.categoryImageUrl ), - categoryName: sharedCategory.categoryName + contentCount: sharedCategory.contentCount, + createdAt: "", + openType: .공개, + keywordType: .default, + userCount: 0 + ) + state.path.append(.포킷추가및수정(PokitCategorySettingFeature.State( + type: .공유추가, + category: category ))) return .none case .path(.element(_, action: .알림함(.delegate(.alertBoxDismiss)))): diff --git a/Projects/Feature/FeatureCategorySetting/Sources/PokitCategorySettingFeature.swift b/Projects/Feature/FeatureCategorySetting/Sources/PokitCategorySettingFeature.swift index 509e8ef2..cc52653d 100644 --- a/Projects/Feature/FeatureCategorySetting/Sources/PokitCategorySettingFeature.swift +++ b/Projects/Feature/FeatureCategorySetting/Sources/PokitCategorySettingFeature.swift @@ -38,7 +38,13 @@ public struct PokitCategorySettingFeature { get { domain.imageList } } + var isPublicType: Bool { + get { domain.openType == .공개 ? true : false } + set { domain.openType = newValue ? .공개 : .비공개 } + } + let type: SettingType + let shareType: ShareType var isProfileSheetPresented: Bool = false var pokitNameTextInpuState: PokitInputStyle.State = .default @Shared(.inMemory("SelectCategory")) var categoryId: Int? @@ -49,16 +55,21 @@ public struct PokitCategorySettingFeature { public init( type: SettingType, - categoryId: Int? = nil, - categoryImage: BaseCategoryImage? = nil, - categoryName: String? = "" + category: BaseCategoryItem? = nil ) { self.type = type self.domain = .init( - categoryId: categoryId, - categoryName: categoryName, - categoryImage: categoryImage + categoryId: category?.id, + categoryName: category?.categoryName, + categoryImage: category?.categoryImage, + openType: category?.openType, + keywordType: category?.keywordType ) + self.shareType = category == nil + ? .미공유 + : category?.userCount ?? 0 > 0 + ? .공유 + : .미공유 } } @@ -157,7 +168,12 @@ private extension PokitCategorySettingFeature { switch type { case .추가: guard let image = domain.categoryImage else { return } - let request = CategoryEditRequest(categoryName: domain.categoryName, categoryImageId: image.id) + let request = CategoryEditRequest( + categoryName: domain.categoryName, + categoryImageId: image.id, + openType: domain.openType.title, + keywordType: domain.keywordType.title + ) let response = try await categoryClient.카테고리_생성(request) let responseToCategoryDomain = BaseCategoryItem( id: response.categoryId, @@ -170,8 +186,8 @@ private extension PokitCategorySettingFeature { contentCount: 0, createdAt: "", //TODO: v2 property 수정 - openType: .비공개, - keywordType: .default, + openType: domain.openType, + keywordType: domain.keywordType, userCount: 0 ) await send(.inner(.카테고리_인메모리_저장(responseToCategoryDomain))) @@ -180,7 +196,12 @@ private extension PokitCategorySettingFeature { case .수정: guard let categoryId = domain.categoryId else { return } guard let image = domain.categoryImage else { return } - let request = CategoryEditRequest(categoryName: domain.categoryName, categoryImageId: image.id) + let request = CategoryEditRequest( + categoryName: domain.categoryName, + categoryImageId: image.id, + openType: domain.openType.title, + keywordType: domain.keywordType.title + ) let _ = try await categoryClient.카테고리_수정(categoryId, request) await send(.delegate(.settingSuccess))