import streamlit as st
from .SendEmail import send_email
import time


def join_us():
    st.title("Join Us")
    st.write("Thank you for your interest in the BuffTeks student organization! Please share your information below, \
        and our Faculty Advisor will send you an invitation to join our Discord channel. \
            If you have any questions, feel free to contact our Faculty Advisor, Dr. Carl Zhang, at czhang@wtamu.edu.")

    full_name = st.text_input("**Full Name**")
    wt_email = st.text_input("**WT Email**")
    major_list =  ["Accounting", "Computer Infromation Systems", "Economics", "Finance", "General Business", "Management", "Marketing", "Other"]
    stu_major = st.radio("**Major/Field of Study**",major_list)
    if stu_major == "Other":
        other_major = st.text_input("Please specify the other major")
        stu_major = other_major

    year_of_study_list = ["Freshman", "Sophomore", "Junior", "Senior", "Graduate"]
    stu_year = st.radio("**Year of Study**", year_of_study_list)

    skills_options = ["Programming", "Cybersecurity", "Web Development", "Mobile App Development", "machine Learning/AI", "Data Analysis", "Other"]
    skills_selection = st.multiselect(
        label= "**Technical Skills You Are Interested In (Please check all that apply)**", 
        options = skills_options,
        placeholder = "Choose all that apply")
    if "Other" in skills_selection:
        other_skill = st.text_input("**Please specify the other skills**")
        skills_selection.remove("Other")
        skills_selection.append(f"Other ({other_skill})")
        
    next_btn = st.button("Next")

    if next_btn:
        if "wtamu.edu" not in wt_email:
            st.warning("Please input your WT Email address to receive invitation")
        with st.spinner('Sending Email...'):
            send_email(sender_email="noreply@buffteks.org", password="cidm4360fall2024@*", to_email=wt_email, subject=f"Welcome to join ButtTeks, {full_name}!")
        st.balloons()
        st.success("Thanks for submitting your information, you will receive an invitation email shortly. \n Please contact Dr.Zhang (czhang@wtamu.edu) if you need any help.")
                
# @st.dialog("Check Email")
# def confirm_email(wt_email, full_name):
#     st.write(f"Please double-check your **WT Email** in order to receive our invitation: \n {wt_email}")
#     if st.button("Confirm & Submit"):
#         send_email(sender_email="noreply@buffteks.org", password="cidm4360fall2024@*", to_email=wt_email, subject=f"Welcome to join ButtTeks, {full_name}!")
#         st.rerun()
#         return True
        