Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -180,18 +180,19 @@ def upload_to_firebase(user_id, file):
|
|
| 180 |
|
| 181 |
def fetch_trustbuilders(user_id):
|
| 182 |
"""
|
| 183 |
-
Fetch all TrustBuilders as
|
| 184 |
"""
|
| 185 |
try:
|
| 186 |
-
trustbuilders = db.child("users").child(user_id).child("TrustBuilders").get()
|
| 187 |
-
if
|
| 188 |
-
return
|
|
|
|
|
|
|
| 189 |
else:
|
| 190 |
-
|
| 191 |
-
return []
|
| 192 |
except Exception as e:
|
| 193 |
st.error(f"Error fetching TrustBuilders: {e}")
|
| 194 |
-
return
|
| 195 |
|
| 196 |
|
| 197 |
def delete_trustbuilder(user_id, trustbuilder_id):
|
|
@@ -788,13 +789,15 @@ def side():
|
|
| 788 |
trustbuilders = fetch_trustbuilders(st.session_state["wix_user_id"])
|
| 789 |
results = []
|
| 790 |
for trustbuilder_id, data in trustbuilders.items():
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
(
|
| 797 |
-
|
|
|
|
|
|
|
| 798 |
if results:
|
| 799 |
for result in results:
|
| 800 |
st.markdown(f"- {result}")
|
|
|
|
| 180 |
|
| 181 |
def fetch_trustbuilders(user_id):
|
| 182 |
"""
|
| 183 |
+
Fetch all TrustBuilders from Firebase and return as a list of dictionaries.
|
| 184 |
"""
|
| 185 |
try:
|
| 186 |
+
trustbuilders = db.child("users").child(user_id).child("TrustBuilders").get().val()
|
| 187 |
+
if isinstance(trustbuilders, dict): # If it's a dictionary
|
| 188 |
+
return trustbuilders
|
| 189 |
+
elif isinstance(trustbuilders, list): # If it's a list
|
| 190 |
+
return {str(idx): item for idx, item in enumerate(trustbuilders) if item} # Convert list to dict
|
| 191 |
else:
|
| 192 |
+
return {} # Return an empty dict if no data found
|
|
|
|
| 193 |
except Exception as e:
|
| 194 |
st.error(f"Error fetching TrustBuilders: {e}")
|
| 195 |
+
return {}
|
| 196 |
|
| 197 |
|
| 198 |
def delete_trustbuilder(user_id, trustbuilder_id):
|
|
|
|
| 789 |
trustbuilders = fetch_trustbuilders(st.session_state["wix_user_id"])
|
| 790 |
results = []
|
| 791 |
for trustbuilder_id, data in trustbuilders.items():
|
| 792 |
+
# Ensure data is a dictionary or handle accordingly
|
| 793 |
+
if isinstance(data, dict):
|
| 794 |
+
content = data.get("content", "")
|
| 795 |
+
bucket = data.get("bucket", "")
|
| 796 |
+
tb_brand = data.get("brand", "")
|
| 797 |
+
if ((selected_bucket == bucket or not selected_bucket) and
|
| 798 |
+
(not search_query or search_query.lower() in content.lower()) and
|
| 799 |
+
(not brand or brand.lower() in tb_brand.lower())):
|
| 800 |
+
results.append(f"{bucket}: {content}")
|
| 801 |
if results:
|
| 802 |
for result in results:
|
| 803 |
st.markdown(f"- {result}")
|