feat: 쿠폰 등록 후 마이페이지가 새로고침 되도록 수정
This commit is contained in:
@@ -11,6 +11,8 @@ struct CanCouponView: View {
|
||||
|
||||
@StateObject var viewModel = CanCouponViewModel()
|
||||
|
||||
let refresh: () -> Void
|
||||
|
||||
var body: some View {
|
||||
BaseView(isLoading: $viewModel.isLoading) {
|
||||
GeometryReader { proxy in
|
||||
@@ -52,7 +54,7 @@ struct CanCouponView: View {
|
||||
.cornerRadius(10)
|
||||
.padding(.top, 21.3)
|
||||
.onTapGesture {
|
||||
viewModel.useCoupon()
|
||||
viewModel.useCoupon { refresh() }
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
@@ -116,7 +118,7 @@ struct CanCouponView: View {
|
||||
.padding(.horizontal, 6.7)
|
||||
.frame(width: geo.size.width - 66.7, alignment: .center)
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.background(Color(hex: "9970ff"))
|
||||
.background(Color.button)
|
||||
.foregroundColor(Color.white)
|
||||
.multilineTextAlignment(.leading)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
@@ -133,6 +135,6 @@ struct CanCouponView: View {
|
||||
|
||||
struct CanCouponView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CanCouponView()
|
||||
CanCouponView(refresh: {})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ final class CanCouponViewModel: ObservableObject {
|
||||
|
||||
@Published var couponNumber = ""
|
||||
|
||||
func useCoupon() {
|
||||
func useCoupon(onComplete: @escaping () -> Void) {
|
||||
if !isLoading {
|
||||
isLoading = true
|
||||
repository.useCanCoupon(couponNumber: couponNumber)
|
||||
@@ -46,6 +46,7 @@ final class CanCouponViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
onComplete()
|
||||
AppState.shared.back()
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user