feat: 상단에 최근 공지사항 표시
This commit is contained in:
@@ -97,6 +97,10 @@ struct MyPageView: View {
|
||||
CategoryButtonsView(
|
||||
isShowAuthView: $viewModel.isShowAuthView,
|
||||
isAuthenticated: viewModel.isAuth,
|
||||
showMessage: {
|
||||
viewModel.errorMessage = $0
|
||||
viewModel.isShowPopup = true
|
||||
},
|
||||
refresh: {
|
||||
viewModel.getMypage()
|
||||
}
|
||||
@@ -126,6 +130,7 @@ struct MyPageView: View {
|
||||
if !token.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
viewModel.getMypage()
|
||||
}
|
||||
viewModel.getLatestNotice()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +177,7 @@ struct MyPageHeaderView: View {
|
||||
if isShowButton {
|
||||
HStack(spacing: 24) {
|
||||
// Settings Icon
|
||||
Image(systemName: "ic_settings")
|
||||
Image("ic_settings")
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 24, height: 24)
|
||||
.onTapGesture {
|
||||
@@ -183,7 +188,6 @@ struct MyPageHeaderView: View {
|
||||
}
|
||||
.padding(.horizontal, 24)
|
||||
.padding(.vertical, 20)
|
||||
.background(Color.black)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,22 +363,30 @@ struct CategoryButtonsView: View {
|
||||
@Binding var isShowAuthView: Bool
|
||||
|
||||
let isAuthenticated: Bool
|
||||
let showMessage: (String) -> Void
|
||||
let refresh: () -> Void
|
||||
|
||||
var body: some View {
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 3), spacing: 14) {
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 4), spacing: 16) {
|
||||
CategoryButtonItem(icon: "ic_my_storage", title: "보관함") {
|
||||
AppState.shared.setAppStep(step: .myBox(currentTab: .orderlist))
|
||||
}
|
||||
|
||||
CategoryButtonItem(icon: "ic_my_block", title: "차단목록") {
|
||||
AppState.shared.setAppStep(step: .blockList)
|
||||
}
|
||||
if isAuthenticated {
|
||||
CategoryButtonItem(
|
||||
icon: "ic_my_coupon",
|
||||
title: "쿠폰등록"
|
||||
) {
|
||||
|
||||
CategoryButtonItem(
|
||||
icon: "ic_my_coupon",
|
||||
title: "쿠폰등록"
|
||||
) {
|
||||
if isAuthenticated {
|
||||
AppState.shared.setAppStep(step: .canCoupon(refresh: refresh))
|
||||
} else {
|
||||
showMessage("본인인증 후 등록합니다.")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
isShowAuthView = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,11 +402,11 @@ struct CategoryButtonsView: View {
|
||||
AppState.shared.setAppStep(step: .serviceCenter)
|
||||
}
|
||||
|
||||
if !isAuthenticated {
|
||||
CategoryButtonItem(
|
||||
icon: "ic_my_auth",
|
||||
title: "본인인증"
|
||||
) {
|
||||
CategoryButtonItem(
|
||||
icon: "ic_my_auth",
|
||||
title: isAuthenticated ? "인증완료" : "본인인증"
|
||||
) {
|
||||
if !isAuthenticated {
|
||||
isShowAuthView = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import Moya
|
||||
|
||||
enum NoticeApi {
|
||||
case getNotices
|
||||
case getLatestNotice
|
||||
}
|
||||
|
||||
extension NoticeApi: TargetType {
|
||||
@@ -21,6 +22,9 @@ extension NoticeApi: TargetType {
|
||||
switch self {
|
||||
case .getNotices:
|
||||
return "/notice"
|
||||
|
||||
case .getLatestNotice:
|
||||
return "/notice/latest"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +37,9 @@ extension NoticeApi: TargetType {
|
||||
case .getNotices:
|
||||
let parameters = ["timezone": TimeZone.current.identifier] as [String: Any]
|
||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||
|
||||
case .getLatestNotice:
|
||||
return .requestPlain
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,5 +17,9 @@ final class NoticeRepository {
|
||||
func getNotices() -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getNotices)
|
||||
}
|
||||
|
||||
func getLatestNotice() -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getLatestNotice)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user