Skip to content

Commit 3a82407

Browse files
authored
AUTO_GENERATED surcharge status is handled. #64 (#65)
1 parent 23eef08 commit 3a82407

File tree

15 files changed

+220
-76
lines changed

15 files changed

+220
-76
lines changed

Surcharges/DataLayer/DTOs/Sources/ServerSide/Surcharge/SurchargeStatus.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
import Foundation
1010

1111
public enum SurchargeStatus: String, Codable, Equatable, Sendable {
12-
case UNKNOWN, REPORTED, CONFIRMED
12+
case UNKNOWN, REPORTED, CONFIRMED, AUTO_GENERATED, REJECTED
1313
}

Surcharges/DomainLayer/Entities/Sources/Surcharge/SurchargeStatus.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
import Foundation
1010

1111
public enum SurchargeStatus: String, Codable, Equatable, Sendable {
12-
case unknown, reported, confirmed
12+
case unknown, reported, confirmed, autoGenerated, rejected
1313
}

Surcharges/DomainLayer/UseCases/Sources/ConvertPlaceDTOtoEntity.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ struct ConvertDTOtoEntity {
3737
case .UNKNOWN: return .unknown
3838
case .REPORTED: return .reported
3939
case .CONFIRMED: return .confirmed
40+
case .AUTO_GENERATED: return .autoGenerated
41+
case .REJECTED: return .rejected
4042
}
4143
}
4244

Surcharges/DomainLayer/UseCases/Sources/Place/GetPlaceUsecase.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public struct GetPlaceUsecase<R: PlaceRepositoryProtocol>: GetPlaceUsecaseProtoc
3737
case .UNKNOWN: return .unknown
3838
case .REPORTED: return .reported
3939
case .CONFIRMED: return .confirmed
40+
case .AUTO_GENERATED: return .autoGenerated
41+
case .REJECTED: return .rejected
4042
case .none: return .unknown
4143
}
4244
}

Surcharges/DomainLayer/UseCases/Sources/Place/GetPlacesUsecase.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public struct GetPlacesUsecase<R: PlaceRepositoryProtocol>: GetPlacesUsecaseProt
5252
case .UNKNOWN: return .unknown
5353
case .REPORTED: return .reported
5454
case .CONFIRMED: return .confirmed
55+
case .AUTO_GENERATED: return .autoGenerated
56+
case .REJECTED: return .rejected
5557
case .none: return .unknown
5658
}
5759
}

Surcharges/PresentationLayer/Models/Sources/Surcharge/SurchargeStatus.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
import Foundation
1010

1111
public enum SurchargeStatus: Equatable, Sendable {
12-
case notDetermined, unknown, reported, confirmed
12+
case notDetermined, unknown, reported, confirmed, autoGenerated, rejected
1313
}

Surcharges/PresentationLayer/UIs/CommonUI/Sources/Text+extension/surchargeStatus.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public extension View {
2323
self._style(foreground: R.color.green800.color, background: R.color.green300.color)
2424
}
2525

26+
func surchargeStatusAutoGenerated() -> some View {
27+
self._style(foreground: R.color.yellow800.color, background: R.color.yellow300.color)
28+
}
29+
2630
private func _style(foreground: Color, background: Color) -> some View {
2731
self
2832
.foregroundStyle(foreground)

Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/PlaceView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ struct PlaceView: View {
3838
} else if _place.surcharge.status == .confirmed {
3939
Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())🎉" : "\(rate)%")
4040
.surchargeStatusConfirmed()
41+
42+
} else if _place.surcharge.status == .autoGenerated {
43+
Text(verbatim: rate == 0 ? "\(R.string.localizable.zeroRates())🎉" : "\(rate)%")
44+
.surchargeStatusAutoGenerated()
4145
}
4246
}
4347
}

Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Button/ContributeButton.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ struct ContributeButton: View {
2626
Button {
2727

2828
switch _surcharge.status {
29-
case .notDetermined, .reported:
29+
case .notDetermined, .reported, .rejected:
3030
break
31-
case .unknown, .confirmed:
31+
case .unknown, .confirmed, .autoGenerated:
3232
_action()
3333
}
3434

@@ -45,10 +45,10 @@ struct ContributeButton: View {
4545
private func buttonText() -> String {
4646

4747
switch _surcharge.status {
48-
case .notDetermined: return ""
48+
case .notDetermined, .rejected: return ""
4949
case .unknown: return "\(R.string.localizable.reportForUnknownButtonTitle())🙏🏻"
5050
case .reported: return ""
51-
case .confirmed: return "\(R.string.localizable.reportForConfirmedButtonTitle())🤔"
51+
case .confirmed, .autoGenerated: return "\(R.string.localizable.reportForConfirmedButtonTitle())🤔"
5252
}
5353
}
5454
}

Surcharges/PresentationLayer/UIs/PlaceDetail/Sources/Surcharge/SurchargeView.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct SurchargeView: View {
7575
.shimmering(active: _isLoading)
7676
.cornerRadius(5)
7777

78-
case .unknown:
78+
case .unknown, .rejected:
7979

8080
Text("\(R.string.localizable.surchargeStatusUnknownMessage())😞")
8181
.font(.headline)
@@ -102,6 +102,15 @@ struct SurchargeView: View {
102102
.font(.headline)
103103
.surchargeStatusConfirmed()
104104

105+
case .autoGenerated:
106+
107+
Text(verbatim: _rateText(rate: _surcharge.rate))
108+
.font(.largeTitle)
109+
110+
Text(verbatim: R.string.localizable.surchargeStatusAutoGenerated())
111+
.font(.headline)
112+
.surchargeStatusAutoGenerated()
113+
105114
}
106115

107116
if let updatedDate = _surcharge.updatedDate {
@@ -118,7 +127,7 @@ struct SurchargeView: View {
118127

119128
private func _rateText(rate: Double?) -> String {
120129
if let rate = rate {
121-
return rate == 0 ? "\(R.string.localizable.zeroRates)🎉" : "\(rate)%"
130+
return rate == 0 ? "\(R.string.localizable.zeroRates())🎉" : "\(rate)%"
122131
} else {
123132
return R.string.localizable.surchargeStatusUnknown()
124133
}

0 commit comments

Comments
 (0)