Skip to content

Commit 5b196b1

Browse files
committed
Merge branch 'dev' into 255-update-ui-as-per-the-designs
2 parents 3da0720 + 1dd920d commit 5b196b1

File tree

12 files changed

+633
-132
lines changed

12 files changed

+633
-132
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
'use client';
2+
3+
import { useState } from 'react';
4+
import Image from 'next/image';
5+
import { useParams, useSearchParams } from 'next/navigation';
6+
import { graphql } from '@/gql';
7+
import { useQuery } from '@tanstack/react-query';
8+
import { Button, Select, Tab, TabList, Tabs, Text } from 'opub-ui';
9+
10+
import { GraphQL } from '@/lib/api';
11+
import { Icons } from '@/components/icons';
12+
import TitleBar from '../../components/title-bar';
13+
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+
38+
const ChartDetails = () => {
39+
const params = useParams<{
40+
entityType: string;
41+
entitySlug: string;
42+
chartID: string;
43+
}>();
44+
45+
const searchParams = useSearchParams();
46+
47+
const chartPreviewType = searchParams.get('type');
48+
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+
);
66+
67+
return (
68+
<div>
69+
<TitleBar
70+
label={'Chart Name'}
71+
title={'Chart name from the server'}
72+
goBackURL={`/dashboard/${params.entityType}/${params.entitySlug}/charts`}
73+
onSave={(val: any) => {
74+
console.log(val);
75+
}}
76+
loading={false}
77+
status={'success'}
78+
setStatus={() => {}}
79+
/>
80+
81+
<div className="border-t-2 border-solid border-greyExtralight pt-8">
82+
{chartPreviewType === 'TypeResourceChartImage' ? (
83+
<ChartImagePreview />
84+
) : (
85+
<ChartGenPreview />
86+
)}
87+
</div>
88+
</div>
89+
);
90+
};
91+
92+
export default ChartDetails;
93+
94+
const ChartImagePreview = () => {
95+
return (
96+
<div className="flex flex-col items-center justify-center gap-4">
97+
<Image
98+
src=""
99+
alt="Chart Image"
100+
width={500}
101+
height={500}
102+
className="rounded-4 border-1 border-solid border-greyExtralight"
103+
/>
104+
<Button kind="primary">Publish Chart</Button>
105+
</div>
106+
);
107+
};
108+
109+
const ChartGenPreview = () => {
110+
type TabValue = 'DATA' | 'CUSTOMIZE';
111+
const [selectedTab, setSelectedTab] = useState<TabValue>('DATA');
112+
113+
const handleTabClick = (item: { label: string; id: TabValue }) => {
114+
setSelectedTab(item.id);
115+
};
116+
117+
return (
118+
<div className="flex flex-row justify-center gap-6">
119+
<div className="flex flex-[7] justify-center">
120+
<Image
121+
src=""
122+
alt="Chart Image"
123+
className="w-full rounded-4 border-1 border-solid border-greyExtralight object-contain"
124+
/>
125+
</div>
126+
<div className="flex flex-[3] flex-col rounded-4 border-2 border-solid border-greyExtralight p-3">
127+
<Tabs value={selectedTab}>
128+
<TabList fitted border>
129+
<Tab
130+
theme="dataSpace"
131+
value="DATA"
132+
onClick={() => handleTabClick({ label: 'DATA', id: 'DATA' })}
133+
>
134+
DATA
135+
</Tab>
136+
<Tab
137+
theme="dataSpace"
138+
value="CUSTOMIZE"
139+
onClick={() =>
140+
handleTabClick({ label: 'CUSTOMIZE', id: 'CUSTOMIZE' })
141+
}
142+
>
143+
CUSTOMIZE
144+
</Tab>
145+
</TabList>
146+
</Tabs>
147+
148+
{selectedTab === 'DATA' ? (
149+
<div>
150+
<Select
151+
name="selectDataset"
152+
label="Select Dataset"
153+
options={[]}
154+
required
155+
/>
156+
<Select
157+
name="selectResource"
158+
label="Select Resource"
159+
options={[]}
160+
required
161+
/>
162+
<Select
163+
name="selectChartType"
164+
label="Select Chart Type"
165+
options={[]}
166+
required
167+
/>
168+
</div>
169+
) : (
170+
<div></div>
171+
)}
172+
</div>
173+
</div>
174+
);
175+
};

0 commit comments

Comments
 (0)