import streamlit as st
import time
from handler import *

def main():
  """ Creates a Streamlit page for code analysis """
  prompt=None
  code=None
  # Title and description
  st.set_page_config(page_title="CodeBatuk: Code Review Tool", page_icon="")
  st.title("Code Batuk")
  st.subheader("A code Analysis Tool")
  
  col1, col2 = st.columns([3,1])
  with col1:
    # Text input fields
    code = st.text_area(label="Enter your code here:", height=200)
  #prompt = st.text_area(label="Custom prompt (optional):")
  with col2:
    # Radio buttons for analysis type
    analysis_type = st.radio("Choose analysis type:", 
                                ("Code review", "Code refinement","Documentation", "Resume Writer"))

  # Submit button
  if st.button("Submit"):
    # Process the code and prompt based on analysis_type (implementation omitted for brevity)
    if analysis_type == "Code review":
      res=review_code(code, prompt)
      #st.text_area(label="Result",value=res, height=300)
      st.markdown(res['text'])
      time.sleep(1)
      #st.markdown("Hello ooo")

    elif analysis_type == "Code refinement":
      res=refine_code(code, prompt)
      #st.text_area(label="Result",value=res, height=300)
      st.markdown(res['text'])

    elif analysis_type == "Documentation":
      res=generate_documentation(code, prompt)
      #st.text_area(label="Result",value=res, height=300)
      st.markdown(res['text'])
    elif analysis_type == "Resume Writer":
      res=resume_writer(code, prompt)
      #st.text_area(label="Result",value=res, height=300)
      st.markdown(res['text'])
  
    st.success(f"Code analysis for {analysis_type} submitted successfully!")  

if __name__ == "__main__":
  main()
#git clone https://huggingface.co/spaces/imkhan107/codebatuk