Skip to content

Commit b0da345

Browse files
authored
Merge pull request #76 from MarketPlace-O2O-Platform/Feat#75/PaybackCouponButtonSeperate
[Feat] 마이쿠폰함의 환급 쿠폰 카테고리 영수증 제출 여부에 따라 구별
2 parents 4cfcd69 + 67a0ee8 commit b0da345

8 files changed

Lines changed: 70 additions & 38 deletions

File tree

MarketPlace.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
29D87F462DE85AC500CE9011 /* CheerCardCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D87F452DE85AC500CE9011 /* CheerCardCellViewModel.swift */; };
8888
29D87F4A2DE8629900CE9011 /* CircleCategoryTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D87F492DE8629900CE9011 /* CircleCategoryTabView.swift */; };
8989
29D87F832DE86D6900CE9011 /* MemberInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D87F822DE86D6900CE9011 /* MemberInfoModel.swift */; };
90+
29DAD79B2E72A6780087CA53 /* CouponCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29DAD79A2E72A6780087CA53 /* CouponCategory.swift */; };
9091
29E749322DEEA91100E765E0 /* MyCouponCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29E749312DEEA91100E765E0 /* MyCouponCellViewModel.swift */; };
9192
29E749342DEEABFA00E765E0 /* MyCouponResDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29E749332DEEABFA00E765E0 /* MyCouponResDto.swift */; };
9293
29E749362DEECFBA00E765E0 /* FavoriteMarketModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29E749352DEECFBA00E765E0 /* FavoriteMarketModel.swift */; };
@@ -261,6 +262,7 @@
261262
29D87F452DE85AC500CE9011 /* CheerCardCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheerCardCellViewModel.swift; sourceTree = "<group>"; };
262263
29D87F492DE8629900CE9011 /* CircleCategoryTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleCategoryTabView.swift; sourceTree = "<group>"; };
263264
29D87F822DE86D6900CE9011 /* MemberInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemberInfoModel.swift; sourceTree = "<group>"; };
265+
29DAD79A2E72A6780087CA53 /* CouponCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponCategory.swift; sourceTree = "<group>"; };
264266
29E749312DEEA91100E765E0 /* MyCouponCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCouponCellViewModel.swift; sourceTree = "<group>"; };
265267
29E749332DEEABFA00E765E0 /* MyCouponResDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCouponResDto.swift; sourceTree = "<group>"; };
266268
29E749352DEECFBA00E765E0 /* FavoriteMarketModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteMarketModel.swift; sourceTree = "<group>"; };
@@ -537,6 +539,7 @@
537539
29B3EBA62E03CE0D0095A310 /* UserDefaultsKeys.swift */,
538540
29B3EBA82E03CF800095A310 /* KeyChainKeys.swift */,
539541
29B5236E2E150C9300120AE3 /* CouponType.swift */,
542+
29DAD79A2E72A6780087CA53 /* CouponCategory.swift */,
540543
);
541544
path = Types;
542545
sourceTree = "<group>";
@@ -1187,6 +1190,7 @@
11871190
B28889A32D4BC9370040EC3F /* CouponResDtos.swift in Sources */,
11881191
29B523712E152C0100120AE3 /* UINavigationController+.swift in Sources */,
11891192
B207A25F2D54B18C0099A8DB /* MyCouponCell.swift in Sources */,
1193+
29DAD79B2E72A6780087CA53 /* CouponCategory.swift in Sources */,
11901194
29B5236F2E150C9300120AE3 /* CouponType.swift in Sources */,
11911195
290A71AD2E026969009AEAF8 /* TopClosingCouponResDto.swift in Sources */,
11921196
B215F2962DE6D77B00F53C51 /* AlertListView.swift in Sources */,

