import Combine

final class AccountsMiddleware {
    static let shared = AccountsMiddleware()

    func middleware(state _: AppState, action: AppAction) -> AnyPublisher<AppAction, Never> {
        switch action {
        case .accountsAction(.getAll):
            return Just(AppAction.accountsAction(.accountsListUpdated(accounts: [])))
                .eraseToAnyPublisher()

        case let .accountsAction(.accountsListUpdated(accounts)):
            return Just(AppAction.changeFlow(.welcome))
                .eraseToAnyPublisher()

        default:
            return Empty().eraseToAnyPublisher()
        }
    }
}
