 import FirebaseAuth
 import RxSwift
 
-public enum TeamRepositoryError: Error {
-    case teamNotFound
-    case notInTeam
-}
-
 public protocol TeamRepository {
     func team(for teamID: String) -> Observable<Team?>
     func members(in teamID: String) -> Observable<CollectionChange<TeamMember>>

    func createTeam(_ team: Team, by member: TeamMember) -> Single<String>
    func join(to teamID: String, as member: TeamMember) -> Completable
    func leave(from teamID: String, as memberID: String) -> Completable
//    func updateMember(_ member: TeamMember, in teamID: String) -> Completable
//    func updateTeam(_ team: Team) -> Completable
}

public protocol TeamRepositoryResolver {

        }
    }

    public func updateMember(_ member: TeamMember, in teamID: String) -> Completable {
        let dataStore = self._resolver.resolveDataStore()
        return dataStore.write { writer in
            let teamPath = dataStore.collection("team").document(teamID)
            let teamMemberPath = teamPath.collection("member").document(member.memberID)
            writer.updateDocumentData(member.data, at: teamMemberPath)
        }
    }

    public func updateTeam(_ team: Team) -> Completable {
        let dataStore = self._resolver.resolveDataStore()
        return dataStore.write { writer in
            let teamPath = dataStore.collection("team").document(team.teamID)
            writer.updateDocumentData(team.data, at: teamPath)
        }
    }
}
