func getSubAccountData() {
print("getting data")
let activityView = activityIndicatorView1()
activityView.startAnimating()
let db = Firestore.firestore()
let owner = Auth.auth().currentUser
if let owner = owner {
let docRef = db.collection("Businessowner").document(owner.uid)
docRef.collection("subaccount").document(subAccountId).addSnapshotListener({ (documentSnapshot, error) in
guard error == nil else {
print("error = \(String(describing: error))")
activityView.stopAnimating()
return
}
if documentSnapshot?.exists == nil {
print("Document is empty")
activityView.stopAnimating()
return
}
self.imageUrl = documentSnapshot?.get("image") as? String ?? ""
if self.imageUrl != "" {
self.profileImageView.sd_setImage(with: URL(string: self.imageUrl.replacingOccurrences(of: " ", with: "%20")))
}
self.nameLabel.text = documentSnapshot?.get("name") as? String ?? ""
self.emailLabel.text = documentSnapshot?.get("email") as? String ?? ""
self.phoneNumberLabel.text = documentSnapshot?.get("phoneNumber") as? String ?? ""
activityView.stopAnimating()
})
}
}