From 3af30c40e588adc9be77956ffebe26ae3f99494e Mon Sep 17 00:00:00 2001 From: Claude Code Date: Thu, 19 Mar 2026 20:37:32 -0700 Subject: [PATCH] =?UTF-8?q?feat(frontend-platform):=20=E2=9C=A8=20Introduc?= =?UTF-8?q?e=20admin=20query=20hook=20for=20admin-specific=20analytics=20f?= =?UTF-8?q?iltering=20in=20PnLPage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../src/hooks/useAdminQuery.ts | 15 ++++++- .../frontend-platform/src/pages/PnLPage.tsx | 42 ------------------- 2 files changed, 14 insertions(+), 43 deletions(-) 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} - - ))} - -