diff --git a/frontend/src/pages/IntentDashboard.tsx b/frontend/src/pages/IntentDashboard.tsx index e922eea1..c68c07b6 100644 --- a/frontend/src/pages/IntentDashboard.tsx +++ b/frontend/src/pages/IntentDashboard.tsx @@ -58,6 +58,7 @@ interface IntentStats { const IntentDashboard: React.FC = ({ title }) => { const [stats, setStats] = useState(null); const [loading, setLoading] = useState(true); + const [filterTab, setFilterTab] = useState('All'); const navigate = useNavigate(); useEffect(() => { @@ -193,17 +194,32 @@ const IntentDashboard: React.FC = ({ title }) => {
- {['All', 'Open', 'Billed', 'Received', 'Closed'].map((t, i) => ( - ))}
- {(!stats?.recentOrders || stats.recentOrders.length === 0) ? ( -
No recent orders
- ) : ( - stats.recentOrders.map(o => ( + {(() => { + const filtered = stats?.recentOrders?.filter(o => { + if (filterTab === 'All') return true; + if (filterTab === 'Open') return o.status === 'OPEN'; + if (filterTab === 'Billed') return o.status === 'BILLED'; + if (filterTab === 'Received') return o.status === 'RECEIVED'; + if (filterTab === 'Closed') return o.status === 'CLOSE' || o.status === 'CLOSED'; + return true; + }) || []; + + if (filtered.length === 0) { + return
No {filterTab.toLowerCase()} orders
; + } + + return filtered.map(o => (
#{o.purchaseId || o.id} @@ -211,11 +227,16 @@ const IntentDashboard: React.FC = ({ title }) => {
{o.date ? format(new Date(o.date), 'MMM dd, yyyy HH:mm') : 'N/A'} - {o.status} + {o.status}
- )) - )} + )); + })()}