Files
TankIC/TankiOffline/app/src/jsMain/kotlin/App/State/Reducers/PromoCodeReducer.kt
T

37 lines
1.4 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// PromoCodeReducer.kt —— 促销码切片(对应 module_10032 的 cZ 状态 + wZ.ysg)
//
// 证据链:
// 状态类 cZ:1 个字段,toString 名 "PromoCodeState(...)";copy 是 vsg(1 字段)。
// 默认:validateStatus = dZ() = NONE。
// 根委派:`Q_.ysg(t, n.gpy_1)`。
// reducer:
// vZ → `n.vsg((lZ(), Y_))`,状态置 WAIT(提交校验中)
// pZ → `n.vsg(t.xsg_1)`,写入服务端返回的状态
// `dZ()` 是 `fZ` 枚举:NONE / INVALID / WAIT / NOT_ACTIVATED / ACTIVATED。
package App.State.Reducers
import App.State.ActivatePromoCode
import App.State.SetCodeValidateStatus
/* ------------------------------------------------------------------ 枚举 */
/** 原 `fZ`:促销码校验状态。 */
enum class PromoCodeStatus { NONE, INVALID, WAIT, NOT_ACTIVATED, ACTIVATED }
/* ------------------------------------------------------------------ 状态 */
data class PromoCodeStateSlice(
val ValidateStatus: PromoCodeStatus = PromoCodeStatus.NONE,
)
/* ------------------------------------------------------------------ reducer */
fun ReducePromoCode(
State0: PromoCodeStateSlice,
Action: Any,
): PromoCodeStateSlice = when (Action) {
is ActivatePromoCode -> State0.copy(ValidateStatus = PromoCodeStatus.WAIT)
is SetCodeValidateStatus -> State0.copy(ValidateStatus = Action.promoCodeStatus as PromoCodeStatus)
else -> State0
}