SYNRG / src /ui /components /quick_account.py
cryogenic22's picture
Create src/ui/components/quick_account.py
5520738 verified
"""Quick account addition component for Streamlit"""
import streamlit as st
from typing import Dict, Any
def show_quick_account_form(db_service) -> None:
"""Display quick account addition form"""
with st.expander("➕ Add New Account"):
with st.form("quick_account_form"):
col1, col2 = st.columns(2)
with col1:
name = st.text_input("Account Name*", key="account_name")
industry = st.selectbox(
"Industry*",
["Technology", "Healthcare", "Financial Services",
"Manufacturing", "Retail", "Other"]
)
website = st.text_input("Website")
with col2:
annual_revenue = st.number_input(
"Annual Revenue ($M)",
min_value=0.0,
format="%f"
)
employee_count = st.number_input(
"Employee Count",
min_value=1,
step=1
)
status = st.selectbox(
"Status",
["active", "prospect", "inactive"],
index=0
)
submitted = st.form_submit_button("Add Account")
if submitted:
if not name or not industry:
st.error("Please fill in all required fields")
return
# Create account data
account_data = {
'name': name,
'industry': industry,
'website': website,
'annual_revenue': annual_revenue,
'employee_count': employee_count,
'status': status,
'account_owner_id': st.session_state.user['id'],
'region': st.session_state.user.get('region', 'North')
}
# Add account
try:
account_id = db_service.add_account(account_data)
st.success(f"Account '{name}' added successfully!")
# Trigger page refresh
st.rerun()
except Exception as e:
st.error(f"Error adding account: {str(e)}")