Skip to content

Commit

Permalink
[Feat] sopt-makers#179 - 플그 미등록 유저에 대응하는 UserType 생성 (unregisteredIna…
Browse files Browse the repository at this point in the history
…ctive)
  • Loading branch information
lsj8706 committed Apr 18, 2023
1 parent ff0420e commit 22dc16b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
11 changes: 7 additions & 4 deletions SOPT-iOS/Projects/Core/Sources/Enum/UserType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import Foundation

public enum UserType {
case visitor // 비회원
case active // 활동 회원
case inactive // 비활동 회원
public enum UserType: String {
case visitor = "VISITOR" // 비회원
case active = "ACTIVE" // 활동 회원
case inactive = "INACTIVE" // 비활동 회원
case unregisteredInactive // 비활동 회원 + 플그 프로필 미등록

public func makeDescription(recentHistory: Int) -> String {
switch self {
Expand All @@ -21,6 +22,8 @@ public enum UserType {
return "\(recentHistory)\(I18N.Main.active)"
case .inactive:
return "\(recentHistory)\(I18N.Main.inactive)"
case .unregisteredInactive:
return I18N.Main.inactiveMember
}
}
}
15 changes: 15 additions & 0 deletions SOPT-iOS/Projects/Domain/Sources/Model/UserMainInfoModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import Foundation

import Core

public struct UserMainInfoModel {
public let status, name: String
public let profileImage: String?
Expand All @@ -17,6 +19,19 @@ public struct UserMainInfoModel {
public let responseMessage: String?
public var withError: Bool = false

public var userType: UserType {
switch status {
case "": // 플그 미등록인 경우
return .unregisteredInactive
case UserType.active.rawValue:
return .active
case UserType.inactive.rawValue:
return .inactive
default:
return .visitor
}
}

public init(status: String, name: String, profileImage: String?, historyList: [Int], attendanceScore: Float?, announcement: String?, responseMessage: String?) {
self.status = status
self.name = name
Expand Down
12 changes: 12 additions & 0 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/MainUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extension DefaultMainUseCase: MainUseCase {
.sink { event in
print("MainUseCase: \(event)")
} receiveValue: { [weak self] userMainInfoModel in
self?.setUserType(with: userMainInfoModel?.userType)
self?.userMainInfo.send(userMainInfoModel)
}.store(in: self.cancelBag)
}
Expand All @@ -49,4 +50,15 @@ extension DefaultMainUseCase: MainUseCase {
self?.serviceState.send(serviceStateModel)
}.store(in: self.cancelBag)
}

private func setUserType(with userType: UserType?) {
switch userType {
case .none, .unregisteredInactive, .inactive: // nil인 경우도 플그 미등록 유저로 취급
UserDefaultKeyList.Auth.isActiveUser = false
case .active:
UserDefaultKeyList.Auth.isActiveUser = true
default:
UserDefaultKeyList.Auth.isActiveUser = false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ extension AppMyPageVC {
self.soptampSectionGroup,
self.etcSectionGroup
)
case .visitor:
case .visitor, .unregisteredInactive:
self.contentStackView.addArrangedSubviews(
self.servicePolicySectionGroup,
self.etcForVisitorsSectionGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension UserHistoryCVC {
}

// 플그에 기수 정보 입력 안한 비활동 회원 대응 (추후 제거)
if userType == .inactive {
if userType == .inactive || userType == .unregisteredInactive {
if allHistory == nil {
self.userTypeLabel.text = I18N.Main.inactiveMember
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension UserHistoryHeaderView {
if userType == .visitor {
let text = I18N.Main.encourage
setAttributedTextToUserInfoLabel(text: text, name: nil)
} else if userType == .inactive {
} else if userType == .inactive || userType == .unregisteredInactive {
let text = I18N.Main.welcome
setAttributedTextToUserInfoLabel(text: text, name: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class MainViewModel: ViewModelType {
public struct Output {
var getUserMainInfoDidComplete = PassthroughSubject<Void, Never>()
var isServiceAvailable = PassthroughSubject<Bool, Never>()
var needPlaygroundProfileRegistration = PassthroughSubject<Bool, Never>()
}

// MARK: - init
Expand Down Expand Up @@ -70,7 +71,11 @@ extension MainViewModel {
useCase.userMainInfo.asDriver()
.sink { [weak self] userMainInfo in
self?.userMainInfo = userMainInfo
self?.userType = userMainInfo?.userType ?? .unregisteredInactive
output.getUserMainInfoDidComplete.send()
if self?.userType == .unregisteredInactive {
output.needPlaygroundProfileRegistration.send(true)
}
}.store(in: self.cancelBag)

useCase.serviceState.asDriver()
Expand All @@ -88,7 +93,7 @@ extension MainViewModel {
case .active:
self.mainServiceList = [.attendance, .member, .project]
self.otherServiceList = [.officialHomepage, .crew]
case .inactive:
case .inactive, .unregisteredInactive:
self.mainServiceList = [.faq, .member, .project]
self.otherServiceList = [.crew, .officialHomepage]
}
Expand Down

0 comments on commit 22dc16b

Please sign in to comment.