Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -123,6 +123,7 @@ if menu == "Poll":
|
|
123 |
if st.button("Next", key="step1_next") and name:
|
124 |
st.session_state.users.append(name)
|
125 |
st.session_state.show_drinks_dropdown = True # Initialize the dropdown state for Step 2
|
|
|
126 |
st.session_state.step = 2
|
127 |
|
128 |
# Step 2: Select Drinks
|
@@ -134,19 +135,19 @@ if menu == "Poll":
|
|
134 |
"Italiano", "Café con soja", "Té", "Manzanilla", "Nada"
|
135 |
]
|
136 |
|
137 |
-
#
|
138 |
if st.session_state.get("show_drinks_dropdown", True):
|
139 |
-
selected_drinks = st.multiselect("Choose your drinks:", drinks_options)
|
140 |
-
else:
|
141 |
-
st.write("Drinks selected successfully!")
|
142 |
|
143 |
-
if st.session_state.get("show_drinks_dropdown", True) and selected_drinks:
|
144 |
# If drinks are selected, hide the dropdown and show confirmation text
|
145 |
st.session_state.show_drinks_dropdown = False
|
146 |
|
147 |
if st.button("Next", key="step2_next") and not st.session_state.get("show_drinks_dropdown", True):
|
148 |
-
|
|
|
149 |
st.session_state.show_food_dropdown = True # Initialize the dropdown state for Step 3
|
|
|
150 |
st.session_state.step = 3
|
151 |
|
152 |
# Step 3: Select Food
|
@@ -157,18 +158,17 @@ if menu == "Poll":
|
|
157 |
"Palmera de chocolate blanco", "Yogurt", "Pincho de tortilla", "Nada"
|
158 |
]
|
159 |
|
160 |
-
#
|
161 |
if st.session_state.get("show_food_dropdown", True):
|
162 |
-
selected_food = st.multiselect("Choose your food:", food_options)
|
163 |
-
else:
|
164 |
-
st.write("Food selected successfully!")
|
165 |
|
166 |
-
if st.session_state.get("show_food_dropdown", True) and selected_food:
|
167 |
# If food is selected, hide the dropdown and show confirmation text
|
168 |
st.session_state.show_food_dropdown = False
|
169 |
|
170 |
if st.button("Save Selections", key="save_selections") and not st.session_state.get("show_food_dropdown", True):
|
171 |
-
|
|
|
172 |
df = pd.DataFrame(st.session_state.current_selections)
|
173 |
save_current_selection_to_file(df)
|
174 |
upload_temp_file_to_repo()
|
|
|
123 |
if st.button("Next", key="step1_next") and name:
|
124 |
st.session_state.users.append(name)
|
125 |
st.session_state.show_drinks_dropdown = True # Initialize the dropdown state for Step 2
|
126 |
+
st.session_state.selected_drinks = [] # Initialize an empty list to store selected drinks
|
127 |
st.session_state.step = 2
|
128 |
|
129 |
# Step 2: Select Drinks
|
|
|
135 |
"Italiano", "Café con soja", "Té", "Manzanilla", "Nada"
|
136 |
]
|
137 |
|
138 |
+
# Display the dropdown if `show_drinks_dropdown` is True
|
139 |
if st.session_state.get("show_drinks_dropdown", True):
|
140 |
+
st.session_state.selected_drinks = st.multiselect("Choose your drinks:", drinks_options)
|
|
|
|
|
141 |
|
142 |
+
if st.session_state.get("show_drinks_dropdown", True) and st.session_state.selected_drinks:
|
143 |
# If drinks are selected, hide the dropdown and show confirmation text
|
144 |
st.session_state.show_drinks_dropdown = False
|
145 |
|
146 |
if st.button("Next", key="step2_next") and not st.session_state.get("show_drinks_dropdown", True):
|
147 |
+
# Use the session state to access the selected drinks
|
148 |
+
st.session_state.current_selections.append({"Name": st.session_state.users[-1], "Drinks": st.session_state.selected_drinks})
|
149 |
st.session_state.show_food_dropdown = True # Initialize the dropdown state for Step 3
|
150 |
+
st.session_state.selected_food = [] # Initialize an empty list to store selected food
|
151 |
st.session_state.step = 3
|
152 |
|
153 |
# Step 3: Select Food
|
|
|
158 |
"Palmera de chocolate blanco", "Yogurt", "Pincho de tortilla", "Nada"
|
159 |
]
|
160 |
|
161 |
+
# Display the dropdown if `show_food_dropdown` is True
|
162 |
if st.session_state.get("show_food_dropdown", True):
|
163 |
+
st.session_state.selected_food = st.multiselect("Choose your food:", food_options)
|
|
|
|
|
164 |
|
165 |
+
if st.session_state.get("show_food_dropdown", True) and st.session_state.selected_food:
|
166 |
# If food is selected, hide the dropdown and show confirmation text
|
167 |
st.session_state.show_food_dropdown = False
|
168 |
|
169 |
if st.button("Save Selections", key="save_selections") and not st.session_state.get("show_food_dropdown", True):
|
170 |
+
# Use the session state to access the selected food
|
171 |
+
st.session_state.current_selections[-1]["Food"] = st.session_state.selected_food
|
172 |
df = pd.DataFrame(st.session_state.current_selections)
|
173 |
save_current_selection_to_file(df)
|
174 |
upload_temp_file_to_repo()
|