from interface.actions import * def _start_application(): with gr.Blocks() as app: gr.Markdown("## Agendamiento de citas") home_tab = gr.Tab('Home', visible=True) with home_tab: with gr.Row(): schedule_button = gr.Button(value="Agendar Cita") search_button = gr.Button(value="Buscar Cita") schedule_tab = gr.Tab('Agendamientos', visible=False) with schedule_tab: gr.Markdown("## Agendar cita") identification = gr.Textbox(label="Identificación") name = gr.Textbox(label="Nombres") last_name = gr.Textbox(label="Apellidos") age = gr.Number(label="Edad") with gr.Row(): available_dates = gr.State() day = gr.Dropdown(label='Fecha') hour = gr.Dropdown(label='Hora') with gr.Row(): schedule_back_button = gr.Button(value="Volver") save_appointment_button = gr.Button(value="Agendar Cita") search_tab = gr.Tab('Buscar', visible=False) with search_tab: gr.Markdown("## Buscar cita") with gr.Row(): date_dropdown = gr.Dropdown(label='Citas por', allow_custom_value=True) search_appointment_button = gr.Button(value="Buscar") appointments_df = gr.Dataframe(headers=['Cedula', 'Nombres', 'Hora']) search_back_button = gr.Button(value='Volver') # Start the appointment scheduling process schedule_button.click( make_appointment, None, [home_tab, schedule_tab, search_tab, available_dates, day, hour] ) # Go back to the home tab schedule_back_button.click( get_back_home, None, [home_tab, schedule_tab, search_tab] ) search_back_button.click( get_back_home, None, [home_tab, schedule_tab, search_tab] ) # Update the available hours when the selected day changes when scheduling an appointment day.change( get_available_hours, [day, available_dates], [hour] ) # Create the appointment save_appointment_button.click( create_appointment, [identification, name, last_name, age, day, hour], [home_tab, schedule_tab, search_tab] ) # Start the search appointment process search_button.click( search_appointments_days, None, [home_tab, schedule_tab, search_tab, date_dropdown] ) # Get all the appointments for the selected day search_appointment_button.click( search_appointments, date_dropdown, appointments_df ) app.launch() def init_application(): _start_application()