11import ComposableArchitecture
2+ import PiCK_iOS_DesignSystem
23import HomeDomainInterface
34import AcceptDomainInterface
45import OutListDomainInterface
@@ -51,6 +52,9 @@ public struct HomeReducer: Reducer {
5152 public var floor : String = " 0층 "
5253 public var isHomeroomTeacher : Bool = false
5354 public var isSelfStudyTeacher : Bool = false
55+ public var showAlert : Bool = false
56+ public var alertSuccessType : SuccessType = . success
57+ public var alertMessage : String = " "
5458
5559 // 내부용 리스트
5660 var earlyReturnList : [ EarlyReturnEntity ] = [ ]
@@ -90,6 +94,8 @@ public struct HomeReducer: Reducer {
9094 case classroomMoveResponse( TaskResult < [ ClassroomMoveListEntity ] > )
9195 case outListResponse( TaskResult < [ OutListEntity ] > )
9296 case earlyReturnListResponse( TaskResult < [ EarlyReturnEntity ] > )
97+
98+ case dismissAlert
9399 }
94100
95101 public var body : some Reducer < State , Action > {
@@ -236,6 +242,10 @@ public struct HomeReducer: Reducer {
236242 }
237243
238244 case . updateStatusResponse( . success) :
245+ state. alertSuccessType = . success
246+ state. alertMessage = " 외출 처리를 성공했어요 "
247+ state. showAlert = true
248+
239249 let components = state. classroom. split ( separator: " - " ) . compactMap { Int ( $0) }
240250 if components. count == 2 {
241251 return . merge(
@@ -245,9 +255,16 @@ public struct HomeReducer: Reducer {
245255 }
246256 return . none
247257 case . updateStatusResponse( . failure) :
258+ state. alertSuccessType = . fail
259+ state. alertMessage = " 외출 처리를 실패했어요 "
260+ state. showAlert = true
248261 return . none
249262
250263 case . updateEarlyReturnStatusResponse( . success) :
264+ state. alertSuccessType = . success
265+ state. alertMessage = " 조기귀가 처리를 성공했어요 "
266+ state. showAlert = true
267+
251268 let components = state. classroom. split ( separator: " - " ) . compactMap { Int ( $0) }
252269 if components. count == 2 {
253270 return . merge(
@@ -257,6 +274,9 @@ public struct HomeReducer: Reducer {
257274 }
258275 return . none
259276 case . updateEarlyReturnStatusResponse( . failure) :
277+ state. alertSuccessType = . fail
278+ state. alertMessage = " 조기귀가 처리를 실패했어요 "
279+ state. showAlert = true
260280 return . none
261281
262282 case let . classroomMoveResponse( . success( students) ) :
@@ -284,6 +304,10 @@ public struct HomeReducer: Reducer {
284304 return . none
285305 case . earlyReturnListResponse( . failure) :
286306 return . none
307+
308+ case . dismissAlert:
309+ state. showAlert = false
310+ return . none
287311 }
288312 }
289313 }
0 commit comments