33import React from 'react' ;
44import { notFound , useParams } from 'next/navigation' ;
55import { SidebarNavItem } from '@/types' ;
6+ import { useQuery } from '@tanstack/react-query' ;
67
8+ import { GraphQL } from '@/lib/api' ;
79import { cn } from '@/lib/utils' ;
810import BreadCrumbs from '@/components/BreadCrumbs' ;
911import { DashboardNav } from '../../components/dashboard-nav' ;
1012import { MobileDashboardNav } from '../../components/mobile-dashboard-nav' ;
1113import styles from '../../components/styles.module.scss' ;
14+ import { getDataSpaceDetailsQryDoc , getOrgDetailsQryDoc } from './schema' ;
1215
1316interface DashboardLayoutProps {
1417 children ?: React . ReactNode ;
@@ -18,6 +21,17 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) {
1821 const [ isOpened , setIsOpened ] = React . useState ( false ) ;
1922 const params = useParams < { entityType : string ; entitySlug : string } > ( ) ;
2023
24+ const EntityDetailsQryRes : { data : any ; isLoading : boolean ; error : any } =
25+ useQuery ( [ `entity_details_${ params . entityType } ` ] , ( ) =>
26+ GraphQL (
27+ params . entityType === 'organization'
28+ ? getOrgDetailsQryDoc
29+ : getDataSpaceDetailsQryDoc ,
30+ { } ,
31+ { filters : { slug : params . entitySlug } }
32+ )
33+ ) ;
34+
2135 if (
2236 process . env . NEXT_PUBLIC_DATASPACE_FEATURE_ENABLED !== 'true' &&
2337 params . entityType === 'dataspace'
@@ -56,7 +70,11 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) {
5670 } ,
5771 {
5872 href : '' ,
59- label : `${ params . entitySlug } ` ,
73+ label :
74+ ( params . entityType === 'organization'
75+ ? EntityDetailsQryRes . data ?. organisations [ 0 ]
76+ : EntityDetailsQryRes . data ?. dataspaces [ 0 ]
77+ ) ?. name || params . entitySlug ,
6078 } ,
6179 ] }
6280 />
@@ -66,7 +84,14 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) {
6684 ' bg-surfaceDefault p-4 md:flex'
6785 ) }
6886 >
69- < DashboardNav items = { orgSidebarNav } entitySlug = { params . entitySlug } />
87+ < DashboardNav
88+ items = { orgSidebarNav }
89+ entityDetails = {
90+ params . entityType === 'organization'
91+ ? EntityDetailsQryRes . data ?. organisations [ 0 ]
92+ : EntityDetailsQryRes . data ?. dataspaces [ 0 ]
93+ }
94+ />
7095
7196 < div className = "z-1 basis-2 md:hidden" >
7297 < MobileDashboardNav
0 commit comments