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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app.core.database import redis_client
|
| 2 |
+
|
| 3 |
+
def generate_ui(results_html: str = "", error_msg: str = "", prev_name: str = "", prev_size: str = "", prev_mode: str = "balanced", prev_gender: str = "unisex") -> str:
|
| 4 |
+
error_html = f'<div class="error">{error_msg}</div>' if error_msg else ''
|
| 5 |
+
status_text = "Real-Time Pricing Intelligence & Value Verification" if redis_client else "Security Protection Active | Core Memory Tracking"
|
| 6 |
+
status_color = "var(--accent-green)" if redis_client else "#f59e0b"
|
| 7 |
+
|
| 8 |
+
return f"""
|
| 9 |
+
<!DOCTYPE html>
|
| 10 |
+
<html>
|
| 11 |
+
<head>
|
| 12 |
+
<title>Tarz Price Scout</title>
|
| 13 |
+
<meta charset="UTF-8">
|
| 14 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 15 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 16 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 17 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 18 |
+
<style>
|
| 19 |
+
:root {{
|
| 20 |
+
--bg-main: #0a0c14; --card-bg: #131622; --input-bg: #1b1f32; --border-color: rgba(255, 255, 255, 0.08);
|
| 21 |
+
--text-main: #f3f4f6; --text-muted: #9ca3af; --accent-blue: #3b82f6; --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
|
| 22 |
+
--accent-green: #10b981; --glow-green: rgba(16, 185, 129, 0.2); --accent-gold: #f59e0b;
|
| 23 |
+
}}
|
| 24 |
+
* {{ box-sizing: border-box; }}
|
| 25 |
+
body {{
|
| 26 |
+
font-family: 'Inter', -apple-system, sans-serif;
|
| 27 |
+
padding: 40px 20px;
|
| 28 |
+
background: radial-gradient(circle at 50% 0%, #16192b 0%, #08090f 100%);
|
| 29 |
+
background-attachment: fixed;
|
| 30 |
+
color: var(--text-main);
|
| 31 |
+
max-width: 850px;
|
| 32 |
+
margin: auto;
|
| 33 |
+
line-height: 1.5;
|
| 34 |
+
-webkit-text-size-adjust: 100%;
|
| 35 |
+
}}
|
| 36 |
+
h2 {{ font-size: 28px; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 4px; color: #ffffff; display: flex; align-items: center; gap: 12px; }}
|
| 37 |
+
h3 {{ font-size: 18px; font-weight: 600; color: #ffffff; margin-top: 0; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }}
|
| 38 |
+
.status-line {{ display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 30px; background: rgba(255,255,255,0.02); padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border-color); }}
|
| 39 |
+
.status-pill {{ width: 8px; height: 8px; background: {status_color}; border-radius: 50%; box-shadow: 0 0 12px {status_color}; }}
|
| 40 |
+
.card {{ background: var(--card-bg); padding: 24px; border-radius: 16px; border: 1px solid var(--border-color); margin-bottom: 24px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); }}
|
| 41 |
+
.input-flex {{ display: flex; gap: 16px; margin-bottom: 20px; align-items: flex-end; }}
|
| 42 |
+
.input-group {{ display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }}
|
| 43 |
+
.input-group.size-group {{ flex-grow: 0; width: 140px; }}
|
| 44 |
+
.input-group.gender-group {{ flex-grow: 0; width: 105px; }}
|
| 45 |
+
.input-group.mode-group {{ flex-grow: 0; width: 175px; }}
|
| 46 |
+
label {{ min-height: 32px; display: flex; align-items: flex-end; margin-bottom: 8px; font-weight: 500; color: var(--text-muted); font-size: 13px; line-height: 1.2; }}
|
| 47 |
+
input[type="text"], select {{ background: var(--input-bg); border: 1px solid var(--border-color); color: white; padding: 14px 16px; border-radius: 10px; font-size: 15px; transition: all 0.3s ease; font-family: inherit; width: 100%; height: 50px; }}
|
| 48 |
+
.input-group.gender-group select {{ padding: 14px 22px 14px 12px; font-size: 14px; background-position: right 6px center; }}
|
| 49 |
+
select {{ cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>'); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }}
|
| 50 |
+
input[type="text"]:focus, select:focus {{ border-color: var(--accent-blue); outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }}
|
| 51 |
+
button {{ background: var(--accent-gradient); color: white; border: none; padding: 14px 24px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 15px; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2); font-family: inherit; }}
|
| 52 |
+
button:hover {{ transform: translateY(-1px); box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3); }}
|
| 53 |
+
ul {{ list-style-type: none; padding: 0; margin: 0; }}
|
| 54 |
+
li {{ background: rgba(255, 255, 255, 0.02); padding: 14px 18px; border-radius: 12px; margin-bottom: 12px; border: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 12px; transition: all 0.2s ease; }}
|
| 55 |
+
li:hover {{ border-color: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.04); }}
|
| 56 |
+
.deal-item-header {{ display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 16px; }}
|
| 57 |
+
.deal-item {{ border-left: 4px solid var(--accent-green); background: #161c2a; overflow: hidden; }}
|
| 58 |
+
.product-img {{ width: 52px; height: 52px; min-width: 52px; border-radius: 6px; object-fit: contain; aspect-ratio: 1 / 1; background: #0f111a; border: 1px solid var(--border-color); padding: 2px; }}
|
| 59 |
+
.deal-info {{ flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }}
|
| 60 |
+
.item-title {{ font-weight: 600; color: #ffffff; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }}
|
| 61 |
+
.meta-container {{ display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; margin-top: 2px; }}
|
| 62 |
+
.domain-badge {{ background: rgba(255, 255, 255, 0.05); color: #e5e7eb; font-size: 11px; font-weight: 500; padding: 2px 6px; border-radius: 4px; text-transform: lowercase; border: 1px solid var(--border-color); white-space: nowrap; }}
|
| 63 |
+
.size-badge {{ background: rgba(59, 130, 246, 0.1); color: #60a5fa; font-size: 11px; font-weight: 500; padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(59, 130, 246, 0.15); white-space: nowrap; }}
|
| 64 |
+
.rating-badge {{ background: rgba(245, 158, 11, 0.1); color: #fbbf24; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(245, 158, 11, 0.2); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }}
|
| 65 |
+
.value-badge {{ display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; }}
|
| 66 |
+
.value-badge.best-value {{ background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); box-shadow: 0 0 8px rgba(16, 185, 129, 0.1); }}
|
| 67 |
+
.value-badge.verified-retailer {{ background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }}
|
| 68 |
+
.small-link {{ color: var(--text-muted); text-decoration: none; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }}
|
| 69 |
+
.small-link:hover {{ text-decoration: underline; color: #60a5fa; }}
|
| 70 |
+
|
| 71 |
+
/* HOVER CAPABLE CLICKABLE RETAIL TAG WRAPPER SETS */
|
| 72 |
+
.price-tag {{ background: var(--accent-green); color: white; border-radius: 8px; font-weight: 700; font-size: 16px; text-align: center; white-space: nowrap; min-width: 80px; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.15); padding: 0; transition: transform 0.2s ease; }}
|
| 73 |
+
.price-tag:hover {{ transform: scale(1.03); background: #059669; }}
|
| 74 |
+
.price-tag a {{ display: block; color: white; text-decoration: none; padding: 8px 14px; width: 100%; height: 100%; }}
|
| 75 |
+
|
| 76 |
+
/* DYNAMIC TREND INDICATORS COLOR MATRICES */
|
| 77 |
+
.trend-indicator {{ font-size: 11px; font-weight: 700; font-family: monospace; margin-top: 4px; text-align: right; white-space: nowrap; }}
|
| 78 |
+
.trend-indicator.down {{ color: #ef4444; }} /* Red for Price Decreases (-) */
|
| 79 |
+
.trend-indicator.up {{ color: #10b981; }} /* Green for Price Increases (+) */
|
| 80 |
+
|
| 81 |
+
.error {{ color: #ef4444; background: rgba(239, 68, 68, 0.08); padding: 14px; border-radius: 10px; margin-bottom: 20px; border: 1px solid rgba(239, 68, 68, 0.2); font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }}
|
| 82 |
+
.inline-coupon {{ background: rgba(245, 158, 11, 0.05); border: 1px dashed rgba(245, 158, 11, 0.3); padding: 8px 12px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; width: 100%; margin-top: 4px; }}
|
| 83 |
+
details summary::-webkit-details-marker {{ display: none; }}
|
| 84 |
+
details summary {{ list-style: none; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); padding: 14px; border-radius: 12px; font-size: 14px; font-weight: 600; color: #ffffff; cursor: pointer; transition: all 0.2s ease; margin-top: 15px; }}
|
| 85 |
+
details summary:hover {{ background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.15); }}
|
| 86 |
+
.loader-box {{ display: none; margin-top: 20px; }}
|
| 87 |
+
.skeleton {{ background: linear-gradient(90deg, #1b1f32 25%, #252b47 50%, #1b1f32 75%); background-size: 200% 100%; animation: loading-shimmer 1.4s infinite linear; border-radius: 8px; }}
|
| 88 |
+
@keyframes loading-shimmer {{ 0% {{ background-position: 200% 0; }} 100% {{ background-position: -200% 0; }} }}
|
| 89 |
+
svg.icon {{ width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }}
|
| 90 |
+
@media (max-width: 700px) {{
|
| 91 |
+
body {{ padding: 20px 12px; }}
|
| 92 |
+
h2 {{ font-size: 22px; }}
|
| 93 |
+
.card {{ padding: 16px; border-radius: 12px; margin-bottom: 16px; }}
|
| 94 |
+
.input-flex {{ flex-direction: column; gap: 12px; margin-bottom: 16px; align-items: stretch; }}
|
| 95 |
+
.input-group.size-group, .input-group.gender-group, .input-group.mode-group {{ width: 100%; }}
|
| 96 |
+
label {{ min-height: auto; }}
|
| 97 |
+
.deal-item-header {{ flex-direction: column; align-items: flex-start; gap: 12px; }}
|
| 98 |
+
.product-img {{ width: 48px; height: 48px; min-width: 48px; }}
|
| 99 |
+
.deal-info {{ width: 100%; }}
|
| 100 |
+
.item-title {{ white-space: normal; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }}
|
| 101 |
+
.small-link {{ max-width: 100%; display: block; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }}
|
| 102 |
+
.price-tag {{ width: 100%; text-align: center; }}
|
| 103 |
+
button {{ padding: 12px 16px; font-size: 14px; }}
|
| 104 |
+
}}
|
| 105 |
+
</style>
|
| 106 |
+
<script>
|
| 107 |
+
function triggerLoadingState() {{
|
| 108 |
+
document.getElementById("submit-btn").style.display = "none";
|
| 109 |
+
document.getElementById("loader-zone").style.display = "block";
|
| 110 |
+
}}
|
| 111 |
+
</script>
|
| 112 |
+
</head>
|
| 113 |
+
<body>
|
| 114 |
+
<h2>
|
| 115 |
+
<svg class="icon" style="width:28px; height:28px; color:var(--accent-blue);" viewBox="0 0 24 24"><path d="M12 2L2 22h20L12 2zm0 3.99L19.53 19H4.47L12 5.99zM13 16h-2v2h2v-2zm0-6h-2v4h2v-4z"/></svg>
|
| 116 |
+
Tarz Price Scout
|
| 117 |
+
</h2>
|
| 118 |
+
<div class="status-line">
|
| 119 |
+
<div class="status-pill"></div>
|
| 120 |
+
<span>{status_text}</span>
|
| 121 |
+
</div>
|
| 122 |
+
{error_html}
|
| 123 |
+
<div class="card">
|
| 124 |
+
<h3>
|
| 125 |
+
<svg class="icon" style="color:var(--accent-blue);" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
|
| 126 |
+
Run On-Demand Scan
|
| 127 |
+
</h3>
|
| 128 |
+
<p style="font-size: 12px; color: var(--text-muted); margin-top: -10px; margin-bottom: 15px;">💡 Append an asterisk to force an engine refresh (e.g. <i>nike shorts *</i>)</p>
|
| 129 |
+
<form action="/search" method="post" onsubmit="triggerLoadingState()">
|
| 130 |
+
<div class="input-flex">
|
| 131 |
+
<div class="input-group">
|
| 132 |
+
<label>Enter Product Details OR Paste Product Link</label>
|
| 133 |
+
<input type="text" name="product_name" value="{prev_name}" placeholder="e.g., Creed Green Irish Tweed OR https://www.store.com/item" autocomplete="off" required>
|
| 134 |
+
</div>
|
| 135 |
+
<div class="input-group size-group">
|
| 136 |
+
<label>Size / Variant</label>
|
| 137 |
+
<input type="text" name="product_size" value="{prev_size}" placeholder="e.g., 3.4 oz, XL, 10.5" autocomplete="off">
|
| 138 |
+
</div>
|
| 139 |
+
<div class="input-group gender-group">
|
| 140 |
+
<label>Gender</label>
|
| 141 |
+
<select name="product_gender">
|
| 142 |
+
<option value="unisex" {"selected" if prev_gender == "unisex" else ""}>All</option>
|
| 143 |
+
<option value="mens" {"selected" if prev_gender == "mens" else ""}>Men's</option>
|
| 144 |
+
<option value="womens" {"selected" if prev_gender == "womens" else ""}>Women's</option>
|
| 145 |
+
<option value="kids" {"selected" if prev_gender == "kids" else ""}>Kids'</option>
|
| 146 |
+
</select>
|
| 147 |
+
</div>
|
| 148 |
+
<div class="input-group mode-group">
|
| 149 |
+
<label>Search Strategy</label>
|
| 150 |
+
<select name="search_mode">
|
| 151 |
+
<option value="broad" {"selected" if prev_mode == "broad" else ""}>Broad Exploration</option>
|
| 152 |
+
<option value="balanced" {"selected" if prev_mode == "balanced" else ""}>Standard Balanced</option>
|
| 153 |
+
<option value="exact" {"selected" if prev_mode == "exact" else ""}>Precision Match</option>
|
| 154 |
+
</select>
|
| 155 |
+
</div>
|
| 156 |
+
</div>
|
| 157 |
+
<button type="submit" id="submit-btn">
|
| 158 |
+
<svg class="icon" viewBox="0 0 24 24"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/></svg>
|
| 159 |
+
Execute Price Scout Sweep
|
| 160 |
+
</button>
|
| 161 |
+
<div id="loader-zone" class="loader-box">
|
| 162 |
+
<p style="color: var(--text-muted); font-size: 14px; margin-bottom: 15px; text-align: center;">⚡ Price Scout is assembling structural pricing matrices across real-time storage nodes...</p>
|
| 163 |
+
<div style="height: 64px; width: 100%; margin-bottom: 12px;" class="skeleton"></div>
|
| 164 |
+
<div style="height: 64px; width: 100%; margin-bottom: 12px;" class="skeleton"></div>
|
| 165 |
+
<div style="height: 64px; width: 100%;" class="skeleton"></div>
|
| 166 |
+
</div>
|
| 167 |
+
</form>
|
| 168 |
+
</div>
|
| 169 |
+
{results_html}
|
| 170 |
+
</body>
|
| 171 |
+
</html>
|
| 172 |
+
"""
|