Skip to content

Commit 732061a

Browse files
committed
add resource chart image details query
1 parent 5596452 commit 732061a

File tree

1 file changed

+47
-5
lines changed
  • app/[locale]/dashboard/[entityType]/[entitySlug]/charts/[chartID]

1 file changed

+47
-5
lines changed

app/[locale]/dashboard/[entityType]/[entitySlug]/charts/[chartID]/page.tsx

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,67 @@
22

33
import { useState } from 'react';
44
import Image from 'next/image';
5-
import { useParams } from 'next/navigation';
5+
import { useParams, useSearchParams } from 'next/navigation';
6+
import { graphql } from '@/gql';
7+
import { useQuery } from '@tanstack/react-query';
68
import { Button, Select, Tab, TabList, Tabs, Text } from 'opub-ui';
79

10+
import { GraphQL } from '@/lib/api';
811
import { Icons } from '@/components/icons';
912
import TitleBar from '../../components/title-bar';
1013

14+
const getResourceChartImageDetailsDoc: any = graphql(`
15+
query getResourceChartImageDetails($imageId: UUID!) {
16+
resourceChartImage(imageId: $imageId) {
17+
description
18+
dataset {
19+
id
20+
title
21+
slug
22+
}
23+
id
24+
name
25+
image {
26+
name
27+
path
28+
size
29+
url
30+
width
31+
height
32+
}
33+
status
34+
}
35+
}
36+
`);
37+
1138
const ChartDetails = () => {
1239
const params = useParams<{
1340
entityType: string;
1441
entitySlug: string;
1542
chartID: string;
1643
}>();
1744

18-
console.log('Chart ID provided :: ', params.chartID);
45+
const searchParams = useSearchParams();
1946

20-
type LoadedChartType = 'TypeResourceChartImage' | 'TypeResourceChart';
47+
const chartPreviewType = searchParams.get('type');
2148

22-
const [chartPreviewType, setChartPreviewType] =
23-
useState<LoadedChartType>('TypeResourceChart');
49+
const getResourceChartDetailsRes: {
50+
data: any;
51+
isLoading: boolean;
52+
refetch: any;
53+
error: any;
54+
isError: boolean;
55+
} = useQuery([`getResourceChartImageDetails_${params.chartID}`], () =>
56+
GraphQL(
57+
getResourceChartImageDetailsDoc,
58+
{
59+
[params.entityType]: params.entitySlug,
60+
},
61+
{
62+
imageId: params.chartID,
63+
}
64+
)
65+
);
2466

2567
return (
2668
<div>

0 commit comments

Comments
 (0)