""" profile_editor.py Profile editing component for Aqua Thistle Allows users to update their profile data in real-time """ import streamlit as st def render_profile_editor(profile, category): """ Render category-specific profile editor Allows users to update their data in real-time """ with st.expander("âœī¸ Edit Your Profile", expanded=False): st.markdown("Update your info below - changes apply instantly") # Finance fields if category == "Finance": st.markdown("##### 💰 Financial Data") col1, col2 = st.columns(2) with col1: new_budget = st.number_input( "Monthly Budget ($)", min_value=500, max_value=10000, value=profile['budget'], step=100, key="edit_budget", help="Your total monthly budget" ) if new_budget != profile['budget']: profile['budget'] = new_budget with col2: new_spend = st.number_input( "Current Spending ($)", min_value=0, max_value=20000, # High ceiling to allow any value value=profile['spend'], step=50, key="edit_spend", help="How much you've spent this month" ) if new_spend != profile['spend']: profile['spend'] = new_spend # Warning if over budget if profile['spend'] > profile['budget']: over_amount = profile['spend'] - profile['budget'] st.warning(f"âš ī¸ You're ${over_amount} over budget! Consider adjusting your spending or budget.") # Education fields elif category == "Education": st.markdown("##### 📚 Academic Data") col1, col2 = st.columns(2) with col1: new_exam_score = st.number_input( "Recent Exam Score", min_value=400, max_value=1600, value=profile['recent_exam'], step=10, key="edit_exam", help="Your most recent test score" ) if new_exam_score != profile['recent_exam']: profile['recent_exam'] = new_exam_score with col2: new_goal = st.number_input( "Target Score", min_value=400, max_value=1600, value=profile['goal'], step=50, key="edit_goal", help="Your goal score" ) if new_goal != profile['goal']: profile['goal'] = new_goal st.markdown("##### 📊 Subject Scores") cols = st.columns(5) subjects = ["Reading", "Writing", "Reasoning", "Algebra", "Geometry"] for i, subject in enumerate(subjects): with cols[i]: new_score = st.number_input( subject, min_value=0, max_value=400, value=profile['last_scores'].get(subject, 100), step=10, key=f"edit_score_{subject}", help=f"{subject} score" ) if new_score != profile['last_scores'].get(subject, 100): profile['last_scores'][subject] = new_score # Checkboxes for weaknesses st.markdown("##### âš ī¸ Areas Needing Work") col1, col2 = st.columns(2) with col1: math_weak = st.checkbox( "Math weakness", value=profile.get('math_weakness', False), key="edit_math_weak" ) profile['math_weakness'] = math_weak with col2: rushing = st.checkbox( "Rushing on tests", value=profile.get('rushing', False), key="edit_rushing" ) profile['rushing'] = rushing # Feedback if profile['recent_exam'] >= profile['goal']: st.success(f"🎉 You've reached your goal! Consider setting a higher target.") # Show sum of subject scores for reference subject_total = sum(profile['last_scores'].values()) if abs(subject_total - profile['recent_exam']) > 50: st.info(f"â„šī¸ Subject scores total: {subject_total} (Recent exam: {profile['recent_exam']})") # Family fields elif category == "Family": st.markdown("##### 👨‍👩‍👧 Family Tracking") col1, col2 = st.columns(2) # Initialize family metrics if not present if 'family_checkins' not in profile: profile['family_checkins'] = 2 if 'family_checkins_goal' not in profile: profile['family_checkins_goal'] = 3 if 'last_contact_days' not in profile: profile['last_contact_days'] = 3 if 'family_time_hours' not in profile: profile['family_time_hours'] = 4.5 with col1: checkin_goal = st.number_input( "Weekly Check-ins Goal", min_value=1, max_value=10, value=profile['family_checkins_goal'], step=1, key="edit_checkin_goal" ) profile['family_checkins_goal'] = checkin_goal checkins = st.number_input( "Weekly Check-ins Completed", min_value=0, max_value=20, # High ceiling to allow exceeding goal value=profile['family_checkins'], step=1, key="edit_checkins" ) profile['family_checkins'] = checkins with col2: last_contact = st.number_input( "Days Since Last Contact", min_value=0, max_value=365, value=profile['last_contact_days'], step=1, key="edit_last_contact" ) profile['last_contact_days'] = last_contact family_time = st.number_input( "Family Time (hrs/week)", min_value=0.0, max_value=40.0, value=profile['family_time_hours'], step=0.5, key="edit_family_time" ) profile['family_time_hours'] = family_time # Positive feedback if over goal if profile['family_checkins'] > profile['family_checkins_goal']: extra = profile['family_checkins'] - profile['family_checkins_goal'] st.success(f"🎉 You did {extra} extra check-in(s) this week!") # Friends fields elif category == "Friends": st.markdown("##### đŸ‘Ĩ Social Tracking") if 'social_budget' not in profile: profile['social_budget'] = 150 if 'social_spent' not in profile: profile['social_spent'] = 75 if 'hangouts_count' not in profile: profile['hangouts_count'] = 4 col1, col2 = st.columns(2) with col1: social_budget = st.number_input( "Social Budget ($)", min_value=0, max_value=1000, value=profile['social_budget'], step=10, key="edit_social_budget" ) profile['social_budget'] = social_budget social_spent = st.number_input( "Social Spending ($)", min_value=0, max_value=5000, # High ceiling value=profile['social_spent'], step=5, key="edit_social_spent" ) profile['social_spent'] = social_spent with col2: hangouts = st.number_input( "Hangouts This Month", min_value=0, max_value=30, value=profile['hangouts_count'], step=1, key="edit_hangouts" ) profile['hangouts_count'] = hangouts # Warning if over social budget if profile['social_spent'] > profile['social_budget']: over_amount = profile['social_spent'] - profile['social_budget'] st.warning(f"âš ī¸ You're ${over_amount} over your social budget!") # Weekend/Vacation fields elif category == "Weekend/Vacation": st.markdown("##### âœˆī¸ Vacation Planning") if 'vacation_fund' not in profile: profile['vacation_fund'] = 450 if 'vacation_goal' not in profile: profile['vacation_goal'] = 1000 col1, col2 = st.columns(2) with col1: vac_fund = st.number_input( "Vacation Fund ($)", min_value=0, max_value=5000, value=profile['vacation_fund'], step=50, key="edit_vac_fund" ) profile['vacation_fund'] = vac_fund with col2: vac_goal = st.number_input( "Vacation Goal ($)", min_value=500, max_value=10000, value=profile['vacation_goal'], step=100, key="edit_vac_goal" ) profile['vacation_goal'] = vac_goal # Global daily goals (shown in all categories) st.markdown("---") st.markdown("##### đŸŽ¯ Today's Goals Progress (%)") cols = st.columns(3) goal_types = ["Calories", "Money", "Steps"] for i, goal_type in enumerate(goal_types): with cols[i]: new_progress = st.slider( goal_type, 0, 100, profile['goals_today'].get(goal_type, 50), 5, key=f"edit_goal_{goal_type}" ) profile['goals_today'][goal_type] = new_progress # Contextual success message has_warnings = False if category == "Finance" and profile['spend'] > profile['budget']: has_warnings = True if category == "Friends" and profile['social_spent'] > profile['social_budget']: has_warnings = True if has_warnings: st.info("💡 Changes saved! Check warnings above.") else: st.success("✅ All changes saved - looking good!") # Reset button if st.button("🔄 Reset to Defaults", type="secondary", use_container_width=True): # Reset to default profile from llm_agent import get_default_profile default = get_default_profile() for key, value in default.items(): profile[key] = value st.rerun()