File size: 1,784 Bytes
404b996
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# utils.py
"""
Utility functions for the app
"""
import streamlit as st
from typing import List, Dict, Any


def display_agent_results(agents: List[Dict[str, Any]], agent_type: str = "selling"):
    """Display agent recommendations in a clean format"""
    if not agents:
        st.warning("No agents found matching your criteria.")
        return

    for agent in agents:
        with st.container():
            col1, col2 = st.columns([2, 3])

            with col1:
                st.subheader(f"🏢 {agent['AgentName']}")
                st.write(f"**Office:** {agent['OfficeName']}")
                score_color = (
                    "green"
                    if agent["Score"] >= 80
                    else "orange" if agent["Score"] >= 60 else "red"
                )
                st.markdown(
                    f"<h3 style='color: {score_color}'>Score: {agent['Score']:.1f}%</h3>",
                    unsafe_allow_html=True,
                )

            with col2:
                metrics = agent["AgentMetrics"]
                cols = st.columns(4)
                cols[0].metric("Total Sales", metrics["TotalSales"])
                cols[1].metric(
                    "Avg Days on Market", f"{metrics['AvgDaysOnMarket']:.0f}"
                )
                # Convert ratio to percentage for display
                ratio_pct = metrics["AvgPriceToListRatio"] * 100
                cols[2].metric("Price/List Ratio", f"{ratio_pct:.1f}%")

                # Show AvgTransactionPrice only for buying agents
                if agent_type == "buying" and "AvgTransactionPrice" in metrics:
                    cols[3].metric(
                        "Avg Transaction", f"${metrics['AvgTransactionPrice']:,.0f}"
                    )

            st.divider()