Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -925,28 +925,42 @@ def side():
|
|
| 925 |
|
| 926 |
search_query = st.text_input("Search by keyword", key="search_query")
|
| 927 |
st.write("or")
|
| 928 |
-
|
| 929 |
|
| 930 |
-
|
| 931 |
-
|
| 932 |
|
| 933 |
-
|
| 934 |
-
|
| 935 |
if st.button("Show TrustBuilders", key="show_trustbuilders"):
|
|
|
|
| 936 |
trustbuilders = fetch_trustbuilders(st.session_state.get("wix_user_id"))
|
| 937 |
|
| 938 |
-
|
|
|
|
|
|
|
|
|
|
| 939 |
for tb in trustbuilders:
|
|
|
|
| 940 |
bucket, text = tb.split(": ", 1) if ": " in tb else ("", tb)
|
| 941 |
-
if (selected_bucket == "Any" or bucket == selected_bucket) and (not search_query or search_query.lower() in text.lower()):
|
| 942 |
-
results.append(tb)
|
| 943 |
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 948 |
else:
|
| 949 |
st.write("No TrustBuilders found matching the criteria.")
|
|
|
|
| 950 |
|
| 951 |
# UI for saving TrustBuilders
|
| 952 |
st.subheader("Save TrustBuilders®")
|
|
|
|
| 925 |
|
| 926 |
search_query = st.text_input("Search by keyword", key="search_query")
|
| 927 |
st.write("or")
|
| 928 |
+
search_query1 = st.text_input("Search by Brand/Product/Person", key="search_query1")
|
| 929 |
|
| 930 |
+
# Dropdown for selecting a trust bucket
|
| 931 |
+
selected_bucket = st.selectbox("Select Trust Bucket", trust_buckets, key="selected_bucket")
|
| 932 |
|
| 933 |
+
# Button to show results
|
|
|
|
| 934 |
if st.button("Show TrustBuilders", key="show_trustbuilders"):
|
| 935 |
+
# Fetch trustbuilders
|
| 936 |
trustbuilders = fetch_trustbuilders(st.session_state.get("wix_user_id"))
|
| 937 |
|
| 938 |
+
# Initialize variable for a match
|
| 939 |
+
matching_trustbuilders = []
|
| 940 |
+
|
| 941 |
+
# Filter trustbuilders based on the criteria
|
| 942 |
for tb in trustbuilders:
|
| 943 |
+
# Split bucket and text
|
| 944 |
bucket, text = tb.split(": ", 1) if ": " in tb else ("", tb)
|
|
|
|
|
|
|
| 945 |
|
| 946 |
+
# Check if bucket matches or "Any" is selected
|
| 947 |
+
bucket_matches = selected_bucket == "Any" or bucket == selected_bucket
|
| 948 |
+
|
| 949 |
+
# Match keyword or brand/product/person search
|
| 950 |
+
keyword_match = search_query.lower() in text.lower() if search_query else False
|
| 951 |
+
additional_match = search_query1.lower() in text.lower() if search_query1 else False
|
| 952 |
+
|
| 953 |
+
# Append if all conditions are met
|
| 954 |
+
if bucket_matches and (keyword_match or additional_match):
|
| 955 |
+
matching_trustbuilders.append(tb)
|
| 956 |
+
|
| 957 |
+
# Display the first matching trustbuilder
|
| 958 |
+
if matching_trustbuilders:
|
| 959 |
+
st.write("### Result:")
|
| 960 |
+
st.write(f"- {matching_trustbuilders}")
|
| 961 |
else:
|
| 962 |
st.write("No TrustBuilders found matching the criteria.")
|
| 963 |
+
|
| 964 |
|
| 965 |
# UI for saving TrustBuilders
|
| 966 |
st.subheader("Save TrustBuilders®")
|