11'use client' ;
22
33import Image from 'next/image' ;
4+ import { fetchUseCases } from '@/fetch' ;
45import { graphql } from '@/gql' ;
56import { useQuery } from '@tanstack/react-query' ;
67import { Card , Spinner , Text } from 'opub-ui' ;
78
89import { GraphQL } from '@/lib/api' ;
9- import { cn , formatDate } from '@/lib/utils' ;
1010import BreadCrumbs from '@/components/BreadCrumbs' ;
11- import { Icons } from '@/components/icons' ;
12- import { Loading } from '@/components/loading' ;
13- import Styles from '../page.module.scss' ;
11+ import ListingComponent from '../components/ListingComponent' ;
1412
15- const useCasesListQueryDoc : any = graphql ( `
16- query UseCasesList($filters: UseCaseFilter) {
17- publishedUseCases(filters: $filters) {
18- id
19- title
20- summary
21- slug
22- datasetCount
23- isIndividualUsecase
24- user {
25- fullName
26- profilePicture {
27- url
28- }
29- }
30- organization {
31- name
32- logo {
33- url
34- }
35- }
36- logo {
37- path
38- }
39- metadata {
40- metadataItem {
41- id
42- label
43- dataType
44- }
45- id
46- value
47- }
48- publishers {
49- logo {
50- path
51- }
52- name
53- }
54- sectors {
55- id
56- name
57- }
58- created
59- modified
60- website
61- contactEmail
62- }
63- }
64- ` ) ;
13+ const breadcrumbData = [
14+ { href : '/' , label : 'Home' } ,
15+ { href : '#' , label : 'Use Cases' } ,
16+ ] ;
6517
6618const UseCasesListingPage = ( ) => {
67- const getUseCasesList : {
68- data : any ;
69- isLoading : boolean ;
70- error : any ;
71- isError : boolean ;
72- } = useQuery ( [ `useCases_list_page` ] , ( ) =>
73- GraphQL (
74- useCasesListQueryDoc ,
75- { } ,
76- {
77- filters : { status : 'PUBLISHED' } ,
78- }
79- )
80- ) ;
81-
8219 return (
83- < main className = "bg-baseGraySlateSolid2" >
84- < BreadCrumbs
85- data = { [
86- { href : '/' , label : 'Home' } ,
87- { href : '#' , label : 'Use Cases' } ,
88- ] }
89- />
20+ < main >
21+ < BreadCrumbs data = { breadcrumbData } />
9022 < div className = " bg-primaryBlue " >
9123 < div className = "container flex flex-col-reverse justify-center gap-8 p-10 lg:flex-row " >
9224 < div className = "flex flex-col justify-center gap-6" >
@@ -96,7 +28,7 @@ const UseCasesListingPage = () => {
9628 < Text
9729 variant = "headingLg"
9830 fontWeight = "regular"
99- className = " text-surfaceDefault leading-3 lg:leading-5"
31+ className = " leading-3 text-surfaceDefault lg:leading-5"
10032 >
10133 By Use case we mean any specific sector or domain data led
10234 interventions that can be applied to address some of the most
@@ -113,66 +45,13 @@ const UseCasesListingPage = () => {
11345 />
11446 </ div >
11547 </ div >
116- < div className = "container p-6 lg:pb-20 lg:p-10 " >
48+ < div className = "container p-6 lg:p-10 lg:pb-20 " >
11749 < div >
118- < Text variant = "heading2xl" fontWeight = 'bold' > Explore Use Cases</ Text >
50+ < Text variant = "heading2xl" fontWeight = "bold" >
51+ Explore Use Cases
52+ </ Text >
11953 </ div >
120- { getUseCasesList . isLoading ? (
121- < div className = " mt-8 flex justify-center" >
122- < Spinner />
123- </ div >
124- ) : (
125- < div
126- className = { cn (
127- 'grid w-full grid-cols-1 gap-6 pt-6 lg:pt-10 md:grid-cols-2 lg:grid-cols-3' ,
128- Styles . Card
129- ) }
130- >
131- { getUseCasesList &&
132- getUseCasesList ?. data ?. publishedUseCases . length > 0 &&
133- getUseCasesList ?. data ?. publishedUseCases . map ( ( item : any , index : any ) => (
134- < Card
135- title = { item . title }
136- key = { index }
137- href = { `/usecases/${ item . id } ` }
138- metadataContent = { [
139- {
140- icon : Icons . calendar ,
141- label : 'Date' ,
142- value : formatDate ( item . modified ) ,
143- } ,
144- {
145- icon : Icons . globe ,
146- label : 'Geography' ,
147- value : item . metadata ?. find (
148- ( meta : any ) => meta . metadataItem ?. label === 'Geography'
149- ) ?. value ,
150- } ,
151- ] }
152- footerContent = { [
153- {
154- icon : `/Sectors/${ item ?. sectors [ 0 ] ?. name } .svg` ,
155- label : 'Sectors' ,
156- } ,
157- {
158- icon : item . isIndividualUsecase
159- ? item ?. user ?. profilePicture
160- ? `${ process . env . NEXT_PUBLIC_BACKEND_URL } /${ item . user . profilePicture . url } `
161- : '/profile.png'
162- : item ?. organization ?. logo
163- ? `${ process . env . NEXT_PUBLIC_BACKEND_URL } /${ item . organization . logo . url } `
164- : '/org.png' ,
165- label : 'Published by' ,
166- } ,
167- ] }
168- imageUrl = { `${ process . env . NEXT_PUBLIC_BACKEND_URL } /${ item . logo ?. path . replace ( '/code/files/' , '' ) } ` }
169- description = { item . summary }
170- iconColor = "warning"
171- variation = { 'collapsed' }
172- />
173- ) ) }
174- </ div >
175- ) }
54+ < ListingComponent fetchDatasets = { fetchUseCases } />
17655 </ div >
17756 </ main >
17857 ) ;
0 commit comments