Skip to content

Commit

Permalink
๐Ÿ—‘๏ธ :: [#195] ๋™์•„๋ฆฌ ์‚ญ์ œ ํƒ€์ดํ‹€ ์ œ๊ฑฐ ๋ฐ clubExit์œผ๋กœ๋งŒ ๋˜๊ฒŒ๋” ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
junseopark0331 committed Feb 2, 2024
1 parent e1d384d commit 3e7220d
Showing 1 changed file with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import UIKit
final class DetailClubReactor: Reactor, Stepper {
// MARK: - Properties
var steps: PublishRelay<Step> = .init()

private let disposeBag: DisposeBag = .init()

// MARK: - Reactor
enum Action {
case viewWillAppear
Expand All @@ -28,17 +28,17 @@ final class DetailClubReactor: Reactor, Stepper {
var clubDetail: Club?
var isLoading: Bool
}

let initialState: State
private let clubID: Int

private let fetchDetailClubUseCase: FetchDetailClubUseCase
private let exitClubUseCase: ExitClubUseCase
private let clubApplyUseCase: ClubApplyUseCase
private let clubCancelUseCase: ClubCancelUseCase
private let clubOpenUseCase: ClubOpenUseCase
private let clubCloseUseCase: ClubCloseUseCase

// MARK: - Init
init(
clubID: Int,
Expand All @@ -60,7 +60,7 @@ final class DetailClubReactor: Reactor, Stepper {
self.clubOpenUseCase = clubOpenUseCase
self.clubCloseUseCase = clubCloseUseCase
}

}

// MARK: - Mutate
Expand Down Expand Up @@ -88,14 +88,14 @@ extension DetailClubReactor {
extension DetailClubReactor {
func reduce(state: State, mutation: Mutation) -> State {
var newState = state

switch mutation {
case let .setClub(club):
newState.clubDetail = club
case let .setIsLoading(load):
newState.isLoading = load
}

return newState
}
}
Expand All @@ -105,15 +105,15 @@ private extension DetailClubReactor {
func viewDidLoad() -> Observable<Mutation> {
let start = Observable.just(Mutation.setIsLoading(true))
let task: Single<Club> = fetchDetailClubUseCase.execute(clubID: clubID)

let res = task
.asObservable()
.flatMap { Observable.from([Mutation.setClub($0), .setIsLoading(false)]) }
.catch { [weak self] e in
self?.steps.accept(GCMSStep.failureAlert(title: "์‹คํŒจ", message: e.localizedDescription, action: []))
return .just(.setIsLoading(false))
}

return .concat([start, res])
}
func bottomButtonDidTap() -> Observable<Mutation> {
Expand All @@ -140,25 +140,15 @@ private extension DetailClubReactor {
}
func statusButtonDidTap() -> Observable<Mutation> {
let isHead = (currentState.clubDetail?.scope ?? .member) == .head
let title = isHead ? "๋™์•„๋ฆฌ ์‚ญ์ œํ•˜๊ธฐ" : "๋™์•„๋ฆฌ ํƒˆํ‡ดํ•˜๊ธฐ"
let title = "๋™์•„๋ฆฌ ํƒˆํ‡ดํ•˜๊ธฐ"
var actions: [UIAlertAction] = []
actions.append(.init(title: "๋™์•„๋ฆฌ ๋ฉค๋ฒ„ ๊ด€๋ฆฌ", style: .default, handler: { [weak self] _ in
guard let self = self else { return }
self.steps.accept(GCMSStep.clubStatusIsRequired(clubID: self.clubID, isHead: isHead, isOpened: self.currentState.clubDetail?.isOpen ?? false))
}))
if isHead {
actions.append(.init(title: "๋™์•„๋ฆฌ ์ˆ˜์ •ํ•˜๊ธฐ", style: .default, handler: { [weak self] _ in
guard let self = self, let club = self.currentState.clubDetail else { return }
self.steps.accept(GCMSStep.firstUpdateClubIsRequired(club: club))
}))
}
actions.append(.init(title: title, style: .destructive, handler: { [weak self] _ in
guard let self = self else { return }
if isHead {

} else {
self.clubExit()
}
self.clubExit()
}))
actions.append(.init(title: "์ทจ์†Œ", style: .cancel, handler: nil))
let style: UIAlertController.Style = UIDevice.current.userInterfaceIdiom == .phone ? .actionSheet : .alert
Expand Down

0 comments on commit 3e7220d

Please sign in to comment.