Skip to content

Commit 64d70d9

Browse files
committed
remove accessmodels from the query and types
1 parent 0fc64d8 commit 64d70d9

File tree

1 file changed

+49
-54
lines changed
  • app/[locale]/(user)/datasets/[datasetIdentifier]/components/Resources

1 file changed

+49
-54
lines changed

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

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Button, Spinner, Tag, Text } from 'opub-ui';
1010
import { GraphQL } from '@/lib/api';
1111
import { formatDate } from '@/lib/utils';
1212

13-
const datasetResourceQuery = graphql(`
13+
const datasetResourceQuery: any = graphql(`
1414
query datasetResources($datasetId: UUID!) {
1515
datasetResources(datasetId: $datasetId) {
1616
id
@@ -19,18 +19,7 @@ const datasetResourceQuery = graphql(`
1919
type
2020
name
2121
description
22-
accessModels {
23-
name
24-
description
25-
type
26-
modelResources {
27-
fields {
28-
format
29-
fieldName
30-
description
31-
}
32-
}
33-
}
22+
3423
schema {
3524
fieldName
3625
id
@@ -47,7 +36,7 @@ const datasetResourceQuery = graphql(`
4736
const Resources = () => {
4837
const params = useParams();
4938

50-
const { data, isLoading } = useQuery(
39+
const getResourceDetails: { data: any; isLoading: boolean } = useQuery(
5140
[`resources_${params.datasetIdentifier}`],
5241
() =>
5342
GraphQL(
@@ -87,62 +76,68 @@ const Resources = () => {
8776
}));
8877
}
8978
});
90-
}, [data]);
79+
}, [getResourceDetails.data]);
9180

9281
return (
9382
<div className="w-full">
94-
{isLoading ? (
83+
{getResourceDetails.isLoading ? (
9584
<div className="mt-8 flex justify-center">
9685
<Spinner />
9786
</div>
98-
) : data && data?.datasetResources?.length > 0 ? (
87+
) : getResourceDetails.data &&
88+
getResourceDetails.data?.datasetResources?.length > 0 ? (
9989
<>
10090
<Text variant="bodyLg" className="mx-6 lg:mx-0">
10191
Downloadable Resources
10292
</Text>
10393
<div className="mx-6 mt-5 flex flex-col gap-8 bg-surfaceDefault p-6 lg:mx-0">
104-
{data?.datasetResources.map((item: any, index: number) => (
105-
<div key={index} className="flex flex-wrap justify-between gap-4">
106-
<div className="gap flex flex-col lg:w-4/5">
107-
<div className="item flex items-center gap-2">
108-
<Text variant="headingMd">{item.name}</Text>
109-
<Tag>{item.fileDetails.format}</Tag>
94+
{getResourceDetails.data?.datasetResources.map(
95+
(item: any, index: number) => (
96+
<div
97+
key={index}
98+
className="flex flex-wrap justify-between gap-4"
99+
>
100+
<div className="gap flex flex-col lg:w-4/5">
101+
<div className="item flex items-center gap-2">
102+
<Text variant="headingMd">{item.name}</Text>
103+
<Tag>{item.fileDetails.format}</Tag>
104+
</div>
105+
<div>
106+
<Text>Updated:</Text>
107+
<Text>{formatDate(item.modified)}</Text>
108+
</div>
109+
<div className="flex flex-col">
110+
<div
111+
ref={(el) => (descriptionRefs.current[index] = el)}
112+
className={!showMore[index] ? 'line-clamp-2' : ''}
113+
>
114+
<Text>{item.description}</Text>
115+
</div>
116+
{isDescriptionLong[index] && (
117+
<Button
118+
className="self-start p-2"
119+
onClick={() => toggleShowMore(index)}
120+
variant="interactive"
121+
size="slim"
122+
kind="tertiary"
123+
>
124+
{showMore[index] ? 'Show less' : 'Show more'}
125+
</Button>
126+
)}
127+
</div>
110128
</div>
111129
<div>
112-
<Text>Updated:</Text>
113-
<Text>{formatDate(item.modified)}</Text>
114-
</div>
115-
<div className="flex flex-col">
116-
<div
117-
ref={(el) => (descriptionRefs.current[index] = el)}
118-
className={!showMore[index] ? 'line-clamp-2' : ''}
130+
<Link
131+
href={`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/resource/${item.id}`}
132+
target="_blank"
133+
className="flex justify-center"
119134
>
120-
<Text>{item.description}</Text>
121-
</div>
122-
{isDescriptionLong[index] && (
123-
<Button
124-
className="self-start p-2"
125-
onClick={() => toggleShowMore(index)}
126-
variant="interactive"
127-
size="slim"
128-
kind="tertiary"
129-
>
130-
{showMore[index] ? 'Show less' : 'Show more'}
131-
</Button>
132-
)}
135+
<Button>Download</Button>
136+
</Link>
133137
</div>
134138
</div>
135-
<div>
136-
<Link
137-
href={`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/download/resource/${item.id}`}
138-
target="_blank"
139-
className="flex justify-center"
140-
>
141-
<Button>Download</Button>
142-
</Link>
143-
</div>
144-
</div>
145-
))}
139+
)
140+
)}
146141
</div>
147142
</>
148143
) : (

0 commit comments

Comments
 (0)