Skip to content

Commit cb870ec

Browse files
committed
use new geography fields for usecase and dataset everywhere
1 parent e935c54 commit cb870ec

File tree

4 files changed

+79
-18
lines changed

4 files changed

+79
-18
lines changed

app/[locale]/(user)/collaboratives/[collaborativeSlug]/CollaborativeDetailsClient.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ const CollaborativeDetails = graphql(`
121121
sectors {
122122
name
123123
}
124+
geographies {
125+
id
126+
name
127+
code
128+
type
129+
}
124130
modified
125131
}
126132
useCases {
@@ -154,6 +160,12 @@ const CollaborativeDetails = graphql(`
154160
sectors {
155161
name
156162
}
163+
geographies {
164+
id
165+
name
166+
code
167+
type
168+
}
157169
tags {
158170
id
159171
value
@@ -396,9 +408,9 @@ const CollaborativeDetailClient = () => {
396408
? `${process.env.NEXT_PUBLIC_BACKEND_URL}/${useCase.organization.logo.url}`
397409
: '/org.png';
398410

399-
const Geography = useCase.metadata?.find(
400-
(meta: any) => meta.metadataItem?.label === 'Geography'
401-
)?.value;
411+
const Geography = useCase.geographies && useCase.geographies.length > 0
412+
? useCase.geographies.map((geo: any) => geo.name).join(', ')
413+
: null;
402414

403415
const MetadataContent = [
404416
{
@@ -492,10 +504,9 @@ const CollaborativeDetailClient = () => {
492504
icon: Icons.globe,
493505
label: 'Geography',
494506
value:
495-
dataset.metadata?.find(
496-
(meta: any) =>
497-
meta.metadataItem?.label === 'Geography'
498-
)?.value || '',
507+
dataset.geographies && dataset.geographies.length > 0
508+
? dataset.geographies.map((geo: any) => geo.name).join(', ')
509+
: '',
499510
},
500511
]}
501512
href={`/datasets/${dataset.id}`}

app/[locale]/(user)/datasets/[datasetIdentifier]/DatasetDetailsPage.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
'use client';
22

3-
import { useEffect, useState } from 'react';
43
import { graphql } from '@/gql';
54
import { useQuery } from '@tanstack/react-query';
65
import { Spinner } from 'opub-ui';
76

8-
import { GraphQL } from '@/lib/api';
9-
import { generateJsonLd } from '@/lib/utils';
107
import BreadCrumbs from '@/components/BreadCrumbs';
118
import JsonLd from '@/components/JsonLd';
9+
import { GraphQL } from '@/lib/api';
10+
import { generateJsonLd } from '@/lib/utils';
1211
import Details from './components/Details';
1312
import Metadata from './components/Metadata';
1413
import PrimaryData from './components/PrimaryData';
@@ -64,6 +63,17 @@ const datasetQuery: any = graphql(`
6463
sectors {
6564
name
6665
}
66+
geographies {
67+
id
68+
name
69+
code
70+
type
71+
parentId {
72+
id
73+
name
74+
type
75+
}
76+
}
6777
formats
6878
}
6979
}

app/[locale]/(user)/datasets/[datasetIdentifier]/components/Metadata/index.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { useEffect, useState } from 'react';
21
import Image from 'next/image';
32
import Link from 'next/link';
43
import { Button, Divider, Icon, Tag, Text, Tooltip } from 'opub-ui';
4+
import React, { useEffect, useState } from 'react';
55

6-
import { cn, formatDate, getWebsiteTitle } from '@/lib/utils';
76
import { Icons } from '@/components/icons';
7+
import { cn, formatDate, getWebsiteTitle } from '@/lib/utils';
88
import Styles from '../../../dataset.module.scss';
99

1010
interface MetadataProps {
@@ -19,8 +19,8 @@ const MetadataComponent: React.FC<MetadataProps> = ({ data, setOpen }) => {
1919
type: item.metadataItem.dataType,
2020
}));
2121

22-
const [isexpanded, setIsexpanded] = useState(false);
23-
const toggleDescription = () => setIsexpanded(!isexpanded);
22+
// const [isexpanded, setIsexpanded] = useState(false);
23+
// const toggleDescription = () => setIsexpanded(!isexpanded);
2424

2525
const licenseOptions = [
2626
{
@@ -177,6 +177,25 @@ const MetadataComponent: React.FC<MetadataProps> = ({ data, setOpen }) => {
177177
)}
178178
</div>
179179
</div>
180+
{data.geographies && data.geographies.length > 0 && (
181+
<div className="flex items-center gap-2 ">
182+
<Text className="min-w-[120px] basis-1/4 uppercase" variant="bodyMd">
183+
Geography
184+
</Text>
185+
<div className="flex flex-wrap gap-2">
186+
{data.geographies.map((geo: any, index: number) => (
187+
<Tag
188+
key={index}
189+
fillColor="var(--blue-secondary-color)"
190+
borderColor="var(--blue-secondary-text)"
191+
textColor="black"
192+
>
193+
{geo.name}
194+
</Tag>
195+
))}
196+
</div>
197+
</div>
198+
)}
180199
{Metadata.map((item: any, index: any) => (
181200
<div className="flex gap-2 " key={index}>
182201
<Text

app/[locale]/(user)/usecases/[useCaseSlug]/UsecaseDetailsClient.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ const UseCasedetails = graphql(`
6060
id
6161
name
6262
}
63+
geographies {
64+
id
65+
name
66+
code
67+
type
68+
parentId {
69+
id
70+
name
71+
type
72+
}
73+
}
74+
sdgs {
75+
id
76+
code
77+
name
78+
}
6379
runningStatus
6480
tags {
6581
id
@@ -108,6 +124,12 @@ const UseCasedetails = graphql(`
108124
sectors {
109125
name
110126
}
127+
geographies {
128+
id
129+
name
130+
code
131+
type
132+
}
111133
modified
112134
}
113135
contactEmail
@@ -283,10 +305,9 @@ const UseCaseDetailClient = () => {
283305
icon: Icons.globe,
284306
label: 'Geography',
285307
value:
286-
dataset.metadata?.find(
287-
(meta: any) =>
288-
meta.metadataItem?.label === 'Geography'
289-
)?.value || '',
308+
dataset.geographies && dataset.geographies.length > 0
309+
? dataset.geographies.map((geo: any) => geo.name).join(', ')
310+
: '',
290311
},
291312
]}
292313
href={`/datasets/${dataset.id}`}

0 commit comments

Comments
 (0)