Spaces:
Running
Running
Commit ·
8302440
1
Parent(s): 620c0cb
Fix: Connect lease price slider to header display
Browse filesMove sidebar controls before header section so slider values
are available when rendering the LiiS Lease metric.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -93,51 +93,8 @@ selected_product = st.sidebar.selectbox(
|
|
| 93 |
config = products[selected_product]
|
| 94 |
|
| 95 |
# ============================================================
|
| 96 |
-
#
|
| 97 |
# ============================================================
|
| 98 |
-
product_info = config["product"]
|
| 99 |
-
retail_price = product_info.get("retail_price", 0)
|
| 100 |
-
lease_monthly = config["pricing"]["lease_monthly"]
|
| 101 |
-
lease_term = config["pricing"]["lease_term_months"]
|
| 102 |
-
total_lease_cost = lease_monthly * lease_term
|
| 103 |
-
|
| 104 |
-
# Create header with image and product info
|
| 105 |
-
header_col1, header_col2 = st.columns([1, 2])
|
| 106 |
-
|
| 107 |
-
with header_col1:
|
| 108 |
-
if "image_url" in product_info:
|
| 109 |
-
st.image(product_info["image_url"], width=280)
|
| 110 |
-
|
| 111 |
-
with header_col2:
|
| 112 |
-
st.subheader(product_info["name"])
|
| 113 |
-
st.caption(f"**{product_info['brand']}** | {product_info.get('safety_standard', '')}")
|
| 114 |
-
st.markdown(product_info["description"])
|
| 115 |
-
|
| 116 |
-
# Features list
|
| 117 |
-
if "features" in product_info:
|
| 118 |
-
with st.expander("Key Features", expanded=False):
|
| 119 |
-
for feature in product_info["features"]:
|
| 120 |
-
st.markdown(f"- {feature}")
|
| 121 |
-
|
| 122 |
-
# Price comparison
|
| 123 |
-
if retail_price > 0:
|
| 124 |
-
price_cols = st.columns(3)
|
| 125 |
-
with price_cols[0]:
|
| 126 |
-
st.metric("Retail Price", f"€{retail_price:,}")
|
| 127 |
-
with price_cols[1]:
|
| 128 |
-
st.metric("LiiS Lease", f"€{lease_monthly}/mo",
|
| 129 |
-
delta=f"€{total_lease_cost} total ({lease_term}mo)")
|
| 130 |
-
with price_cols[2]:
|
| 131 |
-
savings_vs_buy = retail_price - total_lease_cost
|
| 132 |
-
if savings_vs_buy > 0:
|
| 133 |
-
st.metric("vs Buying", f"Save €{savings_vs_buy:,}",
|
| 134 |
-
delta=f"{savings_vs_buy/retail_price*100:.0f}% less")
|
| 135 |
-
else:
|
| 136 |
-
st.metric("vs Buying", f"€{-savings_vs_buy:,} more",
|
| 137 |
-
help="Premium for flexibility and circularity")
|
| 138 |
-
|
| 139 |
-
st.markdown("---")
|
| 140 |
-
|
| 141 |
st.sidebar.markdown("---")
|
| 142 |
st.sidebar.header("Adjust Parameters")
|
| 143 |
|
|
@@ -193,6 +150,51 @@ customers_per_month = st.sidebar.slider(
|
|
| 193 |
help="Monthly customer acquisition rate",
|
| 194 |
)
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
# Derived values
|
| 197 |
mfg_cost = config["costs"]["manufacturing_unit_cost"]
|
| 198 |
refurb_a = config["costs"]["refurbishment"]["grade_a"]
|
|
|
|
| 93 |
config = products[selected_product]
|
| 94 |
|
| 95 |
# ============================================================
|
| 96 |
+
# SIDEBAR CONTROLS (must be before header to use slider values)
|
| 97 |
# ============================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
st.sidebar.markdown("---")
|
| 99 |
st.sidebar.header("Adjust Parameters")
|
| 100 |
|
|
|
|
| 150 |
help="Monthly customer acquisition rate",
|
| 151 |
)
|
| 152 |
|
| 153 |
+
# ============================================================
|
| 154 |
+
# PRODUCT HEADER (uses slider values)
|
| 155 |
+
# ============================================================
|
| 156 |
+
product_info = config["product"]
|
| 157 |
+
retail_price = product_info.get("retail_price", 0)
|
| 158 |
+
lease_term = config["pricing"]["lease_term_months"]
|
| 159 |
+
total_lease_cost = lease_price * lease_term # Uses slider value
|
| 160 |
+
|
| 161 |
+
# Create header with image and product info
|
| 162 |
+
header_col1, header_col2 = st.columns([1, 2])
|
| 163 |
+
|
| 164 |
+
with header_col1:
|
| 165 |
+
if "image_url" in product_info:
|
| 166 |
+
st.image(product_info["image_url"], width=280)
|
| 167 |
+
|
| 168 |
+
with header_col2:
|
| 169 |
+
st.subheader(product_info["name"])
|
| 170 |
+
st.caption(f"**{product_info['brand']}** | {product_info.get('safety_standard', '')}")
|
| 171 |
+
st.markdown(product_info["description"])
|
| 172 |
+
|
| 173 |
+
# Features list
|
| 174 |
+
if "features" in product_info:
|
| 175 |
+
with st.expander("Key Features", expanded=False):
|
| 176 |
+
for feature in product_info["features"]:
|
| 177 |
+
st.markdown(f"- {feature}")
|
| 178 |
+
|
| 179 |
+
# Price comparison
|
| 180 |
+
if retail_price > 0:
|
| 181 |
+
price_cols = st.columns(3)
|
| 182 |
+
with price_cols[0]:
|
| 183 |
+
st.metric("Retail Price", f"€{retail_price:,}")
|
| 184 |
+
with price_cols[1]:
|
| 185 |
+
st.metric("LiiS Lease", f"€{lease_price}/mo", # Uses slider value
|
| 186 |
+
delta=f"€{total_lease_cost} total ({lease_term}mo)")
|
| 187 |
+
with price_cols[2]:
|
| 188 |
+
savings_vs_buy = retail_price - total_lease_cost
|
| 189 |
+
if savings_vs_buy > 0:
|
| 190 |
+
st.metric("vs Buying", f"Save €{savings_vs_buy:,}",
|
| 191 |
+
delta=f"{savings_vs_buy/retail_price*100:.0f}% less")
|
| 192 |
+
else:
|
| 193 |
+
st.metric("vs Buying", f"€{-savings_vs_buy:,} more",
|
| 194 |
+
help="Premium for flexibility and circularity")
|
| 195 |
+
|
| 196 |
+
st.markdown("---")
|
| 197 |
+
|
| 198 |
# Derived values
|
| 199 |
mfg_cost = config["costs"]["manufacturing_unit_cost"]
|
| 200 |
refurb_a = config["costs"]["refurbishment"]["grade_a"]
|