@@ -9,6 +9,7 @@ import { Icons } from '@/components/icons';
99
1010interface SidebarCardProps {
1111 data : any ;
12+ type : 'organization' | 'Publisher' ;
1213}
1314const sectorsDoc : any = graphql ( `
1415 query sectorInfo($userId: ID!) {
@@ -20,35 +21,75 @@ const sectorsDoc: any = graphql(`
2021 }
2122` ) ;
2223
23- const SidebarCard : React . FC < SidebarCardProps > = ( { data } ) => {
24- const sectorInfo : any = useQuery ( [ `${ data . id } _sector` ] , ( ) =>
25- GraphQL (
26- sectorsDoc ,
27- {
28- // Entity Headers if present
29- } ,
30- { userId : data . id }
31- )
24+ const organizationDoc : any = graphql ( `
25+ query organizationInfo($organizationId: ID!) {
26+ organizationContributedSectors(organizationId: $organizationId) {
27+ id
28+ name
29+ slug
30+ }
31+ }
32+ ` ) ;
33+
34+ const SidebarCard : React . FC < SidebarCardProps > = ( { data, type } ) => {
35+ const sectorInfo : any = useQuery (
36+ [ `${ data . id } _sector` ] ,
37+ ( ) =>
38+ GraphQL (
39+ sectorsDoc ,
40+ {
41+ // Entity Headers if present
42+ } ,
43+ { userId : data . id }
44+ ) ,
45+ {
46+ enabled : type === 'Publisher' && ! ! data ?. id ,
47+ }
48+ ) ;
49+
50+ const organizationInfo : any = useQuery (
51+ [ `${ data . id } _organization` ] ,
52+ ( ) =>
53+ GraphQL (
54+ organizationDoc ,
55+ {
56+ // Entity Headers if present
57+ } ,
58+ { organizationId : data . id }
59+ ) ,
60+ {
61+ enabled : type === 'organization' && ! ! data ?. id , // runs only if type is 'organization' and data.id exists
62+ }
3263 ) ;
3364
3465 return (
3566 < div className = "m-auto flex flex-col gap-4" >
3667 < div >
37- < Image
38- src = { `${ process . env . NEXT_PUBLIC_BACKEND_URL } /${ data ?. profilePicture ?. url } ` }
39- alt = { data . fullName }
40- width = { 240 }
41- height = { 240 }
42- className = "m-auto rounded-full object-cover"
43- />
68+ { type === 'organization' ? (
69+ < Image
70+ src = { `${ data ?. logo ?. url ? process . env . NEXT_PUBLIC_BACKEND_URL + data ?. logo ?. url : '/org.png' } ` }
71+ alt = { data . fullName }
72+ width = { 168 }
73+ height = { 168 }
74+ className = "m-auto rounded-4 bg-surfaceDefault object-contain p-4"
75+ />
76+ ) : (
77+ < Image
78+ src = { `${ data ?. profilePicture ?. url ? process . env . NEXT_PUBLIC_BACKEND_URL + data ?. profilePicture ?. url : '/profile.png' } ` }
79+ alt = { data . fullName }
80+ width = { 240 }
81+ height = { 240 }
82+ className = "m-auto rounded-full object-cover"
83+ />
84+ ) }
4485 </ div >
4586 < div className = "flex flex-col gap-4" >
4687 < div className = "pt-4" >
4788 < Text variant = "bodyLg" fontWeight = "semibold" color = "onBgDefault" >
48- { data ?. fullName }
89+ { type === 'organization' ? data ?. name : data ?. fullName }
4990 </ Text >
5091 </ div >
51- < div className = "flex items-center gap-2" >
92+ < div className = "flex flex-wrap items-center gap-2" >
5293 < Text variant = "bodySm" color = "onBgDefault" >
5394 { data ?. publishedUseCasesCount } Use Cases
5495 </ Text >
@@ -88,7 +129,8 @@ const SidebarCard: React.FC<SidebarCardProps> = ({ data }) => {
88129 ) }
89130 </ div >
90131 < div className = "flex flex-col gap-2" >
91- { sectorInfo ?. data &&
132+ { type === 'Publisher' &&
133+ sectorInfo ?. data &&
92134 sectorInfo ?. data . userContributedSectors . map (
93135 ( item : any , index : any ) => (
94136 < div className = "flex items-center gap-2" key = { index } >
@@ -103,6 +145,22 @@ const SidebarCard: React.FC<SidebarCardProps> = ({ data }) => {
103145 </ div >
104146 )
105147 ) }
148+ { type === 'organization' &&
149+ organizationInfo ?. data &&
150+ organizationInfo ?. data . organizationContributedSectors . map (
151+ ( item : any , index : any ) => (
152+ < div className = "flex items-center gap-2" key = { index } >
153+ < Image
154+ src = { `/Sectors/${ item ?. name } .svg` }
155+ alt = "Sector Logo"
156+ width = { 32 }
157+ height = { 32 }
158+ className = " rounded-2 bg-surfaceDefault p-1"
159+ />
160+ < Text color = "onBgDefault" > { item ?. name } </ Text >
161+ </ div >
162+ )
163+ ) }
106164 </ div >
107165 </ div >
108166 </ div >
0 commit comments