diff --git a/SodaLive/Sources/MyPage/Auth/AuthResponse.swift b/SodaLive/Sources/MyPage/Auth/AuthResponse.swift new file mode 100644 index 0000000..50b269c --- /dev/null +++ b/SodaLive/Sources/MyPage/Auth/AuthResponse.swift @@ -0,0 +1,10 @@ +// +// AuthResponse.swift +// SodaLive +// +// Created by klaus on 2/3/25. +// + +struct AuthResponse: Decodable { + let gender: Int +} diff --git a/SodaLive/Sources/MyPage/MyPageViewModel.swift b/SodaLive/Sources/MyPage/MyPageViewModel.swift index ca990ef..6ab3925 100644 --- a/SodaLive/Sources/MyPage/MyPageViewModel.swift +++ b/SodaLive/Sources/MyPage/MyPageViewModel.swift @@ -81,12 +81,16 @@ final class MyPageViewModel: ObservableObject { do { let jsonDecoder = JSONDecoder() - let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) + let decoded = try jsonDecoder.decode(ApiResponse.self, from: responseData) - if decoded.success { - self.errorMessage = "본인인증이 완료되었습니다." - self.isShowPopup = true - self.getMypage() + if let data = decoded.data, decoded.success { + if data.gender == 0 { + UserDefaults.set(ContentType.FEMALE.rawValue, forKey: .contentPreference) + } else { + UserDefaults.set(ContentType.MALE.rawValue, forKey: .contentPreference) + } + AppState.shared.isChangeAdultContentVisible = true + AppState.shared.setAppStep(step: .splash) } else { if let message = decoded.message { self.errorMessage = message