Skip to content

Commit e0b81ff

Browse files
committed
add usecases
1 parent 86c7fb2 commit e0b81ff

File tree

3 files changed

+173
-1
lines changed

3 files changed

+173
-1
lines changed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
'use client';
2+
3+
import { useRouter } from 'next/navigation';
4+
import { graphql } from '@/gql';
5+
import { useQuery } from '@tanstack/react-query';
6+
import {
7+
Button,
8+
Card,
9+
Carousel,
10+
CarouselContent,
11+
CarouselItem,
12+
CarouselNext,
13+
CarouselPrevious,
14+
Spinner,
15+
Text,
16+
} from 'opub-ui';
17+
18+
import { GraphQL } from '@/lib/api';
19+
import { cn, formatDate } from '@/lib/utils';
20+
import { Icons } from '@/components/icons';
21+
import Styles from './datasets.module.scss';
22+
23+
const useCasesListDoc: any = graphql(`
24+
query TopUseCases($filters: UseCaseFilter) {
25+
useCases(filters: $filters) {
26+
id
27+
title
28+
summary
29+
slug
30+
datasetCount
31+
logo {
32+
path
33+
}
34+
metadata {
35+
metadataItem {
36+
id
37+
label
38+
dataType
39+
}
40+
id
41+
value
42+
}
43+
publishers {
44+
logo {
45+
path
46+
}
47+
name
48+
}
49+
sectors {
50+
id
51+
name
52+
}
53+
created
54+
modified
55+
website
56+
contactEmail
57+
}
58+
}
59+
`);
60+
61+
const UseCasesListingPage = () => {
62+
const getUseCasesList: {
63+
data: any;
64+
isLoading: boolean;
65+
error: any;
66+
isError: boolean;
67+
} = useQuery([`useCases_list`], () =>
68+
GraphQL(
69+
useCasesListDoc,
70+
{},
71+
{
72+
filters: { status: 'PUBLISHED' },
73+
}
74+
)
75+
);
76+
const router = useRouter();
77+
78+
return (
79+
<div className=" container pt-10 md:px-8 lg:pt-20">
80+
<div className="flex flex-col gap-2 p-3 md:p-0 lg:p-0 ">
81+
<Text variant="heading3xl">Recent UseCases</Text>
82+
<div className="flex flex-wrap justify-between gap-2 ">
83+
<Text variant="headingLg" fontWeight="medium">
84+
Recently updated and trending Use Cases on Asia-Pacific Climate Data
85+
Collaborative{' '}
86+
</Text>
87+
<Button
88+
kind="primary"
89+
className=" bg-secondaryOrange text-basePureBlack"
90+
onClick={() => {
91+
router.push('/datasets');
92+
}}
93+
>
94+
Explore all Use Cases
95+
</Button>
96+
</div>
97+
</div>
98+
<div>
99+
<Carousel className="flex w-full justify-between">
100+
<CarouselPrevious />
101+
102+
{getUseCasesList.isLoading ? (
103+
<div className="p-8">
104+
<Spinner />
105+
</div>
106+
) : (
107+
<CarouselContent className="p-4 ">
108+
{getUseCasesList &&
109+
getUseCasesList?.data?.useCases.length > 0 &&
110+
getUseCasesList?.data?.useCases.map((item: any, index: any) => (
111+
<CarouselItem
112+
key={item.id}
113+
className={cn(
114+
'h-2/4 basis-full pl-4 sm:basis-1/2 lg:basis-1/3',
115+
Styles.UseCaseList
116+
)}
117+
>
118+
<Card
119+
title={item.title}
120+
key={index}
121+
href={`/usecases/${item.id}`}
122+
metadataContent={[
123+
{
124+
icon: Icons.calendar,
125+
label: 'Date',
126+
value: formatDate(item.modified),
127+
},
128+
{
129+
icon: Icons.globe,
130+
label: 'Geography',
131+
value: item.metadata?.find(
132+
(meta: any) =>
133+
meta.metadataItem?.label === 'Geography'
134+
)?.value,
135+
},
136+
]}
137+
footerContent={[
138+
{
139+
icon: `/Sectors/${item?.sectors[0]?.name}.svg`,
140+
label: 'Sectors',
141+
},
142+
{ icon: '/fallback.svg', label: 'Published by' },
143+
]}
144+
imageUrl={`${process.env.NEXT_PUBLIC_BACKEND_URL}/${item.logo?.path.replace('/code/files/', '')}`}
145+
description={item.summary}
146+
iconColor="warning"
147+
variation={'collapsed'}
148+
/>
149+
</CarouselItem>
150+
))}
151+
</CarouselContent>
152+
)}
153+
<CarouselNext />
154+
</Carousel>
155+
</div>
156+
</div>
157+
);
158+
};
159+
160+
export default UseCasesListingPage;

app/[locale]/(user)/components/datasets.module.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@
88
}
99
}
1010
}
11+
.UseCaseList {
12+
a {
13+
min-height: 460px;
14+
max-height: 460px;
15+
@media screen and (max-width: 1120px) {
16+
min-height: 530px;
17+
max-height: 530px;
18+
}
19+
}
20+
}

app/[locale]/(user)/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { Content } from './components/Content';
22
import Datasets from './components/Datasets';
33
import Sectors from './components/Sectors';
4+
import UseCases from './components/UseCases';
45

56
export default async function Home() {
67
return (
78
<div className="bg-surfaceDefault">
89
<Content />
10+
<UseCases />
11+
<Sectors />
912
<Datasets />
10-
<Sectors/>
1113
</div>
1214
);
1315
}

0 commit comments

Comments
 (0)