MarketPlace/Model/MembersCouponModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct MembersCouponModel: Codable, Identifiable {
1010
let description: String
1111
var used: Bool
1212
let couponType: String
13+
let isSubmit: Bool
1314
let deadLine: String?
1415
let expired: Bool
1516

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// CouponCategory.swift
3+
// MarketPlace
4+
//
5+
// Created by Bowon Han on 9/11/25.
6+
//
7+
8+
import Foundation
9+
10+
enum CouponCategory: CaseIterable {
11+
case payback, gift, ended
12+
13+
static let orderedCases: [CouponCategory] = [
14+
.payback, .gift, .ended
15+
]
16+
17+
init?(index: Int) {
18+
switch index {
19+
case 0: self = .payback
20+
case 1: self = .gift
21+
case 2: self = .ended
22+
default: return nil
23+
}
24+
}
25+
26+
func toString() -> String {
27+
switch self {
28+
case .payback, .gift: return "ISSUED"
29+
case .ended: return "ENDED"
30+
}
31+
}
32+
33+
func toUIName() -> String {
34+
switch self {
35+
case .payback: return "환급형 쿠폰"
36+
case .gift: return "증정형 쿠폰"
37+
case .ended: return "끝난 쿠폰"
38+
}
39+
}
40+
}

MarketPlace/Types/CouponStatus.swift

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,15 @@
88
import Foundation
99

1010
enum CouponStatus: String, CaseIterable {
11-
case issued, ended
12-
13-
init?(index: Int) {
14-
switch index {
15-
case 0: self = .issued
16-
case 1: self = .issued
17-
case 2: self = .ended
18-
default: return nil
19-
}
20-
}
21-
22-
func toString() -> String {
23-
switch self {
24-
case .issued: return "ISSUED"
25-
case .ended: return "ENDED"
26-
}
27-
}
11+
case beforeSubmitReceipt, beforePayback, beforeUsedCoupon, used, ended
2812

2913
func toUIName() -> String {
3014
switch self {
31-
case .issued: return "사용하러 가기"
32-
case .ended: return "사용완료"
15+
case .beforeSubmitReceipt: "환급하러 가기"
16+
case .beforePayback: "환급 진행 중"
17+
case .beforeUsedCoupon: "사용하러 가기"
18+
case .used: "사용 완료"
19+
case .ended: "기간 만료"
3320
}
3421
}
3522
}
36-

MarketPlace/View/MyPage/Components/CouponCategoryView.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ import SwiftUI
22

33
struct CouponCategoryView: View {
44
@Binding var selectedCategory: Int
5-
private let categories: [String] = ["환급형 쿠폰", "증정형 쿠폰", "끝난 쿠폰"]
65

76
var body: some View {
87
VStack(spacing: 0) {
98
HStack(spacing: 0) {
10-
ForEach(Array(categories.enumerated()), id: \.offset) { index, category in
9+
ForEach(Array(CouponCategory.orderedCases.enumerated()), id: \.offset) { index, category in
1110
Button(action: {
1211
selectedCategory = index
1312
}) {
1413
VStack(spacing: 5) {
15-
Text(category)
14+
Text(category.toUIName())
1615
.pretendardFont(size: 14, weight: .semibold)
1716
.foregroundColor(selectedCategory == index ? .black : Color(hex: "#A0A0A0"))
1817
.padding(.bottom, 9)

MarketPlace/View/MyPage/Components/MyCouponCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ struct MyCouponCell: View {
5050
}
5151
}, label: {
5252
Text(viewModel.couponStatusText)
53-
.foregroundStyle(viewModel.couponStatus==CouponStatus.issued ? .white : Color(hex: "#727272"))
53+
.foregroundStyle(viewModel.couponStatus==CouponStatus.beforeSubmitReceipt || viewModel.couponStatus==CouponStatus.beforeUsedCoupon ? .white : Color(hex: "#727272"))
5454
.pretendardFont(size: 14, weight: .semibold)
5555
.padding(.vertical, 15)
5656
.frame(maxWidth: .infinity)
5757
.background(
5858
RoundedRectangle(cornerRadius: 4)
59-
.fill(viewModel.couponStatus==CouponStatus.issued ? Color(hex: "#303030") : Color(hex: "#E0E0E0"))
59+
.fill(viewModel.couponStatus==CouponStatus.beforeSubmitReceipt || viewModel.couponStatus==CouponStatus.beforeUsedCoupon ? Color(hex: "#303030") : Color(hex: "#E0E0E0"))
6060
)
6161
})
6262
.padding(.horizontal ,20)

MarketPlace/View/MyPage/View/MyCouponView.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ struct MyCouponView: View {
5959
.navigationBarBackButtonHidden(true)
6060
.onAppear {
6161
Task {
62-
await viewModel.fetchMemberPaybackCoupon(type: CouponStatus(index: 0)?.toString() ?? "", memberCouponId: nil, size: nil)
62+
await viewModel.fetchMemberPaybackCoupon(type: CouponCategory(index: selectedCategoryIndex)?.toString() ?? "", memberCouponId: nil, size: nil)
6363
}
6464
}
6565
.onChange(of: selectedCategoryIndex) {
6666
Task {
6767
switch selectedCategoryIndex {
68-
case 0: await viewModel.fetchMemberPaybackCoupon(type: CouponStatus(index: 0)?.toString() ?? "", memberCouponId: nil, size: nil)
69-
case 1: await viewModel.fetchMemberCoupon(type: CouponStatus(index: 0)?.toString() ?? "", memberCouponId: nil, size: nil)
68+
case 0: await viewModel.fetchMemberPaybackCoupon(type: CouponCategory(index: selectedCategoryIndex)?.toString() ?? "", memberCouponId: nil, size: nil)
69+
case 1: await viewModel.fetchMemberCoupon(type: CouponCategory(index: selectedCategoryIndex)?.toString() ?? "", memberCouponId: nil, size: nil)
7070
case 2: await viewModel.fetchEndedCoupon()
7171
default:
7272
break
@@ -80,7 +80,16 @@ struct MyCouponView: View {
8080

8181
// MARK: - coupon Cell 생성
8282
private func makeCouponCell(for coupon: MembersCouponModel) -> some View {
83-
let status = CouponStatus(index: selectedCategoryIndex) ?? .issued
83+
var status: CouponStatus = .used
84+
85+
if coupon.used { status = .used }
86+
else if coupon.expired { status = .ended }
87+
else {
88+
if coupon.couponType == "GIFT" { status = .beforeUsedCoupon }
89+
else if coupon.isSubmit { status = .beforePayback }
90+
else { status = .beforeSubmitReceipt }
91+
}
92+
8493
let viewModel = MyCouponCellViewModel(coupon: coupon, couponStatus: status)
8594

8695
return MyCouponCell(viewModel: viewModel) {

MarketPlace/ViewModel/MyPage/MyCouponCellViewModel.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ final class MyCouponCellViewModel: ObservableObject {
2525
}
2626

2727
var couponStatusText: String {
28-
switch couponStatus {
29-
case .issued:
30-
return "사용하러 가기"
31-
case .ended:
32-
return "사용 완료"
33-
// case .expired:
34-
// return "기간 만료"
35-
}
28+
return couponStatus.toUIName()
3629
}
3730

3831
var formattedDeadline: String {
@@ -44,7 +37,7 @@ final class MyCouponCellViewModel: ObservableObject {
4437
}
4538

4639
var canUse: Bool {
47-
return couponStatus == .issued
40+
return couponStatus == .beforeSubmitReceipt || couponStatus == .beforeUsedCoupon
4841
}
4942

5043
func useMemberCoupon(memberCouponId: Int) async {

0 commit comments

Comments
 (0)