33import Image from 'next/image' ;
44import Link from 'next/link' ;
55import { useRouter } from 'next/navigation' ;
6- import { SearchInput , Tag , Text } from 'opub-ui' ;
6+ import { graphql } from '@/gql' ;
7+ import { useQuery } from '@tanstack/react-query' ;
8+ import { SearchInput , Spinner , Tag , Text } from 'opub-ui' ;
79
10+ import { GraphQL } from '@/lib/api' ;
811import { cn } from '@/lib/utils' ;
912import Styles from '../page.module.scss' ;
1013
14+ const statsInfo : any = graphql ( `
15+ query StatsList {
16+ stats {
17+ totalUsers
18+ totalPublishedDatasets
19+ totalPublishers
20+ totalPublishedUsecases
21+ }
22+ }
23+ ` ) ;
24+
25+ // const tagsInfo: any = graphql(`
26+ // query TagsData {
27+ // tags {
28+ // id
29+ // value
30+ // }
31+ // }
32+ // `);
33+
1134export const Content = ( ) => {
1235 const router = useRouter ( ) ;
36+ const Stats : { data : any ; isLoading : any } = useQuery ( [ `statsDetails` ] , ( ) =>
37+ GraphQL ( statsInfo , { } , [ ] )
38+ ) ;
39+ // const Tags: { data: any; isLoading: any } = useQuery([`tagDetails`], () =>
40+ // GraphQL(tagsInfo, {}, [])
41+ // );
42+
1343 const handleSearch = ( value : string ) => {
1444 if ( value ) {
1545 router . push ( `/datasets?query=${ encodeURIComponent ( value ) } ` ) ;
@@ -18,20 +48,20 @@ export const Content = () => {
1848 const Metrics = [
1949 {
2050 label : 'Datasets' ,
21- count : '2k' ,
51+ count : Stats ?. data ?. stats ?. totalPublishedDatasets ,
2252 } ,
2353 {
2454 label : 'Use Cases' ,
25- count : '15' ,
55+ count : Stats ?. data ?. stats ?. totalPublishedUsecases ,
2656 } ,
2757
2858 {
29- label : 'Consumers ' ,
30- count : '24k' ,
59+ label : 'Publishers ' ,
60+ count : Stats ?. data ?. stats ?. totalPublishers ,
3161 } ,
3262 {
33- label : 'Publishers ' ,
34- count : '56' ,
63+ label : 'Users ' ,
64+ count : Stats ?. data ?. stats ?. totalUsers ,
3565 } ,
3666 ] ;
3767
@@ -44,8 +74,8 @@ export const Content = () => {
4474 'Urban Development' ,
4575 ] ;
4676 return (
47- < main className = "bg-primaryBlue py-6 md:py-10 md:px-8 lg:py-20" >
48- < div className = "container md:px-12 px-10 lg:px-8 flex items-center justify-around gap-20 " >
77+ < main className = "bg-primaryBlue py-6 md:px-8 md:py-10 lg:py-20" >
78+ < div className = "container flex items-center justify-around gap-20 px-10 md:px-12 lg:px-8 " >
4979 < div className = "flex flex-col gap-11 lg:w-[49%]" >
5080 < div className = "flex flex-col" >
5181 < Text variant = "heading3xl" color = "onBgDefault" >
@@ -62,21 +92,27 @@ export const Content = () => {
6292 with CivicDataLab{ ' ' }
6393 </ Text >
6494 </ div >
65- < div className = "flex flex-wrap items-center gap-4 md:gap-0 lg:gap-0 " >
66- { Metrics . map ( ( item , index ) => (
67- < div
68- key = { index }
69- className = "flex flex-col border-x-[1px] border-solid border-tertiaryAccent px-4"
70- >
71- < Text variant = "heading3xl" className = " text-secondaryOrange" >
72- { item . count }
73- </ Text >
74- < Text color = "onBgDefault" className = " w-20" >
75- { item . label }
76- </ Text >
77- </ div >
78- ) ) }
79- </ div >
95+ { Stats . isLoading ? (
96+ < div className = " flex w-fit justify-center rounded-2 bg-surfaceDefault p-4" >
97+ < Spinner />
98+ </ div >
99+ ) : (
100+ < div className = "flex flex-wrap items-center gap-4 md:gap-0 lg:gap-0 " >
101+ { Metrics . map ( ( item , index ) => (
102+ < div
103+ key = { index }
104+ className = "flex flex-col border-x-[1px] border-solid border-tertiaryAccent px-4"
105+ >
106+ < Text variant = "heading3xl" className = " text-secondaryOrange" >
107+ { item . count }
108+ </ Text >
109+ < Text color = "onBgDefault" className = " w-20 " >
110+ { item . label }
111+ </ Text >
112+ </ div >
113+ ) ) }
114+ </ div >
115+ ) }
80116 < div className = "w-full" >
81117 < SearchInput
82118 className = { cn ( Styles . Search ) }
0 commit comments