from utils import *

global data_component

block = gr.Blocks()

with block:
    gr.Markdown(
        LEADERBORAD_INTRODUCTION
    )
    with gr.Tabs(elem_classes="tab-buttons") as tabs:
        # Table 1
        with gr.TabItem("📊 Science Leaderboard", elem_id="qa-tab-table1", id=1):
            with gr.Row():
                with gr.Accordion("Citation", open=False):
                    citation_button = gr.Textbox(
                        value=CITATION_BUTTON_TEXT,
                        label=CITATION_BUTTON_LABEL,
                        elem_id="citation-button",
                        lines=20,
                    )
            gr.Markdown(
                TABLE_INTRODUCTION
            )

            data_component=gr.components.Dataframe(
                value=get_df(), 
                headers=COLUMN_NAMES,
                type="pandas", 
                datatype=DATA_TITILE_TYPE,
                interactive=False,
                visible=True,
                )
            refresh_button = gr.Button("Refresh")
            refresh_button.click(fn=refresh_data, outputs=data_component)

        # table 2
        with gr.TabItem("📝 About", elem_id="qa-tab-table2", id=2):
            gr.Markdown(LEADERBORAD_INFO, elem_classes="markdown-text")
        
        # table 3 
        with gr.TabItem("🚀 Submit here! ", elem_id="mtheoremqa-tab-table", id=3):
            with gr.Row():
                gr.Markdown(SUBMIT_INTRODUCTION, elem_classes="markdown-text")

            with gr.Row():
                gr.Markdown("# ✉️✨ Submit your json file here!", elem_classes="markdown-text")

            with gr.Column():

                input_file = gr.components.File(label = "Click to Upload a json File", file_count="single", type='binary')
                submit_button = gr.Button("Submit Results")
    
                submission_result = gr.Markdown()
                submit_button.click(
                    add_new_eval,
                    inputs=[input_file],
                )


block.launch()