Skip to content

Commit 1650413

Browse files
committed
Add query to get details and add to dashboard navbar
1 parent 01df61b commit 1650413

File tree

1 file changed

+27
-2
lines changed
  • app/[locale]/dashboard/[entityType]/[entitySlug]

1 file changed

+27
-2
lines changed

app/[locale]/dashboard/[entityType]/[entitySlug]/layout.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import React from 'react';
44
import { notFound, useParams } from 'next/navigation';
55
import { SidebarNavItem } from '@/types';
6+
import { useQuery } from '@tanstack/react-query';
67

8+
import { GraphQL } from '@/lib/api';
79
import { cn } from '@/lib/utils';
810
import BreadCrumbs from '@/components/BreadCrumbs';
911
import { DashboardNav } from '../../components/dashboard-nav';
1012
import { MobileDashboardNav } from '../../components/mobile-dashboard-nav';
1113
import styles from '../../components/styles.module.scss';
14+
import { getDataSpaceDetailsQryDoc, getOrgDetailsQryDoc } from './schema';
1215

1316
interface 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

Comments
 (0)