Spaces:
Build error
Build error
Create components/sidebar.py
Browse files- components/sidebar.py +41 -0
components/sidebar.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from typing import Dict, Optional
|
| 3 |
+
|
| 4 |
+
def render_sidebar(case_manager) -> Optional[str]:
|
| 5 |
+
"""Render sidebar with case management"""
|
| 6 |
+
with st.sidebar:
|
| 7 |
+
st.title("Legal AI Assistant")
|
| 8 |
+
|
| 9 |
+
# Case creation
|
| 10 |
+
with st.expander("Create New Case"):
|
| 11 |
+
with st.form("new_case"):
|
| 12 |
+
title = st.text_input("Case Title")
|
| 13 |
+
description = st.text_area("Description")
|
| 14 |
+
case_type = st.selectbox(
|
| 15 |
+
"Case Type",
|
| 16 |
+
["Contract", "Employment", "Intellectual Property", "Litigation"]
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
if st.form_submit_button("Create Case"):
|
| 20 |
+
if title:
|
| 21 |
+
case_id = case_manager.create_case(title, description, case_type)
|
| 22 |
+
st.success("Case created successfully!")
|
| 23 |
+
return case_id
|
| 24 |
+
else:
|
| 25 |
+
st.error("Please enter a case title")
|
| 26 |
+
|
| 27 |
+
# Case selection
|
| 28 |
+
st.header("Cases")
|
| 29 |
+
cases = case_manager.get_all_cases()
|
| 30 |
+
|
| 31 |
+
if cases:
|
| 32 |
+
case_titles = {case['id']: case['title'] for case in cases}
|
| 33 |
+
selected_case = st.selectbox(
|
| 34 |
+
"Select Case",
|
| 35 |
+
options=list(case_titles.keys()),
|
| 36 |
+
format_func=lambda x: case_titles[x]
|
| 37 |
+
)
|
| 38 |
+
return selected_case
|
| 39 |
+
else:
|
| 40 |
+
st.info("No cases yet. Create your first case!")
|
| 41 |
+
return None
|