Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhello0507 committed Oct 7, 2024
1 parent e8077ec commit 0a27d31
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.bestswlkh0310.graduating.graduatingserver.api.core

class VoidRes
class VoidRes
26 changes: 19 additions & 7 deletions Graduating-iOS/Data/Network/Foundation/AuthInterceptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ class AuthInterceptor: RequestInterceptor {
completion: @escaping (RetryResult) -> Void
) {
guard let response = request.task?.response as? HTTPURLResponse else {
completion(.doNotRetryWithError(error))
DispatchQueue.main.async {
completion(.doNotRetryWithError(error))
}
return
}

guard request.retryCount <= 2 else {
print("❌ AuthInterceptor - RetryCount가 2보다 큽니다")
completion(.doNotRetryWithError(APIError.refreshFailure))
DispatchQueue.main.async {
completion(.doNotRetryWithError(APIError.refreshFailure))
}
return
}

Expand All @@ -40,24 +44,32 @@ class AuthInterceptor: RequestInterceptor {
let tokenExpiredStatusCode = 403
guard response.statusCode == tokenExpiredStatusCode else {
print("❌ AuthInterceptor - HTTP statusCode is not \(tokenExpiredStatusCode)")
completion(.doNotRetryWithError(error))
DispatchQueue.main.async {
completion(.doNotRetryWithError(error))
}
return
}
guard let refreshToken = Sign.me.refreshToken else {
print("❌ AuthInterceptor - refreshToken is nil")
completion(.doNotRetryWithError(APIError.refreshFailure))
DispatchQueue.main.async {
completion(.doNotRetryWithError(APIError.refreshFailure))
}
return
}

AuthService.shared.refresh(
.init(refreshToken: refreshToken)
).sink {
if case .failure = $0 {
completion(.doNotRetryWithError(APIError.refreshFailure))
DispatchQueue.main.async {
completion(.doNotRetryWithError(APIError.refreshFailure))
}
}
} receiveValue: { token in
Sign.me.reissue(token.accessToken)
completion(.retry)
DispatchQueue.main.async {
Sign.me.reissue(token.accessToken)
completion(.retry)
}
}.store(in: &subscription)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct EditGraduatingYearView: View {
@StateObject private var viewModel = EditGraduatingYearViewModel()

private let path: Path
private let currentYear = Date.now[.year]!

public init(path: Path) {
self.path = path
Expand All @@ -25,13 +26,15 @@ extension EditGraduatingYearView {
.myFont(.title1B)
.foreground(Colors.Label.normal)
.frame(maxWidth: .infinity, alignment: .leading)
Picker("Graduating Year", selection: $viewModel.graduatingYear) {
ForEach(Date.now[.year]!...2100, id: \.self) { number in
Text(String(number))
.myFont(.headling2M)
if let limit = appState.currentUser.data?.school.type?.limit {
Picker("Graduating Year", selection: $viewModel.graduatingYear) {
ForEach((currentYear + 1)...(currentYear + limit), id: \.self) { number in
Text(String(number))
.myFont(.headling2M)
}
}
.pickerStyle(.wheel)
}
.pickerStyle(.wheel)
Spacer()
MyButton("다음", expanded: true, action: handleSubmit)
.padding(.bottom, 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Shared

final class EditGraduatingYearViewModel: ObservableObject {
private var subscriptions = Set<AnyCancellable>()
@Published var graduatingYear = Date.now[.year]!
@Published var graduatingYear = Date.now[.year]! + 1
@Published var editGraduatingYearFlow = Flow.idle

func editGraduatingYear() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ struct OnboardingThirdView {

@EnvironmentObject private var router: Router
@EnvironmentObject private var viewModel: OnboardingViewModel
@EnvironmentObject private var appState: AppState

private let path: Path
private let currentYear = Date.now[.year]!

public init(path: Path) {
self.path = path
Expand All @@ -23,13 +25,15 @@ extension OnboardingThirdView: View {
.myFont(.title1B)
.foreground(Colors.Label.normal)
.frame(maxWidth: .infinity, alignment: .leading)
Picker("Graduating Year", selection: $viewModel.graduatingYear) {
ForEach(1900...2100, id: \.self) { number in
Text(String(number))
.myFont(.headling2M)
if let limit = appState.currentUser.data?.school.type?.limit {
Picker("Graduating Year", selection: $viewModel.graduatingYear) {
ForEach((currentYear + 1)...(currentYear + limit), id: \.self) { number in
Text(String(number))
.myFont(.headling2M)
}
}
.pickerStyle(.wheel)
}
.pickerStyle(.wheel)
Spacer()
MyButton("다음", expanded: true, action: handleSubmit)
.padding(.bottom, 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class OnboardingViewModel: ObservableObject {
@Published var platformType: PlatformType?
@Published var email: String?
@Published var school: School?
@Published var graduatingYear = Date.now[.year] ?? 1900
@Published var graduatingYear = Date.now[.year]! + 1
@Published var nickname: String = ""
@Published var signUpFlow: Resource<Token> = .idle
@Published var signInFlow: Resource<Token> = .idle
Expand Down

0 comments on commit 0a27d31

Please sign in to comment.