Skip to content

Commit

Permalink
Merge pull request #78 from Team-Clody/network/#77-WrittingDiary
Browse files Browse the repository at this point in the history
[Feat/#77] 네트워크 반영
  • Loading branch information
kim-seonwoo authored Aug 25, 2024
2 parents 0e8ffe9 + 6a08100 commit a36d27b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ import Foundation

struct PostDiaryResponseDTO: Codable {
let createdAt: String
let replyType: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ private extension WritingDiaryViewController {
from: self.date,
format: "yyyy-MM-dd"
)
self.viewModel.postDiary(date: dateString, content: self.viewModel.diariesRelay.value, completion: {status in
self.viewModel.postDiary(date: dateString, content: self.viewModel.diariesRelay.value, completion: {statusCode,type in
self.hideLoadingIndicator()
switch status {
switch statusCode {
case .success:
self.navigationController?.pushViewController(ReplyWaitingViewController(date: self.date, isNew: true, isHomeBackButton: true), animated: true)
if type == "NO_REPLY" {
self.navigationController?.popViewController(animated: true)
} else {
self.navigationController?.pushViewController(ReplyWaitingViewController(date: self.date, isNew: true, isHomeBackButton: true), animated: true)
}
case .network:
self.showErrorAlert(isNetworkError: true)
case .unknowned:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ extension WritingDiaryViewModel {
self.isFirstRelay.accept(isFirst)
}

func postDiary(date: String, content: [String], completion: @escaping (NetworkViewJudge) -> ()) {
func postDiary(date: String, content: [String], completion: @escaping (NetworkViewJudge, String) -> ()) {
let provider = Providers.diaryRouter
let data = PostDiaryRequestDTO(date: date, content: content)

Expand All @@ -211,8 +211,8 @@ extension WritingDiaryViewModel {
case -1: dataStatus = .network
default: dataStatus = .unknowned
}
completion(dataStatus)
guard let data = data.data else { return }
completion(dataStatus, data.replyType)
}
}
}

0 comments on commit a36d27b

Please sign in to comment.