"""A complete DyUI app that shows the `confirm` component.

Save it as app.py, then run:  dyui run app.py
"""
import dyui
from dyui import ui

app = dyui.App(title="Confirm demo", starters=["Show me"], persist=False)


@app.on_message
async def reply(msg: dyui.Message, chat: dyui.Chat):
    yield "Here is the `confirm` component."
    yield ui.Confirm("Book TAP 18:05 for $189?", confirm_label="Book", data={"flight": "TP123"})


@app.on_action("confirm")
async def on_confirm(action: dyui.Action, chat: dyui.Chat):
    # action.values holds what the user entered or chose; action.data is the static data
    yield f"Got `{action.name}` from **{action.label}** with values `{action.values}`."
