Skip to content

Commit 78684f5

Browse files
committed
[feat] #187 신고하기 api 연동
1 parent 686d833 commit 78684f5

File tree

8 files changed

+56
-11
lines changed

8 files changed

+56
-11
lines changed

Projects/App/Sources/MainTab/MainTabFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private extension MainTabFeature {
296296
guard let category = state.categoryOfSavedContent else { return .none }
297297
state.categoryOfSavedContent = nil
298298
return .send(.inner(.카테고리상세_이동(category: category)))
299-
case .error, .text, .warning, .none:
299+
case .error, .text, .warning, .report, .none:
300300
return .none
301301
}
302302
}

Projects/CoreKit/Sources/Data/Network/Content/ContentClient+LiveKey.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ extension ContentClient: DependencyKey {
6464
},
6565
추천_컨텐츠_조회: { pageable, keyword in
6666
try await provider.request(.추천_컨텐츠_조회(pageable: pageable, keyword: keyword))
67+
},
68+
컨텐츠_신고: { id in
69+
try await provider.requestNoBody(.컨텐츠_신고(contentId: id))
6770
}
6871
)
6972
}()

Projects/CoreKit/Sources/Data/Network/Content/ContentClient+TestKey.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ extension ContentClient: TestDependencyKey {
2121
썸네일_수정: { _, _ in },
2222
미분류_링크_포킷_이동: { _ in },
2323
미분류_링크_삭제: { _ in },
24-
추천_컨텐츠_조회: { _, _ in .mock }
24+
추천_컨텐츠_조회: { _, _ in .mock },
25+
컨텐츠_신고: { _ in }
2526
)
2627
}()
2728
}

Projects/CoreKit/Sources/Data/Network/Content/ContentClient.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@ public struct ContentClient {
5454
_ pageable: BasePageableRequest,
5555
_ keyword: String?
5656
) async throws -> ContentListInquiryResponse
57+
public var 컨텐츠_신고: @Sendable (
58+
_ contentId: Int
59+
) async throws -> Void
5760
}
5861

Projects/CoreKit/Sources/Data/Network/Content/ContentEndpoint.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public enum ContentEndpoint {
3434
pageable: BasePageableRequest,
3535
keyword: String?
3636
)
37+
case 컨텐츠_신고(contentId: Int)
3738
}
3839

3940
extension ContentEndpoint: TargetType {
@@ -69,6 +70,8 @@ extension ContentEndpoint: TargetType {
6970
return "/uncategorized"
7071
case .추천_컨텐츠_조회:
7172
return "/recommended"
73+
case let .컨텐츠_신고(contentId):
74+
return "report/\(contentId)"
7275
}
7376
}
7477

@@ -81,7 +84,8 @@ extension ContentEndpoint: TargetType {
8184

8285
case .컨텐츠_상세_조회,
8386
.즐겨찾기,
84-
.컨텐츠_추가:
87+
.컨텐츠_추가,
88+
.컨텐츠_신고:
8589
return .post
8690

8791
case .컨텐츠_수정,
@@ -169,6 +173,8 @@ extension ContentEndpoint: TargetType {
169173

170174
case let .미분류_링크_삭제(model):
171175
return .requestJSONEncodable(model)
176+
case .컨텐츠_신고:
177+
return .requestPlain
172178
}
173179
}
174180

