Download frontend/src/components/Sidebar.jsx from bhuvi3/CIOAgent: direct link, hf CLI and curl.
- Browser
- Download file 6.36 kB
-
https://huggingface.co/spaces/bhuvi3/CIOAgent/resolve/main/frontend/src/components/Sidebar.jsx
- Command line
-
hf download hf://spaces/bhuvi3/CIOAgent/frontend/src/components/Sidebar.jsx
-
curl -L -o Sidebar.jsx https://huggingface.co/spaces/bhuvi3/CIOAgent/resolve/main/frontend/src/components/Sidebar.jsx
6.36 kB
| import React from "react"; | |
| const GOAL_TYPES = [ | |
| "Retirement", | |
| "House Down Payment", | |
| "Education Fund", | |
| "Emergency Fund", | |
| "Wealth Building", | |
| "Debt Payoff", | |
| "Custom", | |
| ]; | |
| export default function Sidebar({ | |
| portfolio, | |
| setPortfolio, | |
| profile, | |
| setProfile, | |
| financialGoal, | |
| setFinancialGoal, | |
| onRunAnalysis, | |
| onRunAgents, | |
| onRunInsights, | |
| onSaveSnapshot, | |
| onExportPDF, | |
| loading, | |
| hasAnalysis, | |
| }) { | |
| const update = (field, value) => | |
| setPortfolio((p) => ({ ...p, [field]: value })); | |
| const updateProfile = (field, value) => | |
| setProfile((p) => ({ ...p, [field]: value })); | |
| const updateGoal = (field, value) => | |
| setFinancialGoal((g) => ({ ...g, [field]: value })); | |
| return ( | |
| <aside className="sidebar"> | |
| <h2>Settings</h2> | |
| <label>Tickers (comma-separated)</label> | |
| <input | |
| value={portfolio.tickers.join(", ")} | |
| onChange={(e) => | |
| update( | |
| "tickers", | |
| e.target.value.split(",").map((t) => t.trim().toUpperCase()).filter(Boolean), | |
| ) | |
| } | |
| /> | |
| <label>Benchmarks</label> | |
| <input | |
| value={portfolio.benchmarks.join(", ")} | |
| onChange={(e) => | |
| update( | |
| "benchmarks", | |
| e.target.value.split(",").map((b) => b.trim().toUpperCase()).filter(Boolean), | |
| ) | |
| } | |
| /> | |
| <label>Weights (comma-separated)</label> | |
| <input | |
| value={portfolio.weights.join(", ")} | |
| onChange={(e) => | |
| update( | |
| "weights", | |
| e.target.value.split(",").map((w) => parseFloat(w.trim())).filter((w) => !isNaN(w)), | |
| ) | |
| } | |
| /> | |
| <label>Start Date</label> | |
| <input | |
| type="date" | |
| className="date-input" | |
| value={portfolio.start_date} | |
| max={new Date().toISOString().split("T")[0]} | |
| onChange={(e) => update("start_date", e.target.value)} | |
| /> | |
| <label>Risk-Free Rate</label> | |
| <input | |
| type="number" | |
| step="0.005" | |
| min="0" | |
| max="1" | |
| value={portfolio.rf} | |
| onChange={(e) => update("rf", parseFloat(e.target.value))} | |
| /> | |
| <div className="slider-group"> | |
| <div className="slider-header"> | |
| <label>Simulations</label> | |
| <span className="slider-value">{portfolio.sims.toLocaleString()}</span> | |
| </div> | |
| <input | |
| type="range" | |
| className="styled-range" | |
| min="500" | |
| max="20000" | |
| step="500" | |
| value={portfolio.sims} | |
| onChange={(e) => update("sims", parseInt(e.target.value))} | |
| /> | |
| <div className="slider-ticks"> | |
| <span>500</span> | |
| <span>20,000</span> | |
| </div> | |
| </div> | |
| <div className="slider-group"> | |
| <div className="slider-header"> | |
| <label>Horizon (trading days)</label> | |
| <span className="slider-value">{portfolio.horizon}</span> | |
| </div> | |
| <input | |
| type="range" | |
| className="styled-range" | |
| min="21" | |
| max="756" | |
| step="21" | |
| value={portfolio.horizon} | |
| onChange={(e) => update("horizon", parseInt(e.target.value))} | |
| /> | |
| <div className="slider-ticks"> | |
| <span>21</span> | |
| <span>756</span> | |
| </div> | |
| </div> | |
| <hr /> | |
| <h3>Financial Profile</h3> | |
| <label>Total Assets ($)</label> | |
| <input | |
| type="number" | |
| step="10000" | |
| min="0" | |
| value={profile.total_assets} | |
| onChange={(e) => updateProfile("total_assets", parseFloat(e.target.value))} | |
| /> | |
| <label>Total Liabilities ($)</label> | |
| <input | |
| type="number" | |
| step="10000" | |
| min="0" | |
| value={profile.total_liabilities} | |
| onChange={(e) => | |
| updateProfile("total_liabilities", parseFloat(e.target.value)) | |
| } | |
| /> | |
| <label>Risk Tolerance</label> | |
| <select | |
| value={profile.risk_tolerance} | |
| onChange={(e) => updateProfile("risk_tolerance", e.target.value)} | |
| > | |
| <option>Conservative</option> | |
| <option>Moderate</option> | |
| <option>Aggressive</option> | |
| </select> | |
| <hr /> | |
| <h3>Financial Goal</h3> | |
| <label>Goal Type</label> | |
| <select | |
| value={financialGoal.goal_type} | |
| onChange={(e) => updateGoal("goal_type", e.target.value)} | |
| > | |
| {GOAL_TYPES.map((g) => ( | |
| <option key={g} value={g}> | |
| {g} | |
| </option> | |
| ))} | |
| </select> | |
| <label>Target Amount ($)</label> | |
| <input | |
| type="number" | |
| step="10000" | |
| min="0" | |
| value={financialGoal.target_amount} | |
| onChange={(e) => updateGoal("target_amount", parseFloat(e.target.value) || 0)} | |
| /> | |
| <label>Time Horizon (years)</label> | |
| <input | |
| type="number" | |
| step="1" | |
| min="1" | |
| max="50" | |
| value={financialGoal.time_horizon_years} | |
| onChange={(e) => updateGoal("time_horizon_years", parseInt(e.target.value) || 1)} | |
| /> | |
| <label>Initial Investment ($)</label> | |
| <input | |
| type="number" | |
| step="5000" | |
| min="0" | |
| value={financialGoal.initial_investment} | |
| onChange={(e) => updateGoal("initial_investment", parseFloat(e.target.value) || 0)} | |
| /> | |
| <label>Monthly Contribution ($)</label> | |
| <input | |
| type="number" | |
| step="100" | |
| min="0" | |
| value={financialGoal.monthly_contribution} | |
| onChange={(e) => updateGoal("monthly_contribution", parseFloat(e.target.value) || 0)} | |
| /> | |
| <div className="button-group"> | |
| <button className="btn primary" onClick={onRunAnalysis} disabled={!!loading}> | |
| Run Analysis | |
| </button> | |
| <button className="btn" onClick={onRunAgents} disabled={!!loading}> | |
| Run Agents | |
| </button> | |
| <button className="btn" onClick={onRunInsights} disabled={!!loading}> | |
| Run Insights | |
| </button> | |
| </div> | |
| {hasAnalysis && ( | |
| <div className="button-group" style={{ marginTop: "0.5rem" }}> | |
| <button className="btn" onClick={onSaveSnapshot} disabled={!!loading}> | |
| Save Snapshot | |
| </button> | |
| <button className="btn" onClick={onExportPDF} disabled={!!loading}> | |
| Export PDF | |
| </button> | |
| </div> | |
| )} | |
| </aside> | |
| ); | |
| } | |