Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -284,15 +284,15 @@ def get_compatibility_message(pet):
|
|
284 |
return messages
|
285 |
|
286 |
# Function to display pet details page
|
287 |
-
def display_pet_details(pet_id):
|
288 |
pet = get_pet_details(pet_id)
|
289 |
if not pet:
|
290 |
st.error("Unable to retrieve pet details. Please try again.")
|
291 |
return
|
292 |
|
293 |
# Back button
|
294 |
-
if st.button("← Back to Search Results", key=f"
|
295 |
-
if st.session_state.selected_pet is not None:
|
296 |
st.session_state.selected_pet = None
|
297 |
st.rerun() # Force immediate rerun
|
298 |
# Pet name and status
|
@@ -397,7 +397,7 @@ def main():
|
|
397 |
with tab1:
|
398 |
# If a pet is selected, show details
|
399 |
if st.session_state.selected_pet:
|
400 |
-
display_pet_details(st.session_state.selected_pet)
|
401 |
else:
|
402 |
# Search form
|
403 |
with st.expander("Search Options", expanded=True):
|
@@ -502,7 +502,7 @@ def main():
|
|
502 |
else:
|
503 |
# Check if a pet is selected from favorites
|
504 |
if st.session_state.selected_pet:
|
505 |
-
display_pet_details(st.session_state.selected_pet)
|
506 |
else:
|
507 |
for pet in st.session_state.favorites:
|
508 |
st.markdown("---")
|
|
|
284 |
return messages
|
285 |
|
286 |
# Function to display pet details page
|
287 |
+
def display_pet_details(pet_id, context="search"):
|
288 |
pet = get_pet_details(pet_id)
|
289 |
if not pet:
|
290 |
st.error("Unable to retrieve pet details. Please try again.")
|
291 |
return
|
292 |
|
293 |
# Back button
|
294 |
+
if st.button("← Back to Search Results", key=f"back_{context}_{pet_id}"):
|
295 |
+
#if st.session_state.selected_pet is not None:
|
296 |
st.session_state.selected_pet = None
|
297 |
st.rerun() # Force immediate rerun
|
298 |
# Pet name and status
|
|
|
397 |
with tab1:
|
398 |
# If a pet is selected, show details
|
399 |
if st.session_state.selected_pet:
|
400 |
+
display_pet_details(st.session_state.selected_pet, context="search")
|
401 |
else:
|
402 |
# Search form
|
403 |
with st.expander("Search Options", expanded=True):
|
|
|
502 |
else:
|
503 |
# Check if a pet is selected from favorites
|
504 |
if st.session_state.selected_pet:
|
505 |
+
display_pet_details(st.session_state.selected_pet, context="search")
|
506 |
else:
|
507 |
for pet in st.session_state.favorites:
|
508 |
st.markdown("---")
|