@@ -8,12 +8,9 @@ import { useAccountMutations } from "@/features/accounts/hooks/use-accounts";
88import { AccountCards } from "@/features/dashboard/components/account-cards" ;
99import { DashboardSkeleton } from "@/features/dashboard/components/dashboard-skeleton" ;
1010import { OverviewTimeframeSelect } from "@/features/dashboard/components/filters/overview-timeframe-select" ;
11- import { RequestFilters } from "@/features/dashboard/components/filters/request-filters" ;
12- import { RecentRequestsTable } from "@/features/dashboard/components/recent-requests-table" ;
1311import { StatsGrid } from "@/features/dashboard/components/stats-grid" ;
1412import { UsageDonuts } from "@/features/dashboard/components/usage-donuts" ;
1513import { useDashboard } from "@/features/dashboard/hooks/use-dashboard" ;
16- import { useRequestLogs } from "@/features/dashboard/hooks/use-request-logs" ;
1714import { buildDashboardView } from "@/features/dashboard/utils" ;
1815import {
1916 DEFAULT_OVERVIEW_TIMEFRAME ,
@@ -22,10 +19,6 @@ import {
2219 type OverviewTimeframe ,
2320} from "@/features/dashboard/schemas" ;
2421import { useThemeStore } from "@/hooks/use-theme" ;
25- import { REQUEST_STATUS_LABELS } from "@/utils/constants" ;
26- import { formatModelLabel , formatSlug } from "@/utils/formatters" ;
27-
28- const MODEL_OPTION_DELIMITER = ":::" ;
2922
3023export function DashboardPage ( ) {
3124 const navigate = useNavigate ( ) ;
@@ -37,10 +30,9 @@ export function DashboardPage() {
3730 [ searchParams ] ,
3831 ) ;
3932 const dashboardQuery = useDashboard ( overviewTimeframe ) ;
40- const { filters, logsQuery, optionsQuery, updateFilters } = useRequestLogs ( ) ;
4133 const { resumeMutation } = useAccountMutations ( ) ;
4234
43- const isRefreshing = dashboardQuery . isFetching || logsQuery . isFetching ;
35+ const isRefreshing = dashboardQuery . isFetching ;
4436
4537 const handleRefresh = useCallback ( ( ) => {
4638 void queryClient . invalidateQueries ( { queryKey : [ "dashboard" ] } ) ;
@@ -77,63 +69,16 @@ export function DashboardPage() {
7769 ) ;
7870
7971 const overview = dashboardQuery . data ;
80- const logPage = logsQuery . data ;
8172
8273 const view = useMemo ( ( ) => {
83- if ( ! overview || ! logPage ) {
74+ if ( ! overview ) {
8475 return null ;
8576 }
86- return buildDashboardView ( overview , logPage . requests , isDark ) ;
87- } , [ overview , logPage , isDark ] ) ;
88-
89- const accountOptions = useMemo ( ( ) => {
90- const entries = new Map < string , { label : string ; isEmail : boolean } > ( ) ;
91- for ( const account of overview ?. accounts ?? [ ] ) {
92- const raw = account . displayName || account . email || account . accountId ;
93- const isEmail = ! ! account . email && raw === account . email ;
94- entries . set ( account . accountId , { label : raw , isEmail } ) ;
95- }
96- return ( optionsQuery . data ?. accountIds ?? [ ] ) . map ( ( accountId ) => {
97- const entry = entries . get ( accountId ) ;
98- return {
99- value : accountId ,
100- label : entry ?. label ?? accountId ,
101- isEmail : entry ?. isEmail ?? false ,
102- } ;
103- } ) ;
104- } , [ optionsQuery . data ?. accountIds , overview ?. accounts ] ) ;
105-
106- const apiKeyOptions = useMemo (
107- ( ) =>
108- ( optionsQuery . data ?. apiKeys ?? [ ] ) . map ( ( option ) => ( {
109- value : option . id ,
110- label : option . keyPrefix ? `${ option . name } · ${ option . keyPrefix } ` : option . name ,
111- } ) ) ,
112- [ optionsQuery . data ?. apiKeys ] ,
113- ) ;
114-
115- const modelOptions = useMemo (
116- ( ) =>
117- ( optionsQuery . data ?. modelOptions ?? [ ] ) . map ( ( option ) => ( {
118- value : `${ option . model } ${ MODEL_OPTION_DELIMITER } ${ option . reasoningEffort ?? "" } ` ,
119- label : formatModelLabel ( option . model , option . reasoningEffort ) ,
120- } ) ) ,
121- [ optionsQuery . data ?. modelOptions ] ,
122- ) ;
123-
124- const statusOptions = useMemo (
125- ( ) =>
126- ( optionsQuery . data ?. statuses ?? [ ] ) . map ( ( status ) => ( {
127- value : status ,
128- label : REQUEST_STATUS_LABELS [ status ] ?? formatSlug ( status ) ,
129- } ) ) ,
130- [ optionsQuery . data ?. statuses ] ,
131- ) ;
77+ return buildDashboardView ( overview , [ ] , isDark ) ;
78+ } , [ overview , isDark ] ) ;
13279
13380 const errorMessage =
13481 ( dashboardQuery . error instanceof Error && dashboardQuery . error . message ) ||
135- ( logsQuery . error instanceof Error && logsQuery . error . message ) ||
136- ( optionsQuery . error instanceof Error && optionsQuery . error . message ) ||
13782 null ;
13883
13984 return (
@@ -143,7 +88,7 @@ export function DashboardPage() {
14388 < div >
14489 < h1 className = "text-2xl font-semibold tracking-tight" > Dashboard</ h1 >
14590 < p className = "mt-1 text-sm text-muted-foreground" >
146- Overview, account health, and recent request logs .
91+ Overview and account health for your active pool .
14792 </ p >
14893 </ div >
14994 < div className = "flex items-center gap-2" >
@@ -171,16 +116,16 @@ export function DashboardPage() {
171116 < >
172117 < StatsGrid stats = { view . stats } />
173118
174- < UsageDonuts
175- primaryItems = { view . primaryUsageItems }
176- secondaryItems = { view . secondaryUsageItems }
177- primaryTotal = { overview ?. summary . primaryWindow . capacityCredits ?? 0 }
178- secondaryTotal = { overview ?. summary . secondaryWindow ?. capacityCredits ?? 0 }
179- primaryCenterValue = { view . primaryTotal }
180- secondaryCenterValue = { view . secondaryTotal }
181- safeLinePrimary = { view . safeLinePrimary }
182- safeLineSecondary = { view . safeLineSecondary }
183- />
119+ < UsageDonuts
120+ primaryItems = { view . primaryUsageItems }
121+ secondaryItems = { view . secondaryUsageItems }
122+ primaryTotal = { overview ?. summary . primaryWindow . capacityCredits ?? 0 }
123+ secondaryTotal = { overview ?. summary . secondaryWindow ?. capacityCredits ?? 0 }
124+ primaryCenterValue = { view . primaryTotal }
125+ secondaryCenterValue = { view . secondaryTotal }
126+ safeLinePrimary = { view . safeLinePrimary }
127+ safeLineSecondary = { view . safeLineSecondary }
128+ />
184129
185130 < section className = "space-y-4" >
186131 < div className = "flex items-center gap-3" >
@@ -189,51 +134,6 @@ export function DashboardPage() {
189134 </ div >
190135 < AccountCards accounts = { overview ?. accounts ?? [ ] } onAction = { handleAccountAction } />
191136 </ section >
192-
193- < section className = "space-y-4" >
194- < div className = "flex items-center gap-3" >
195- < h2 className = "text-[13px] font-medium uppercase tracking-wider text-muted-foreground" > Request Logs</ h2 >
196- < div className = "h-px flex-1 bg-border" />
197- </ div >
198- < RequestFilters
199- filters = { filters }
200- accountOptions = { accountOptions }
201- apiKeyOptions = { apiKeyOptions }
202- modelOptions = { modelOptions }
203- statusOptions = { statusOptions }
204- onSearchChange = { ( search ) => updateFilters ( { search, offset : 0 } ) }
205- onTimeframeChange = { ( timeframe ) => updateFilters ( { timeframe, offset : 0 } ) }
206- onAccountChange = { ( accountIds ) => updateFilters ( { accountIds, offset : 0 } ) }
207- onApiKeyChange = { ( apiKeyIds ) => updateFilters ( { apiKeyIds, offset : 0 } ) }
208- onModelChange = { ( modelOptionsSelected ) =>
209- updateFilters ( { modelOptions : modelOptionsSelected , offset : 0 } )
210- }
211- onStatusChange = { ( statuses ) => updateFilters ( { statuses, offset : 0 } ) }
212- onReset = { ( ) =>
213- updateFilters ( {
214- search : "" ,
215- timeframe : "all" ,
216- accountIds : [ ] ,
217- apiKeyIds : [ ] ,
218- modelOptions : [ ] ,
219- statuses : [ ] ,
220- offset : 0 ,
221- } )
222- }
223- />
224- < div className = "transition-opacity duration-200" >
225- < RecentRequestsTable
226- requests = { view . requestLogs }
227- accounts = { overview ?. accounts ?? [ ] }
228- total = { logPage ?. total ?? 0 }
229- limit = { filters . limit }
230- offset = { filters . offset }
231- hasMore = { logPage ?. hasMore ?? false }
232- onLimitChange = { ( limit ) => updateFilters ( { limit, offset : 0 } ) }
233- onOffsetChange = { ( offset ) => updateFilters ( { offset } ) }
234- />
235- </ div >
236- </ section >
237137 </ >
238138 ) }
239139
0 commit comments