Skip to content

Commit

Permalink
[feat] 회원 탈퇴 기능 추가 (#43)
Browse files Browse the repository at this point in the history
- RootVC 설정
  • Loading branch information
BAEKYUJEONG committed Aug 30, 2024
1 parent ef381be commit 2554983
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion PLUV/MyPage/DeleteAccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,34 @@ class DeleteAccountViewController: UIViewController {
}

@objc func clickDeleteAccountButton() {
print("clickDeleteAccountButton 확인")
deleteAccountAPI()
}

private func deleteAccountAPI() {
let loginToken = UserDefaults.standard.string(forKey: APIService.shared.loginAccessTokenKey)!

let url = EndPoint.memberUnregister.path

APIService().postWithAccessToken(of: APIResponse<String>.self, url: url, parameters: nil, AccessToken: loginToken) { response in
switch response.code {
case 200:
let LoginVC = UINavigationController(rootViewController: LoginViewController())
self.setRootViewController(LoginVC)
self.navigationController?.popToRootViewController(animated: true)
default:
AlertController(message: response.msg).show()
}
}
}

func setRootViewController(_ viewController: UIViewController) {
guard let window = UIApplication.shared.connectedScenes
.filter({ $0.activationState == .foregroundActive })
.first(where: { $0 is UIWindowScene }) as? UIWindowScene else {
return
}

window.windows.first?.rootViewController = viewController
window.windows.first?.makeKeyAndVisible()
}
}

0 comments on commit 2554983

Please sign in to comment.