@@ -40,20 +40,67 @@ const userPublishedUseCasesDoc: any = graphql(`
4040 }
4141` ) ;
4242
43- const UseCases = ( ) => {
43+ const orgPublishedUseCasesDoc : any = graphql ( `
44+ query orgPublishedUseCasesList($organizationId: ID!) {
45+ organizationPublishedUseCases(organizationId: $organizationId) {
46+ id
47+ title
48+ summary
49+ slug
50+ metadata {
51+ metadataItem {
52+ id
53+ label
54+ dataType
55+ }
56+ id
57+ value
58+ }
59+ publishers {
60+ logo {
61+ path
62+ }
63+ name
64+ }
65+ sectors {
66+ id
67+ name
68+ }
69+ created
70+ modified
71+ }
72+ }
73+ ` ) ;
74+
75+ const UseCases = ( { type } : { type : 'organization' | 'Publisher' } ) => {
4476 const params = useParams ( ) ;
77+
4578 const PublishedUseCasesList : any = useQuery (
46- [ `userPublishedUseCase_ ${ params . publisherSlug } ` ] ,
79+ [ `userPublishedDataset_ ${ params . publisherSlug } ` ] ,
4780 ( ) =>
48- GraphQL (
49- userPublishedUseCasesDoc ,
50- {
51- // Entity Headers if present
52- } ,
53- { userId : params . publisherSlug }
54- )
81+ type === 'organization'
82+ ? GraphQL (
83+ orgPublishedUseCasesDoc ,
84+ {
85+ // Entity Headers
86+ } ,
87+ { organizationId : params . organizationSlug } // ✅ exact match for expected shape
88+ )
89+ : GraphQL (
90+ userPublishedUseCasesDoc ,
91+ {
92+ // Entity Headers
93+ } ,
94+ { userId : params . publisherSlug } // ✅ exact match for expected shape
95+ )
5596 ) ;
5697
98+ const UseCaseData =
99+ type === 'organization'
100+ ? PublishedUseCasesList . data ?. organizationPublishedUseCases
101+ : PublishedUseCasesList . data ?. userPublishedUseCases ;
102+
103+
57104 return (
58105 < div >
59106 < div
@@ -66,47 +113,45 @@ const UseCases = () => {
66113 < Spinner />
67114 </ div >
68115 ) : (
69- PublishedUseCasesList . data . userPublishedUseCases . length > 0 &&
70- PublishedUseCasesList . data . userPublishedUseCases . map (
71- ( item : any , index : any ) => (
72- < Card
73- type = { [
74- {
75- label : 'Use Case' ,
76- fillColor : '#FEF7E5' ,
77- borderColor : '#F9C74F' ,
78- } ,
79- ] }
80- title = { item . title }
81- key = { index }
82- href = { `/usecases/${ item . id } ` }
83- metadataContent = { [
84- {
85- icon : Icons . calendar ,
86- label : 'Date' ,
87- value : formatDate ( item . modified ) ,
88- } ,
89- {
90- icon : Icons . globe ,
91- label : 'Geography' ,
92- value : item . metadata ?. find (
93- ( meta : any ) => meta . metadataItem ?. label === 'Geography'
94- ) ?. value ,
95- } ,
96- ] }
97- footerContent = { [
98- {
99- icon : `/Sectors/${ item ?. sectors [ 0 ] ?. name } .svg` ,
100- label : 'Sectors' ,
101- } ,
102- { icon : '/fallback.svg' , label : 'Published by' } ,
103- ] }
104- description = { item . summary }
105- iconColor = "warning"
106- variation = { 'collapsed' }
107- />
108- )
109- )
116+ UseCaseData ?. length > 0 &&
117+ UseCaseData ?. map ( ( item : any , index : any ) => (
118+ < Card
119+ type = { [
120+ {
121+ label : 'Use Case' ,
122+ fillColor : '#FEF7E5' ,
123+ borderColor : '#F9C74F' ,
124+ } ,
125+ ] }
126+ title = { item . title }
127+ key = { index }
128+ href = { `/usecases/${ item . id } ` }
129+ metadataContent = { [
130+ {
131+ icon : Icons . calendar ,
132+ label : 'Date' ,
133+ value : formatDate ( item . modified ) ,
134+ } ,
135+ {
136+ icon : Icons . globe ,
137+ label : 'Geography' ,
138+ value : item . metadata ?. find (
139+ ( meta : any ) => meta . metadataItem ?. label === 'Geography'
140+ ) ?. value ,
141+ } ,
142+ ] }
143+ footerContent = { [
144+ {
145+ icon : `/Sectors/${ item ?. sectors [ 0 ] ?. name } .svg` ,
146+ label : 'Sectors' ,
147+ } ,
148+ { icon : '/fallback.svg' , label : 'Published by' } ,
149+ ] }
150+ description = { item . summary }
151+ iconColor = "warning"
152+ variation = { 'collapsed' }
153+ />
154+ ) )
110155 ) }
111156 </ div >
112157 </ div >
0 commit comments