@@ -3,7 +3,6 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@conar
33import { cn } from '@conar/ui/lib/utils'
44import NumberFlow from '@number-flow/react'
55import { useStore } from '@tanstack/react-store'
6- import { useState } from 'react'
76import { useConnectionTableTotal } from '~/entities/connection/queries'
87import { Route } from '../..'
98import { useTableColumns } from '../../-queries/use-columns-query'
@@ -16,11 +15,10 @@ export function Header({ table, schema }: { table: string, schema: string }) {
1615 const columns = useTableColumns ( { connection, table, schema } )
1716 const store = usePageStoreContext ( )
1817 const filters = useStore ( store , state => state . filters )
19- const [ exact , setExact ] = useState ( false )
18+ const exact = useStore ( store , state => state . exact )
2019 const { data : total , isLoading } = useConnectionTableTotal ( { connection, table, schema, query : { filters, exact } } )
2120
2221 const columnsCount = columns ?. length ?? 0
23- const count = Number ( total ?. count )
2422
2523 return (
2624 < div className = "flex w-full items-center justify-between gap-6" >
@@ -43,31 +41,35 @@ export function Header({ table, schema }: { table: string, schema: string }) {
4341 { columnsCount === 1 ? '' : 's' }
4442 </ span >
4543 < Separator orientation = "vertical" className = "h-3!" />
46- < TooltipProvider >
47- < Tooltip >
48- < TooltipTrigger
49- className = { cn ( 'inline-flex items-center gap-1' , ! exact && total ?. isEstimated && `
50- cursor-pointer
51- ` ) }
52- onClick = { ( ) => setExact ( true ) }
53- >
54- < NumberFlow
55- value = { count }
56- format = { { notation : 'compact' , compactDisplay : 'short' , maximumFractionDigits : 1 } }
57- className = { cn ( 'text-muted-foreground tabular-nums' , isLoading && `
58- animate-pulse
59- ` ) }
60- prefix = { total ?. isEstimated ? '~' : '' }
61- suffix = { count === 1 ? ' row' : ' rows' }
62- />
63- </ TooltipTrigger >
64- { ! exact && total ?. isEstimated && (
65- < TooltipContent side = "bottom" >
66- Click to get the exact count.
67- </ TooltipContent >
44+ { total ?. count === undefined
45+ ? < > ...</ >
46+ : (
47+ < TooltipProvider >
48+ < Tooltip >
49+ < TooltipTrigger
50+ className = { cn ( 'inline-flex items-center gap-1' , ! exact && total . isEstimated && `
51+ cursor-pointer
52+ ` ) }
53+ onClick = { ( ) => store . setState ( state => ( { ...state , exact : true } satisfies typeof state ) ) }
54+ >
55+ < NumberFlow
56+ value = { total . count }
57+ format = { { notation : 'compact' , compactDisplay : 'short' , maximumFractionDigits : 1 } }
58+ className = { cn ( 'text-muted-foreground tabular-nums' , isLoading && `
59+ animate-pulse text-muted-foreground/50
60+ ` ) }
61+ prefix = { total . isEstimated ? '~' : '' }
62+ suffix = { total . count === 1 ? ' row' : ' rows' }
63+ />
64+ </ TooltipTrigger >
65+ { ! exact && total . isEstimated && (
66+ < TooltipContent side = "bottom" >
67+ Click to get the exact count.
68+ </ TooltipContent >
69+ ) }
70+ </ Tooltip >
71+ </ TooltipProvider >
6872 ) }
69- </ Tooltip >
70- </ TooltipProvider >
7173 </ div >
7274 </ div >
7375 < Separator orientation = "vertical" className = "h-6!" />
0 commit comments