Skip to content

Commit b117d6e

Browse files
committed
chore :: [#111] 수락 에러 메세지 토스트 변경
1 parent d22f7de commit b117d6e

3 files changed

Lines changed: 21 additions & 45 deletions

File tree

Projects/Feature/AcceptFeature/Sources/AcceptReducer.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ComposableArchitecture
22
import AcceptDomainInterface
3+
import PiCK_iOS_DesignSystem
34

45
public struct AcceptReducer: Reducer {
56
private let getAllApplicationsUseCase: any GetAllApplicationsUseCaseProtocol
@@ -53,9 +54,9 @@ public struct AcceptReducer: Reducer {
5354
public var currentClassNum: Int = 5
5455
public var currentFloor: Int = 1
5556
public var currentType: ApplicationType = .outgoing
56-
public var toastMessage: String? = nil
57-
public var showToast: Bool = false
58-
public var shouldDismiss: Bool = false
57+
public var showAlert = false
58+
public var alertSuccessType: SuccessType = .success
59+
public var alertMessage: String = ""
5960

6061
public init() {}
6162
}
@@ -70,7 +71,7 @@ public struct AcceptReducer: Reducer {
7071
case approveSelectedApplications
7172
case rejectSelectedApplications
7273
case updateStatusResponse(Result<String, Error>)
73-
case hideToast
74+
case dismissAlert
7475
}
7576

7677
public var body: some Reducer<State, Action> {
@@ -226,7 +227,7 @@ public struct AcceptReducer: Reducer {
226227
switch result {
227228
case .success:
228229
await send(.updateStatusResponse(.success("\(count)명의 \(typeText) 거절이 완료되었습니다!")))
229-
case .failure(let error):
230+
case let .failure(error):
230231
await send(.updateStatusResponse(.failure(error)))
231232
}
232233
}
@@ -238,20 +239,19 @@ public struct AcceptReducer: Reducer {
238239
removedIds.contains(item.id)
239240
}
240241
state.selectedItemIds = []
241-
state.toastMessage = message
242-
state.showToast = true
243-
state.shouldDismiss = true
242+
state.alertMessage = message
243+
state.showAlert = true
244244
return .none
245245

246246
case .updateStatusResponse(.failure):
247247
state.isLoading = false
248-
state.toastMessage = "처리에 실패했습니다"
249-
state.showToast = true
248+
state.alertMessage = "처리를 실패했습니다"
249+
state.showAlert = true
250+
state.alertSuccessType = .fail
250251
return .none
251252

252-
case .hideToast:
253-
state.showToast = false
254-
state.toastMessage = nil
253+
case .dismissAlert:
254+
state.showAlert = false
255255
return .none
256256
}
257257
}

Projects/Feature/AcceptFeature/Sources/Scene/AcceptView.swift

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -254,38 +254,14 @@ public struct AcceptView: View {
254254
}
255255
}
256256

257-
if viewStore.showToast, let message = viewStore.toastMessage {
258-
VStack {
259-
Spacer()
260-
261-
HStack(spacing: 12) {
262-
Image(systemName: "checkmark.circle.fill")
263-
.foregroundColor(.Primary.primary500)
264-
.font(.system(size: 20))
265-
266-
Text(message)
267-
.pickText(type: .body1, textColor: .Normal.black)
268-
}
269-
.padding(.horizontal, 16)
270-
.frame(height: 48)
271-
.background(Color.Gray.gray50)
272-
.cornerRadius(24)
273-
.shadow(color: Color.black.opacity(0.1), radius: 10, x: 0, y: 4)
274-
.padding(.bottom, 40)
275-
.transition(.move(edge: .bottom).combined(with: .opacity))
276-
.onAppear {
277-
DispatchQueue.main.asyncAfter(deadline: .now() + 2.5) {
278-
viewStore.send(.hideToast)
279-
}
280-
}
257+
if viewStore.showAlert {
258+
PiCKDisappearAlert(
259+
successType: viewStore.alertSuccessType,
260+
message: viewStore.alertMessage
261+
)
262+
.onDisappear {
263+
viewStore.send(.dismissAlert)
281264
}
282-
.zIndex(1000)
283-
.animation(.spring(response: 0.5, dampingFraction: 0.7), value: viewStore.showToast)
284-
}
285-
}
286-
.onChange(of: viewStore.shouldDismiss) { shouldDismiss in
287-
if shouldDismiss {
288-
dismiss()
289265
}
290266
}
291267
}

Projects/Feature/OutListFeature/Sources/OutListReducer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public struct OutListReducer: Reducer {
121121
state.alertMessage = "복귀가 완료되었습니다!"
122122
return loadOutList(floor: state.currentFloor)
123123

124-
case let .returnStudentsResponse(.failure(error)):
124+
case .returnStudentsResponse(.failure):
125125
state.showAlert = true
126126
state.alertSuccessType = .fail
127127
state.alertMessage = "복귀를 실패하였습니다"

0 commit comments

Comments
 (0)