Files
stonks-oracle/frontend/src/pages/Reports.tsx
T
Celes Renata 7e2343ec2c
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-2 Pipeline was successful
ci/woodpecker/push/build-1 Pipeline was successful
ci/woodpecker/push/build-3 Pipeline was successful
ci/woodpecker/push/finalize Pipeline was successful
Build and Push / lint-and-test (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.adapters.broker_adapter name:broker-adapter]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.aggregation.worker name:aggregation]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.extractor.worker name:extractor]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.ingestion.worker name:ingestion]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.lake_publisher.worker name:lake-publisher]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.parser.worker name:parser]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.recommendation.worker name:recommendation]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.scheduler.app name:scheduler]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.api.app:app --host 0.0.0.0 --port 8000 name:query-api]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.risk.app:app --host 0.0.0.0 --port 8000 name:risk]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.symbol_registry.app:app --host 0.0.0.0 --port 8000 name:symbol-registry]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.trading.app:app --host 0.0.0.0 --port 8000 name:trading-engine]) (push) Has been cancelled
Build and Push / build-dashboard (push) Has been cancelled
Build and Push / build-superset (push) Has been cancelled
Build and Push / integration-test (push) Has been cancelled
Build and Push / beta-gate (push) Has been cancelled
feat: add Reports page and detail view to frontend
- Reports list page with type filter (daily/weekly)
- Report detail page with all sections: P&L, recommendation accuracy,
  position performance table, risk metrics, model quality windows
- Executive summary card, validation warnings display
- Nav item under Trading group
- Routes: /reports and /reports/:id
2026-05-02 00:27:34 +00:00

80 lines
2.3 KiB
TypeScript

import { useState } from 'react';
import { useNavigate } from '@tanstack/react-router';
import { useReports } from '../api/hooks';
import { DataTable, type Column } from '../components/DataTable';
import { StatusBadge, LoadingSpinner } from '../components/ui';
import type { ReportListItem } from '../api/hooks';
export function ReportsPage() {
const navigate = useNavigate();
const [reportType, setReportType] = useState('');
const { data, isLoading } = useReports({
report_type: reportType || undefined,
limit: 50,
});
const columns: Column<ReportListItem>[] = [
{
key: 'report_type',
header: 'Type',
render: (r) => (
<span className="inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-surface-700 text-brand-300 capitalize">
{r.report_type}
</span>
),
},
{
key: 'period_start',
header: 'Period',
render: (r) =>
r.period_start === r.period_end
? r.period_start
: `${r.period_start}${r.period_end}`,
},
{
key: 'validation_status',
header: 'Validation',
render: (r) => <StatusBadge status={r.validation_status} />,
},
{
key: 'generated_at',
header: 'Generated',
render: (r) => (
<span className="text-xs text-gray-400">
{new Date(r.generated_at).toLocaleString()}
</span>
),
},
];
if (isLoading) return <LoadingSpinner />;
return (
<div>
<div className="mb-4 flex items-center justify-between">
<h1 className="text-xl font-semibold text-gray-100">
Trading Reports
</h1>
<select
value={reportType}
onChange={(e) => setReportType(e.target.value)}
className="rounded border border-surface-600 bg-surface-800 px-3 py-1.5 text-sm text-gray-200 focus:border-brand-500 focus:outline-none"
aria-label="Filter by report type"
>
<option value="">All Types</option>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
</select>
</div>
<DataTable<ReportListItem>
data={data ?? []}
columns={columns}
keyField="id"
onRowClick={(row) =>
navigate({ to: '/reports/$id', params: { id: row.id } })
}
/>
</div>
);
}