import streamlit as st
from streamlit_extras.switch_page_button import switch_page
from st_pages import Page, show_pages, hide_pages

# Create an empty container
placeholder = st.empty()

actual_username = "email"
actual_password = "password"

# Insert a form in the container
with placeholder.form("login"):
    st.markdown("#### Enter your credentials")
    username = st.text_input("Email")
    password = st.text_input("Password", type="password")
    submit = st.form_submit_button("Login")

if submit and username == actual_username and password == actual_password:
    # If the form is submitted and the email and password are correct,
    # clear the form/container and display a success message
    placeholder.empty()
    st.success("Login successful")
    st.markdown(
    """
You can now use the analysis modules of for the management of a livestock farm.

"""
)
    show_pages([
    Page("Home.py","Home"),
    Page("pages/login.py","Login"),
    Page("pages/export_data.py","Annual Finance Performance"),
    Page("pages/pie_diagram.py","Income-Expenses"),
    Page("pages/select_income.py","Detailed Analys income"),
    Page("pages/criteria_new.py","Financial KPI")
    ])
    
    #if st.button('Financal KPI'):
     #   switch_page('pages/criteria_new.py')
        
elif submit and username != actual_username and password != actual_password:
    st.error("Login failed")
else:
    pass