Skip to content

Commit 8d190b0

Browse files
committed
Merge branch 'develop' into QA/MainFeed-iOS-169
2 parents 757800a + 528890e commit 8d190b0

File tree

20 files changed

+704
-8
lines changed

20 files changed

+704
-8
lines changed

β€ŽFitfty/Projects/Coordinator/Sources/Coordinator.swiftβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ enum CoordinatorType {
6969
case onboarding
7070
case detailReport
7171
case report
72+
case reportList
7273
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// ReportListCoordinator.swift
3+
// Coordinator
4+
//
5+
// Created by μž„μ˜μ„  on 2023/02/16.
6+
// Copyright Β© 2023 Fitfty. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import Common
11+
import Setting
12+
import Core
13+
14+
final class ReportListCoordinator: Coordinator {
15+
16+
var type: CoordinatorType { .reportList }
17+
var reportType: ReportType
18+
weak var finishDelegate: CoordinatorFinishDelegate?
19+
20+
var parentCoordinator: Coordinator?
21+
var childCoordinators: [Coordinator] = []
22+
var navigationController: BaseNavigationController
23+
24+
init(
25+
navigationController: BaseNavigationController = BaseNavigationController(),
26+
reportType: ReportType
27+
) {
28+
self.navigationController = navigationController
29+
self.reportType = reportType
30+
}
31+
32+
func start() {
33+
let viewController = makeReportListViewController(reportType: reportType)
34+
navigationController.pushViewController(viewController, animated: true)
35+
}
36+
}
37+
38+
private extension ReportListCoordinator {
39+
40+
func makeReportListViewController(reportType: ReportType) -> UIViewController {
41+
let viewController = ReportListViewController(
42+
coordinator: self,
43+
viewModel: ReportListViewModel(reportType: reportType, fitftyRepository: DefaultFitftyRepository()),
44+
reportType: reportType
45+
)
46+
return viewController
47+
}
48+
49+
}
50+
51+
extension ReportListCoordinator: ReportListCoordinatorInterface {
52+
53+
func dismiss() {
54+
navigationController.popViewController(animated: true)
55+
}
56+
57+
}

β€ŽFitfty/Projects/Coordinator/Sources/Setting/SettingCoordinator.swiftβ€Ž

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ private extension SettingCoordinator {
4646
childCoordinators.append(coordinator)
4747
coordinator.start()
4848
coordinator.finishDelegate = self
49-
coordinator.parentCoordinator = self
5049
let bottomSheetViewController = BottomSheetViewController(
5150
style: .custom(UIScreen.main.bounds.height - 70),
5251
contentViewController: coordinator.navigationController
@@ -61,7 +60,6 @@ private extension SettingCoordinator {
6160
childCoordinators.append(coordinator)
6261
coordinator.start()
6362
coordinator.finishDelegate = self
64-
coordinator.parentCoordinator = self
6563
let bottomSheetViewController = BottomSheetViewController(
6664
style: .custom(450),
6765
contentViewController: coordinator.navigationController
@@ -77,6 +75,18 @@ private extension SettingCoordinator {
7775
childCoordinators.append(coordinator)
7876
return coordinator
7977
}
78+
79+
func makeReportListCoordinator(reportType: ReportType) -> Coordinator {
80+
let coordinator = ReportListCoordinator(
81+
navigationController: navigationController,
82+
reportType: reportType
83+
)
84+
coordinator.parentCoordinator = self
85+
coordinator.finishDelegate = self
86+
childCoordinators.append(coordinator)
87+
return coordinator
88+
}
89+
8090
}
8191

8292
extension SettingCoordinator: SettingCoordinatorInterface {
@@ -108,6 +118,11 @@ extension SettingCoordinator: SettingCoordinatorInterface {
108118
navigationController.present(webViewController, animated: true)
109119
}
110120

121+
func showReportList(reportType: ReportType) {
122+
let coordinator = makeReportListCoordinator(reportType: reportType)
123+
coordinator.start()
124+
}
125+
111126
func finished() {
112127
navigationController.popViewController(animated: true)
113128
finishDelegate?.coordinatorDidFinish(childCoordinator: self)

β€ŽFitfty/Projects/Core/Sources/Network/FitftyAPI.swiftβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public enum FitftyAPI {
3131
case deleteBookmark(boardToken: String)
3232
case reportUser(parameters: UserReportRequest)
3333
case reportPost(parameters: PostReportRequest)
34+
case getUserReportList
35+
case getPostReportList
3436
}
3537

3638
extension FitftyAPI: TargetType, AccessTokenAuthorizable {
@@ -90,6 +92,10 @@ extension FitftyAPI: TargetType, AccessTokenAuthorizable {
9092
return "/reports/user/new"
9193
case .reportPost:
9294
return "/reports/board/new"
95+
case .getPostReportList:
96+
return "/reports/board"
97+
case .getUserReportList:
98+
return "/reports/user"
9399
}
94100
}
95101

@@ -107,8 +113,11 @@ extension FitftyAPI: TargetType, AccessTokenAuthorizable {
107113
.getUserPrivacy,
108114
.checkNickname,
109115
.getPost,
110-
.getOtherUserProfile:
116+
.getOtherUserProfile,
117+
.getUserReportList,
118+
.getPostReportList:
111119
return .get
120+
112121
case .deletePost:
113122
return .delete
114123

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// PostReportListResponse.swift
3+
// Core
4+
//
5+
// Created by μž„μ˜μ„  on 2023/02/16.
6+
// Copyright Β© 2023 Fitfty. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public struct PostReportListResponse: Codable {
12+
public let result: String
13+
public let data: [PostReportListData]?
14+
public let message, errorCode: String?
15+
}
16+
17+
public struct PostReportListData: Codable {
18+
public let reportToken, reportUserToken, reportUserEmail, reportedBoardToken: String
19+
public let reportedBoardFilePath: String
20+
public let reportedCount: Int
21+
public let type: [String]
22+
public let isConfirmed: Bool
23+
}

β€ŽFitfty/Projects/Core/Sources/Network/Response/Setting/UserPrivacyResponse.swiftβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ public struct UserData: Codable {
2222
public let phoneNumber: String?
2323
public let gender: String?
2424
public let birthday: String?
25+
public let role: String
2526
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// UserReportListResponse.swift
3+
// Core
4+
//
5+
// Created by μž„μ˜μ„  on 2023/02/16.
6+
// Copyright Β© 2023 Fitfty. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public struct UserReportListResponse: Codable {
12+
public let result: String
13+
public let data: [UserReportListData]?
14+
public let message, errorCode: String?
15+
}
16+
17+
public struct UserReportListData: Codable {
18+
public let reportToken, reportUserToken, reportUserEmail, reportedUserToken: String
19+
public let reportedUserEmail: String
20+
public let reportedCount: Int
21+
public let type: [String]
22+
public let isConfirmed: Bool
23+
}

β€ŽFitfty/Projects/Core/Sources/Repositories/FitftyRepository.swiftβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public protocol FitftyRepository {
2323

2424
func report(_ request: UserReportRequest) async throws -> FitftyResponse
2525

26+
func getUserReportList() async throws -> UserReportListResponse
27+
28+
func getPostReportList() async throws -> PostReportListResponse
29+
2630
}
2731

2832
public final class DefaultFitftyRepository: FitftyRepository {
@@ -64,4 +68,12 @@ public final class DefaultFitftyRepository: FitftyRepository {
6468
return try await FitftyAPI.request(target: .reportUser(parameters: request), dataType: FitftyResponse.self)
6569
}
6670

71+
public func getUserReportList() async throws -> UserReportListResponse {
72+
return try await FitftyAPI.request(target: .getUserReportList, dataType: UserReportListResponse.self)
73+
}
74+
75+
public func getPostReportList() async throws -> PostReportListResponse {
76+
return try await FitftyAPI.request(target: .getPostReportList, dataType: PostReportListResponse.self)
77+
}
78+
6779
}

β€ŽFitfty/Projects/Core/Sources/Utilities/UserManager.swiftβ€Ž

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ public protocol UserManager {
1818
var location: AnyPublisher<(longitude: Double, latitude: Double)?, Never> { get }
1919
var gender: Gender? { get }
2020
var isGuest: AnyPublisher<Bool, Never> { get }
21-
21+
var isAdmin: AnyPublisher<Bool, Never> { get }
2222
func updateUserState(_ state: Bool)
2323
func updateCurrentLocation(_ address: Address)
2424
func updateGender(_ gender: Gender)
2525
func getGender() -> Gender
2626
func updateGuestState(_ isGuest: Bool)
2727
func updateCompletedWelcomePage()
2828
func getCurrentGuestState() -> Bool
29-
29+
func updateAdminState(_ isAdmin: Bool)
30+
func getAdminState() -> Bool
3031
}
3132

3233
public final class DefaultUserManager {
@@ -38,6 +39,7 @@ public final class DefaultUserManager {
3839
private var _location: CurrentValueSubject<(longitude: Double, latitude: Double)?, Never> = .init(nil)
3940
private var _gender: Gender?
4041
private var _guestState: CurrentValueSubject<Bool, Never> = .init(true)
42+
private var _adminState: CurrentValueSubject<Bool, Never> = .init(false)
4143

4244
private var cancellables: Set<AnyCancellable> = .init()
4345

@@ -64,6 +66,7 @@ extension DefaultUserManager: UserManager {
6466
public var location: AnyPublisher<(longitude: Double, latitude: Double)?, Never> { _location.eraseToAnyPublisher() }
6567
public var gender: Gender? { _gender }
6668
public var isGuest: AnyPublisher<Bool, Never> { _guestState.eraseToAnyPublisher() }
69+
public var isAdmin: AnyPublisher<Bool, Never> { _guestState.eraseToAnyPublisher() }
6770

6871
public func updateUserState(_ state: Bool) {
6972
localStorage.write(key: .isNewUser, value: state)
@@ -102,6 +105,14 @@ extension DefaultUserManager: UserManager {
102105
return _guestState.value
103106
}
104107

108+
public func updateAdminState(_ isAdmin: Bool) {
109+
_adminState.send(isAdmin)
110+
}
111+
112+
public func getAdminState() -> Bool {
113+
return _adminState.value
114+
}
115+
105116
public func fetchCurrentLocation() {
106117
if let location = localStorage.read(key: .currentLocation) as? [String: Any] {
107118
let x = Double(

β€ŽFitfty/Projects/MainFeed/Sources/Main/Home/ViewModel/MainViewModel.swiftβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ private extension MainViewModel {
231231

232232
} else {
233233
let userPrivacy = try await self.getUserPrivacy()
234+
if userPrivacy.data?.role == "ROLE_ADMIN" {
235+
userManager.updateAdminState(true)
236+
} else {
237+
userManager.updateAdminState(false)
238+
}
234239
let myUserToken = userPrivacy.data?.userToken
235240
return codyList
236241
.map { ($0, $0.userToken == myUserToken ? .myProfile : .userProfile) }

0 commit comments

Comments
Β (0)