feat: 상단에 최근 공지사항 표시
This commit is contained in:
@@ -125,4 +125,30 @@ final class MyPageViewModel: ObservableObject {
|
||||
isShowPopup = true
|
||||
}
|
||||
}
|
||||
|
||||
func getLatestNotice() {
|
||||
noticeRepository.getLatestNotice()
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
}
|
||||
} receiveValue: {[unowned self] response in
|
||||
self.isLoading = false
|
||||
let responseData = response.data
|
||||
|
||||
do {
|
||||
let jsonDecoder = JSONDecoder()
|
||||
let decoded = try jsonDecoder.decode(ApiResponse<NoticeItem>.self, from: responseData)
|
||||
|
||||
if let data = decoded.data, decoded.success {
|
||||
self.latestNotice = data
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user