diff --git a/features/platform-analytics/frontend-platform/src/hooks/useAdminQuery.ts b/features/platform-analytics/frontend-platform/src/hooks/useAdminQuery.ts index 9875b8ace..4536b59ae 100644 --- a/features/platform-analytics/frontend-platform/src/hooks/useAdminQuery.ts +++ b/features/platform-analytics/frontend-platform/src/hooks/useAdminQuery.ts @@ -235,7 +235,20 @@ export function useErrorTrends(): UseQueryResult { } export function useRecentErrors(): UseQueryResult { - return useAdminQuery('admin/errors/recent'); + const { filterParams } = useAnalyticsFilters(); + + return useQuery({ + queryKey: ['admin', 'admin/errors/recent', filterParams.startDate, filterParams.endDate], + queryFn: async (): Promise => { + const url = new URL('/api/analytics/admin/errors/recent', window.location.origin); + url.searchParams.set('startDate', filterParams.startDate); + url.searchParams.set('endDate', filterParams.endDate); + const response = await fetch(url.toString()); + if (!response.ok) { throw new Error('Failed to fetch data'); } + const data = await response.json() as { errors: RecentError[] } | RecentError[]; + return Array.isArray(data) ? data : data.errors; + }, + }); } // ============================================================================ diff --git a/features/platform-analytics/frontend-platform/src/pages/PnLPage.tsx b/features/platform-analytics/frontend-platform/src/pages/PnLPage.tsx index 92f565b05..3ca6cdaf5 100644 --- a/features/platform-analytics/frontend-platform/src/pages/PnLPage.tsx +++ b/features/platform-analytics/frontend-platform/src/pages/PnLPage.tsx @@ -45,30 +45,6 @@ const HeaderActions = styled.div` align-items: center; `; -const PeriodSelector = styled.div` - display: flex; - gap: ${(props) => props.theme.spacing.sm}; - padding: ${(props) => props.theme.spacing.xs}; - background: ${(props) => props.theme.colors.surface}; - border-radius: ${(props) => props.theme.borderRadius.md}; -`; - -const PeriodButton = styled.button<{ $isActive: boolean }>` - padding: ${(props) => props.theme.spacing.sm} ${(props) => props.theme.spacing.md}; - border: none; - border-radius: ${(props) => props.theme.borderRadius.sm}; - font-size: ${(props) => props.theme.typography.fontSize.sm}; - font-weight: ${(props) => props.theme.typography.fontWeight.medium}; - cursor: pointer; - transition: all ${(props) => props.theme.transitions.fast}; - background: ${(props) => (props.$isActive ? props.theme.colors.primary.main : 'transparent')}; - color: ${(props) => (props.$isActive ? '#fff' : props.theme.colors.text.secondary)}; - - &:hover { - background: ${(props) => (props.$isActive ? props.theme.colors.primary.main : props.theme.colors.hover.surface)}; - } -`; - const AlertsContainer = styled.div` display: flex; gap: ${(props) => props.theme.spacing.md}; @@ -252,7 +228,6 @@ interface BreakdownRow { // ============================================================================ export const PnLPage = () => { - const [period, setPeriod] = useState<'this-month' | 'last-month' | 'quarter'>('this-month'); const [showExportMenu, setShowExportMenu] = useState(false); const { data: statement, isLoading } = usePnLStatement(); @@ -328,23 +303,6 @@ export const PnLPage = () => { - - {([ - ['this-month', 'This Month'], - ['last-month', 'Last Month'], - ['quarter', 'Quarter'], - ] as const).map(([value, label]) => ( - setPeriod(value)} - data-testid={`period-${value}`} - > - {label} - - ))} - -