Projects/DSKit/Sources/Components/PokitLinkPopup.swift

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,17 @@ public struct PokitLinkPopup: View {
9090

9191
private var closeButton: some View {
9292
Button(action: closedPopup) {
93-
Image(.icon(.x))
94-
.resizable()
95-
.frame(width: 24, height: 24)
96-
.foregroundStyle(iconColor)
93+
Group {
94+
if case .report = type {
95+
Image(.icon(.check))
96+
.resizable()
97+
} else {
98+
Image(.icon(.x))
99+
.resizable()
100+
}
101+
}
102+
.frame(width: 24, height: 24)
103+
.foregroundStyle(iconColor)
97104
}
98105
}
99106

@@ -109,7 +116,7 @@ public struct PokitLinkPopup: View {
109116
case .link, .text, .warning:
110117
UINotificationFeedbackGenerator()
111118
.notificationOccurred(.warning)
112-
case .success:
119+
case .success, .report:
113120
UINotificationFeedbackGenerator()
114121
.notificationOccurred(.success)
115122
case .error:
@@ -125,7 +132,7 @@ public struct PokitLinkPopup: View {
125132
return .pokit(.bg(.tertiary))
126133
case .success:
127134
return .pokit(.bg(.success))
128-
case .error:
135+
case .error, .report:
129136
return .pokit(.bg(.error))
130137
case .warning:
131138
return .pokit(.bg(.warning))
@@ -164,7 +171,8 @@ public struct PokitLinkPopup: View {
164171
let .text(title),
165172
let .success(title),
166173
let .error(title),
167-
let .warning(title):
174+
let .warning(title),
175+
let .report(title):
168176
return title
169177
default: return ""
170178
}
@@ -178,6 +186,7 @@ public extension PokitLinkPopup {
178186
case success(title: String)
179187
case error(title: String)
180188
case warning(title: String)
189+
case report(title: String)
181190
}
182191
}
183192

@@ -205,5 +214,9 @@ public extension PokitLinkPopup {
205214
PokitLinkPopup(
206215
type: .constant(.warning(title: "저장공간 부족"))
207216
)
217+
218+
PokitLinkPopup(
219+
type: .constant(.report(title: "신고가 완료되었습니다"))
220+
)
208221
}
209222
}

Projects/Feature/FeatureRecommend/Sources/Recommend/RecommendFeature.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import ComposableArchitecture
1010
import Domain
1111
import CoreKit
1212
import Util
13+
import DSKit
1314

1415
@Reducer
1516
public struct RecommendFeature {
@@ -48,6 +49,7 @@ public struct RecommendFeature {
4849
var interests: [BaseInterest] { domain.interests }
4950
var showKeywordSheet: Bool = false
5051
var selectedInterestList = Set<BaseInterest>()
52+
var linkPopup: PokitLinkPopup.PopupType?
5153
}
5254

5355
/// - Action
@@ -84,13 +86,15 @@ public struct RecommendFeature {
8486
case 추천_조회_페이징_API_반영(BaseContentListInquiry)
8587
case 유저_관심사_조회_API_반영([BaseInterest])
8688
case 관심사_조회_API_반영([BaseInterest])
89+
case 컨텐츠_신고_API_반영(Int)
8790
}
8891

8992
public enum AsyncAction: Equatable {
9093
case 추천_조회_API
9194
case 추천_조회_페이징_API
9295
case 유저_관심사_조회_API
9396
case 관심사_조회_API
97+
case 컨텐츠_신고_API(Int)
9498
}
9599

96100
public enum ScopeAction: Equatable { case doNothing }
@@ -156,7 +160,7 @@ private extension RecommendFeature {
156160
state.shareContent = content
157161
return .none
158162
case let .신고하기_버튼_눌렀을때(content):
159-
return .none
163+
return shared(.async(.컨텐츠_신고_API(content.id)), state: &state)
160164
case let .전체보기_버튼_눌렀을때(proxy):
161165
guard state.selectedInterest != nil else { return .none }
162166

@@ -228,6 +232,10 @@ private extension RecommendFeature {
228232
})
229233
state.showKeywordSheet = true
230234
return .none
235+
case let .컨텐츠_신고_API_반영(contentId):
236+
state.linkPopup = .report(title: "신고가 완료되었습니다")
237+
state.domain.contentList.data?.removeAll(where: { $0.id == contentId })
238+
return .none
231239
}
232240
}
233241

@@ -264,6 +272,14 @@ private extension RecommendFeature {
264272
let interests = try await userClient.관심사_목록_조회().map { $0.toDomian() }
265273
await send(.inner(.관심사_조회_API_반영(interests)))
266274
}
275+
case let .컨텐츠_신고_API(contentId):
276+
return .run { send in
277+
try await contentClient.컨텐츠_신고(contentId: contentId)
278+
await send(
279+
.inner(.컨텐츠_신고_API_반영(contentId)),
280+
animation: .pokitSpring
281+
)
282+
}
267283
}
268284
}
269285

Projects/Feature/FeatureRecommend/Sources/Recommend/RecommendView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public extension RecommendView {
3232
list
3333
}
3434
.ignoresSafeArea(edges: .bottom)
35+
.overlay(if: store.linkPopup != nil, alignment: .bottom) {
36+
PokitLinkPopup(type: $store.linkPopup)
37+
}
3538
.sheet(item: $store.shareContent) { content in
3639
if let shareURL = URL(string: content.data) {
3740
PokitShareSheet(

0 commit comments

Comments
 (0)