Skip to content

Commit

Permalink
merge :: 회원가입 직후 탭바에서 신청 탭이 사라지는 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
DSMInhyeKang authored Mar 9, 2023
2 parents 9dc6679 + f9235fe commit c7b89c3
Show file tree
Hide file tree
Showing 26 changed files with 172 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public struct SignupTermsParam: Equatable {
profileImageURLString: String?
) {
self.schoolCode = signupProfileImageParam.schoolCode
self.schoolID = signupProfileImageParam.schoolID
self.schoolAnswer = signupProfileImageParam.schoolAnswer
self.email = signupProfileImageParam.email
self.authCode = signupProfileImageParam.authCode
Expand All @@ -19,7 +18,6 @@ public struct SignupTermsParam: Equatable {
}

public let schoolCode: String
public let schoolID: String
public let schoolAnswer: String
public let email: String
public let authCode: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ struct SignupTermsView: View {
)
}
.dmsBackButton(dismiss: dismiss)
.dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error)
.padding(.horizontal, 24)
.dmsBackground()
.dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error)
.alert(viewModel.alertMessage, isPresented: $viewModel.isShowingAlert) {
Button("확인", role: .cancel) {
appState.sceneFlow = . main
}
}
.onChange(of: viewModel.dmsFeatures) { newValue in
if let newValue {
appState.features = newValue
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ final class SignupTermsViewModel: BaseViewModel {
@Published var isAgreeTerms = false
@Published var isShowingAlert = false
@Published var alertMessage = ""
@Published var dmsFeatures: DmsFeatures?

private let signupUseCase: any SignupUseCase
let signupTermsParam: SignupTermsParam
Expand Down Expand Up @@ -34,8 +35,11 @@ final class SignupTermsViewModel: BaseViewModel {
profileImageUrl: signupTermsParam.profileImageURLString
)
)
) { [weak self] _ in
) { [weak self] feature in
self?.dmsFeatures = feature
self?.isShowingAlert = true
print("thisis")
print(self?.dmsFeatures?.remainService ?? "failed parsing")
self?.alertMessage = "회원가입이 완료되었습니다!"
}
}
Expand Down
5 changes: 4 additions & 1 deletion Projects/Modules/ErrorModule/Sources/DmsError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum DmsError: Error {
case notFoundAccountID

// MARK: - Students
case unAuthorizedEmail
case alreadyExistUserBySignup
case alreadyExistIDByCheckID
case alreadyExistEmailByCheckEmail
Expand Down Expand Up @@ -86,7 +87,7 @@ extension DmsError: LocalizedError {
return "인증 정보를 찾을 수 없습니다."

case .diffrentEmailByAccountID:
return "아이디외 이메일과 일치하지 않습니다."
return "아이디와 이메일이 일치하지 않습니다."

case .notFoundAccountID:
return "존재하지 않는 아이디입니다."
Expand All @@ -95,6 +96,8 @@ extension DmsError: LocalizedError {
return "학생이 등록되지 않았습니다."

// MARK: - Students
case .unAuthorizedEmail:
return "이메일이 인증되지 않았습니다."

case .alreadyExistUserBySignup:
return "이미 회원가입한 학생합니다!"
Expand Down
4 changes: 4 additions & 0 deletions Projects/Services/APIKit/Sources/StudentsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ extension StudentsAPI: DmsAPI {
case .signup:
return [
400: .badRequest,
401: .unAuthorizedEmail,
409: .alreadyExistUserBySignup,
429: .tooManyRequest,
500: .internalServerError
]

Expand Down Expand Up @@ -206,6 +208,8 @@ extension StudentsAPI: DmsAPI {
"school_name" : "광주소프트웨어마이스터고등학교",
"name" : "변찬우",
"gcn" : "2118",
"profile_image_url": "",
"sex": "MALE",
"bonus_point" : 0,
"minus_point" : 24,
"phrase" : "안녕하세요 프론트하는 변찬우입니다"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ public struct DmsFeaturesResponseDTO: Decodable {
}

public struct DmsFeaturesDTO: Decodable {
public let mealService: Bool
public let noticeService: Bool
public let pointService: Bool
public let studyRoomService: Bool
public let remainService: Bool

enum CodingKeys: String, CodingKey {
case mealService = "meal_service"
case noticeService = "notice_service"
case pointService = "point_service"
case studyRoomService = "study_room_service"
case remainService = "remain_service"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ public struct AuthRepositoryStub: AuthRepository {
public func logout() {}

public func signin(req: SigninRequestDTO) -> AnyPublisher<DmsFeatures, DmsError> {
Just(DmsFeatures(studyRoomService: false, remainService: false ))
.setFailureType(to: DmsError.self)
.eraseToAnyPublisher()
Just(DmsFeatures(
mealService: true,
noticeService: true,
pointService: true,
studyRoomService: false,
remainService: false
))
.setFailureType(to: DmsError.self)
.eraseToAnyPublisher()
}

public func verifyAuthCode(req: VerifyAuthCodeRequestDTO) -> AnyPublisher<Void, DmsError> {
Expand All @@ -25,9 +31,15 @@ public struct AuthRepositoryStub: AuthRepository {
}

public func reissueToken() -> AnyPublisher<DmsFeatures, DmsError> {
Just(DmsFeatures(studyRoomService: false, remainService: false))
.setFailureType(to: DmsError.self)
.eraseToAnyPublisher()
Just(DmsFeatures(
mealService: true,
noticeService: true,
pointService: true,
studyRoomService: false,
remainService: false
))
.setFailureType(to: DmsError.self)
.eraseToAnyPublisher()
}

public func checkEmailExistByAccountID(req: EmailExistByAccountIDRequestDTO) -> AnyPublisher<Void, DmsError> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Combine
import DataMappingModule
import DomainModule
import ErrorModule
import Foundation

public struct SigninUseCaseFake: SigninUseCase {
public init () {}

public func execute(req: SigninRequestDTO) -> AnyPublisher<DmsFeatures, DmsError> {
if req.accountID == "baekteun" && req.password == "baekteun" {
return Just(DmsFeatures(
mealService: true,
noticeService: true,
pointService: true,
studyRoomService: false,
remainService: false
))
.setFailureType(to: DmsError.self)
.delay(for: 1, scheduler: DispatchQueue.main)
.eraseToAnyPublisher()
} else {
return Fail(error: DmsError.passwordMismatch)
.delay(for: 1, scheduler: DispatchQueue.main)
.eraseToAnyPublisher()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct StudentsRepositoryImpl: StudentsRepository {
self.remoteStudentsDataSource = remoteStudentsDataSource
}

public func signup(req: SignupRequestDTO) -> AnyPublisher<Void, DmsError> {
public func signup(req: SignupRequestDTO) -> AnyPublisher<DmsFeatures, DmsError> {
remoteStudentsDataSource.signup(req: req)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ import Foundation
public struct StudentsRepositoryStub: StudentsRepository {
public init() {}

public func signup(req: SignupRequestDTO) -> AnyPublisher<Void, DmsError> {
Just(()).setFailureType(to: DmsError.self)
.eraseToAnyPublisher()
public func signup(req: SignupRequestDTO) -> AnyPublisher<DmsFeatures, DmsError> {
Just(DmsFeatures(
mealService: true,
noticeService: true,
pointService: true,
studyRoomService: false,
remainService: false
))
.setFailureType(to: DmsError.self)
.eraseToAnyPublisher()
}

public func checkDuplicateAccountID(id: String) -> AnyPublisher<Void, DmsError> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Combine
import DataMappingModule
import DomainModule
import ErrorModule
import Foundation

public struct SignupUseCaseFake: SignupUseCase {
public init () {}

public func execute(req: SignupRequestDTO) -> AnyPublisher<DmsFeatures, DmsError> {
if req.accountID == "baekteun" && req.password == "baekteun" {
return Just(DmsFeatures(
mealService: true,
noticeService: true,
pointService: true,
studyRoomService: false,
remainService: false
))
.setFailureType(to: DmsError.self)
.delay(for: 1, scheduler: DispatchQueue.main)
.eraseToAnyPublisher()
} else {
return Fail(error: DmsError.passwordMismatch)
.delay(for: 1, scheduler: DispatchQueue.main)
.eraseToAnyPublisher()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct SignupUseCaseImpl: SignupUseCase {
self.studentsRepository = studentsRepository
}

public func execute(req: SignupRequestDTO) -> AnyPublisher<Void, DmsError> {
public func execute(req: SignupRequestDTO) -> AnyPublisher<DmsFeatures, DmsError> {
studentsRepository.signup(req: req)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Combine
import DomainModule
import DataModule
import NetworkModule
import DatabaseModule
@testable import KeychainModule

// swiftlint: disable function_body_length
final class AuthRepositoryImplSpec: QuickSpec {
Expand All @@ -14,27 +16,12 @@ final class AuthRepositoryImplSpec: QuickSpec {

beforeEach {
remoteAuthDS = RemoteAuthDataSourceStub()
sut = AuthRepositoryImpl(remoteAuthDataSource: remoteAuthDS)
sut = AuthRepositoryImpl(
remoteAuthDataSource: remoteAuthDS,
localAuthDataSource: LocalAuthDataSourceImpl(keychain: KeychainFake())
)
}
describe("AuthRepositoryImpl에서") {
context("signin()를 실행하면") {
it("request를 성공적으로 실행한다.") {
var success: Void?
var res: DmsFeatures?
sut.signin(req: .init(accountID: "", password: ""))
.sink { _ in } receiveValue: { item in
success = ()
res = item
}
.store(in: &bag)
expect { success }.toNotEventually(beNil())
expect { success }.toEventually(beVoid())
expect { res }.toNot(beNil())
expect { res?.mealService }.to(beFalse())
expect { res?.noticeService }.to(beFalse())
expect { res?.pointService }.to(beFalse())
}
}
context("verifyAuthCode()를 실행하면") {
it("request를 성공적으로 실행한다.") {
var success: Void?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@ final class SigninUseCaseImplSpec: QuickSpec {
sut = SigninUseCaseImpl(authRepository: repo)
}
describe("SigninUseCaseImpl에서") {
context("execute()를 실행하면") {
it("request를 성공적으로 실행한다.") {
var success: Void?
var res: DmsFeatures?
sut.execute(req: .init(accountID: "", password: ""))
.sink { _ in } receiveValue: { item in
success = ()
res = item
}
.store(in: &bag)
expect { success }.toNotEventually(beNil())
expect { success }.toEventually(beVoid())
expect { res }.toNot(beNil())
expect { res?.mealService }.to(beFalse())
expect { res?.noticeService }.to(beFalse())
expect { res?.pointService }.to(beFalse())
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class StudentsRepositoryImplSpec: QuickSpec {
describe("StudentsRepositoryImpl에서") {
context("signup()을 실행하면") {
it("request를 성공적으로 실행한다.") {
var success: Void?
var success: DmsFeatures?
sut.signup(
req: .init(
schoolCode: "",
Expand Down Expand Up @@ -91,7 +91,7 @@ final class StudentsRepositoryImplSpec: QuickSpec {
expect { success }.toNotEventually(beNil())
expect { success }.toEventually(beVoid())
expect { res }.toNotEventually(beNil())
expect { res }.toEventually(equal("abc*****@gmail.com"))
expect { res }.toEventually(equal("abcdef@gmail.com"))
}
}
context("fetchMyProfile()을 실행하면") {
Expand All @@ -112,7 +112,7 @@ final class StudentsRepositoryImplSpec: QuickSpec {
expect { res!.gcn }.toEventually(equal("2118"))
expect { res!.bonusPoint }.toEventually(equal(0))
expect { res!.minusPoint }.toEventually(equal(24))
expect { res!.phrase }.toEventually(equal("안녕하세요"))
expect { res!.phrase }.toEventually(equal("벌점이 12점이예요. 더 바른 생활을 위해 노력해주세요!"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class SignupUseCaseImplSpec: QuickSpec {
describe("SignupUseCaseImpl에서") {
context("execute()를 실행하면") {
it("request를 성공적으로 실행한다.") {
var success: Void?
var success: DmsFeatures?
sut.execute(
req: .init(
schoolCode: "",
Expand Down
12 changes: 12 additions & 0 deletions Projects/Services/DomainModule/Sources/Entities/DmsFeatures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@ import Foundation

public struct DmsFeatures: Equatable {
public init(
mealService: Bool,
noticeService: Bool,
pointService: Bool,
studyRoomService: Bool,
remainService: Bool
) {
self.mealService = mealService
self.noticeService = noticeService
self.pointService = pointService
self.studyRoomService = studyRoomService
self.remainService = remainService
}

public init() {
self.mealService = false
self.noticeService = false
self.pointService = false
self.studyRoomService = false
self.remainService = false
}

public let mealService: Bool
public let noticeService: Bool
public let pointService: Bool
public let studyRoomService: Bool
public let remainService: Bool
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import DataMappingModule
import ErrorModule

public protocol StudentsRepository {
func signup(req: SignupRequestDTO) -> AnyPublisher<Void, DmsError>
func signup(req: SignupRequestDTO) -> AnyPublisher<DmsFeatures, DmsError>
func checkDuplicateAccountID(id: String) -> AnyPublisher<Void, DmsError>
func checkDuplicateEmail(email: String) -> AnyPublisher<Void, DmsError>
func renewalPassword(req: RenewalPasswordRequestDTO) -> AnyPublisher<Void, DmsError>
Expand Down
Loading

0 comments on commit c7b89c3

Please sign in to comment.