Skip to content

Commit ed80d39

Browse files
committed
♻️[refactor]: AttendanceCard 경고 아이콘 표시 여부 로직을 컴포넌트 외부로 분리
1 parent 2e97343 commit ed80d39

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

Attendance/Projects/Presentation/Presentation/Sources/CoreMember/AttandanceCheck/View/AttandanceCheckView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ extension AttandanceCheckView {
8686
attendanceCount: store.attendanceCount,
8787
lateCount: store.lateCount,
8888
absentCount: store.absentCount,
89-
isManager: true)
89+
showWarning: false
90+
)
9091
}
9192
.padding(.horizontal, 24)
9293
}

Attendance/Projects/Presentation/Presentation/Sources/Member/MemberMain/Reducer/MemberMain.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public struct MemberMain {
2424
@Shared(.appStorage("UserEmail")) var userEmail: String = ""
2525
var member: UserDTOMember? = nil
2626
var showWarningAlert: Bool = false
27+
28+
// 출석 현황
29+
var shouldShowAttendanceWarningIcon: Bool = false
30+
var isPresentAttendanceWarningAlert: Bool = false
2731
}
2832

2933
public enum Action: BindableAction, FeatureAction {
@@ -82,7 +86,19 @@ public struct MemberMain {
8286
state: inout State,
8387
action: View
8488
) -> Effect<Action> {
85-
89+
switch action {
90+
case .didTapAbesentButton:
91+
guard state.shouldShowAttendanceWarningIcon else {
92+
return .none
93+
}
94+
95+
state.isPresentAttendanceWarningAlert = true
96+
return .none
97+
98+
case .didTapDismissAlertButton:
99+
state.isPresentAttendanceWarningAlert = false
100+
return .none
101+
}
86102
}
87103

88104
private func handleInnerAction(

Attendance/Projects/Presentation/Presentation/Sources/Member/MemberMain/View/MemberMainView.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ struct MemberMainView: View {
2929
.padding(.horizontal, 24)
3030
}
3131
}
32+
.customAlert(
33+
isPresented: store.isPresentAttendanceWarningAlert,
34+
title: "주의해주세요!",
35+
message: "2번 지각 시 노쇼비를 돌려받을 수 없습니다.",
36+
onConfirm: {
37+
store.send(.view(.didTapDismissAlertButton))
38+
}
39+
)
3240
.task {
3341
store.send(.async(.fetchCurrentUser))
3442
}
@@ -101,7 +109,7 @@ struct MemberMainView: View {
101109
attendanceCount: 8,
102110
lateCount: 1,
103111
absentCount: 2,
104-
isManager: false,
112+
showWarning: store.shouldShowAttendanceWarningIcon,
105113
onTapAbsentButton: {
106114
store.send(.view(.didTapAbesentButton))
107115
}

Attendance/Projects/Shared/DesignSystem/Sources/UI/Card/AttendanceCard.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ public struct AttendanceCard: View {
1111
private let attendanceCount: Int
1212
private let lateCount: Int
1313
private let absentCount: Int
14-
private let isManager: Bool
14+
private let showWarning: Bool
1515
private let onTapAbsentButton: (() -> Void)?
1616

1717
public init(
1818
attendanceCount: Int,
1919
lateCount: Int,
2020
absentCount: Int,
21-
isManager: Bool,
21+
showWarning: Bool,
2222
onTapAbsentButton: (() -> Void)? = nil
2323
) {
2424
self.attendanceCount = attendanceCount
2525
self.lateCount = lateCount
2626
self.absentCount = absentCount
27-
self.isManager = isManager
27+
self.showWarning = showWarning
2828
self.onTapAbsentButton = onTapAbsentButton
2929
}
3030

@@ -49,7 +49,7 @@ public struct AttendanceCard: View {
4949
CardItem(
5050
status: .absent,
5151
count: absentCount,
52-
showWarningIcon: isManager == false && absentCount > 0,
52+
showWarning: showWarning,
5353
onTap: onTapAbsentButton
5454
)
5555
}
@@ -68,18 +68,18 @@ public struct AttendanceCard: View {
6868
private struct CardItem: View {
6969
private let status: AttendanceStatus
7070
private let count: Int
71-
private let showWarningIcon: Bool
71+
private let showWarning: Bool
7272
private let onTap: (() -> Void)?
7373

7474
init(
7575
status: AttendanceStatus,
7676
count: Int,
77-
showWarningIcon: Bool = false,
77+
showWarning: Bool = false,
7878
onTap: (() -> Void)? = nil
7979
) {
8080
self.status = status
8181
self.count = count
82-
self.showWarningIcon = showWarningIcon
82+
self.showWarning = showWarning
8383
self.onTap = onTap
8484
}
8585

@@ -94,7 +94,7 @@ private struct CardItem: View {
9494
.pretendardFont(family: .Medium, size: 16)
9595
.foregroundStyle(.textSecondary)
9696

97-
if showWarningIcon {
97+
if showWarning {
9898
Image(asset: .danger)
9999
}
100100
}

0 commit comments

Comments
 (0)