Skip to content

Commit

Permalink
[fix] #181 도메인 변경에 따른 값 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
stealmh committed Jan 22, 2025
1 parent d97907d commit 19d08db
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
21 changes: 14 additions & 7 deletions Projects/App/Sources/MainTab/MainTabPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)))):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
? .공유
: .미공유
}
}

Expand Down Expand Up @@ -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,
Expand All @@ -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)))
Expand All @@ -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))

Expand Down

0 comments on commit 19d08db

Please sign in to comment.