Spaces:
Sleeping
Sleeping
Update app.py
Browse filesAdded a button to add the code from the manual input into the new basket.
app.py
CHANGED
@@ -978,23 +978,34 @@ elif page == "💡 Recomendación de Artículos":
|
|
978 |
article_desc = productos[productos['ARTICULO'] == code]['DESCRIPCION'].values[0]
|
979 |
st.write(f"- {article_desc} (Código: {code})")
|
980 |
|
981 |
-
col1, col2 = st.columns([
|
982 |
-
|
983 |
-
with col2:
|
984 |
-
manual_code = st.text_input("Añadir código manualmente:", value="", key="manual_code")
|
985 |
-
|
986 |
|
|
|
987 |
with col1:
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
st.session_state['
|
995 |
-
st.
|
|
|
|
|
996 |
else:
|
997 |
-
st.warning("⚠️ No
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
998 |
elif st.session_state['recommendations_df'] is not None:
|
999 |
st.warning("⚠️ No se encontraron recomendaciones para la cesta proporcionada.")
|
1000 |
|
|
|
978 |
article_desc = productos[productos['ARTICULO'] == code]['DESCRIPCION'].values[0]
|
979 |
st.write(f"- {article_desc} (Código: {code})")
|
980 |
|
981 |
+
col1, col2 = st.columns([4, 1])
|
|
|
|
|
|
|
|
|
982 |
|
983 |
+
# Input manual del código de producto con el botón en la misma columna
|
984 |
with col1:
|
985 |
+
manual_code = st.text_input("Añadir código manualmente:", value="", key="manual_code")
|
986 |
+
|
987 |
+
# Botón para añadir el código manualmente ingresado, junto al input
|
988 |
+
with col2:
|
989 |
+
if st.button("➕", key="add_manual_code"):
|
990 |
+
if manual_code and manual_code not in st.session_state['new_basket']:
|
991 |
+
st.session_state['new_basket'].append(manual_code)
|
992 |
+
st.success(f"✓ El código {manual_code} ha sido añadido manualmente a la cesta.")
|
993 |
+
elif manual_code in st.session_state['new_basket']:
|
994 |
+
st.warning(f"⚠️ El código {manual_code} ya está en la cesta.")
|
995 |
else:
|
996 |
+
st.warning("⚠️ No se ha introducido un código válido.")
|
997 |
+
|
998 |
+
# Botón para añadir cesta al histórico
|
999 |
+
if st.button("📦 Añadir cesta al histórico"):
|
1000 |
+
if st.session_state['new_basket']:
|
1001 |
+
retroalimentacion(cestas, st.session_state['new_basket'])
|
1002 |
+
st.success("✓ La cesta ha sido añadida al histórico.")
|
1003 |
+
# Reset all session states
|
1004 |
+
st.session_state['new_basket'] = []
|
1005 |
+
st.session_state['recommendations_df'] = None
|
1006 |
+
st.session_state['selected_descriptions'] = []
|
1007 |
+
else:
|
1008 |
+
st.warning("⚠️ No hay artículos en la cesta para añadir.")
|
1009 |
elif st.session_state['recommendations_df'] is not None:
|
1010 |
st.warning("⚠️ No se encontraron recomendaciones para la cesta proporcionada.")
|
1011 |
|