@@ -9,6 +9,7 @@ import { Layout } from '@/components/layout';
99import { useCurrentWorkspaceId , useHasAdminPermission } from '@/store/user' ;
1010import { routeAuthBeforeLoad } from '@/utils/route' ;
1111import { cn } from '@/utils/style' ;
12+ import { formatNumber } from '@/utils/common' ;
1213import { useTranslation } from '@i18next-toolkit/react' ;
1314import {
1415 createFileRoute ,
@@ -28,9 +29,6 @@ function PageComponent() {
2829 const { data = [ ] , isLoading } = trpc . survey . all . useQuery ( {
2930 workspaceId,
3031 } ) ;
31- const { data : allResultCount = { } } = trpc . survey . allResultCount . useQuery ( {
32- workspaceId,
33- } ) ;
3432 const navigate = useNavigate ( ) ;
3533 const pathname = useRouterState ( {
3634 select : ( state ) => state . location . pathname ,
@@ -40,7 +38,7 @@ function PageComponent() {
4038 const items = data . map ( ( item ) => ( {
4139 id : item . id ,
4240 title : item . name ,
43- number : allResultCount [ item . id ] ?? 0 ,
41+ content : < SurveyResultCount surveyId = { item . id } /> ,
4442 href : `/survey/${ item . id } ` ,
4543 } ) ) ;
4644
@@ -91,6 +89,7 @@ function PageComponent() {
9189 < CommonList
9290 hasSearch = { true }
9391 items = { items }
92+ direction = "horizontal"
9493 isLoading = { isLoading }
9594 emptyDescription = { t (
9695 'Not have any survey yet, create a survey to collect user feedback about your user service.'
@@ -101,3 +100,28 @@ function PageComponent() {
101100 />
102101 ) ;
103102}
103+
104+ function SurveyResultCount ( { surveyId } : { surveyId : string } ) {
105+ const workspaceId = useCurrentWorkspaceId ( ) ;
106+ const { data : count } = trpc . survey . count . useQuery (
107+ {
108+ workspaceId,
109+ surveyId,
110+ } ,
111+ {
112+ trpc : {
113+ context : {
114+ skipBatch : true ,
115+ } ,
116+ } ,
117+ }
118+ ) ;
119+
120+ if ( ! count || count <= 0 ) return null ;
121+
122+ return (
123+ < span className = "opacity-60" title = { String ( count ) } >
124+ { formatNumber ( count ) }
125+ </ span >
126+ ) ;
127+ }
0 commit comments