import XMPPSwift

extension RegistrationState {
    static func reducer(state: inout RegistrationState, action: RegistrationAction) {
        switch action {
        case let .goTo(kind):
            state.navigation = kind

        case .targetJidUpdated(let jid):
            state.targetJid = jid
            if jid != nil {
                state.serverState = .connecting
            } else {
                state.serverState = .idle
            }

        case .serverStateChanged(let new):
            state.serverState = new

        case .clientStateChanged(let new):
            state.clientState = new

        default:
            break
        }
    }
}
