Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -154,25 +154,15 @@ with gr.Blocks() as demo:
|
|
| 154 |
const quantity = document.getElementById('quantity').value || 1;
|
| 155 |
const customDescription = document.getElementById('custom-description').value || "None";
|
| 156 |
|
| 157 |
-
//
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
selected_extras: selectedExtras,
|
| 167 |
-
quantity: quantity,
|
| 168 |
-
custom_description: customDescription
|
| 169 |
-
})
|
| 170 |
-
})
|
| 171 |
-
.then(response => response.json())
|
| 172 |
-
.then(data => {
|
| 173 |
-
document.querySelector("#cart-display").innerHTML = data.html;
|
| 174 |
-
closePopup();
|
| 175 |
-
});
|
| 176 |
}
|
| 177 |
</script>
|
| 178 |
""")
|
|
@@ -182,4 +172,11 @@ with gr.Blocks() as demo:
|
|
| 182 |
btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
|
| 183 |
btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
demo.launch()
|
|
|
|
| 154 |
const quantity = document.getElementById('quantity').value || 1;
|
| 155 |
const customDescription = document.getElementById('custom-description').value || "None";
|
| 156 |
|
| 157 |
+
// Trigger Gradio function via input updates
|
| 158 |
+
gradioApp().querySelector("#component-1 textarea").value = selectedDish;
|
| 159 |
+
gradioApp().querySelector("#component-2 textarea").value = spiceLevel;
|
| 160 |
+
gradioApp().querySelector("#component-3 textarea").value = JSON.stringify(selectedExtras);
|
| 161 |
+
gradioApp().querySelector("#component-4 input").value = quantity;
|
| 162 |
+
gradioApp().querySelector("#component-5 textarea").value = customDescription;
|
| 163 |
+
gradioApp().querySelector("#component-6 button").click();
|
| 164 |
+
|
| 165 |
+
closePopup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
}
|
| 167 |
</script>
|
| 168 |
""")
|
|
|
|
| 172 |
btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
|
| 173 |
btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
|
| 174 |
|
| 175 |
+
# Link Add to Cart functionality
|
| 176 |
+
gr.Button("Add", visible=False).click(
|
| 177 |
+
add_to_cart,
|
| 178 |
+
inputs=[gr.Textbox(), gr.Textbox(), gr.Textbox(), gr.Number(), gr.Textbox()],
|
| 179 |
+
outputs=cart_display
|
| 180 |
+
)
|
| 181 |
+
|
| 182 |
demo.launch()
|