Skip to content

Commit 71c7b7e

Browse files
committed
Add a chart specific page
1 parent 48421f6 commit 71c7b7e

File tree

1 file changed

+133
-0
lines changed
  • app/[locale]/dashboard/[entityType]/[entitySlug]/charts/[chartID]

1 file changed

+133
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
'use client';
2+
3+
import { useState } from 'react';
4+
import Image from 'next/image';
5+
import { useParams } from 'next/navigation';
6+
import { Button, Select, Tab, TabList, Tabs, Text } from 'opub-ui';
7+
8+
import { Icons } from '@/components/icons';
9+
import TitleBar from '../../components/title-bar';
10+
11+
const ChartDetails = () => {
12+
const params = useParams<{
13+
entityType: string;
14+
entitySlug: string;
15+
chartID: string;
16+
}>();
17+
18+
console.log('Chart ID provided :: ', params.chartID);
19+
20+
type LoadedChartType = 'TypeResourceChartImage' | 'TypeResourceChart';
21+
22+
const [chartPreviewType, setChartPreviewType] =
23+
useState<LoadedChartType>('TypeResourceChart');
24+
25+
return (
26+
<div>
27+
<TitleBar
28+
label={'Chart Name'}
29+
title={'Chart name from the server'}
30+
goBackURL={`/dashboard/${params.entityType}/${params.entitySlug}/charts`}
31+
onSave={(val: any) => {
32+
console.log(val);
33+
}}
34+
loading={false}
35+
status={'success'}
36+
setStatus={() => {}}
37+
/>
38+
39+
<div className="border-t-2 border-solid border-greyExtralight pt-8">
40+
{chartPreviewType === 'TypeResourceChartImage' ? (
41+
<ChartImagePreview />
42+
) : (
43+
<ChartGenPreview />
44+
)}
45+
</div>
46+
</div>
47+
);
48+
};
49+
50+
export default ChartDetails;
51+
52+
const ChartImagePreview = () => {
53+
return (
54+
<div className="flex flex-col items-center justify-center gap-4">
55+
<Image
56+
src=""
57+
alt="Chart Image"
58+
width={500}
59+
height={500}
60+
className="rounded-4 border-1 border-solid border-greyExtralight"
61+
/>
62+
<Button kind="primary">Publish Chart</Button>
63+
</div>
64+
);
65+
};
66+
67+
const ChartGenPreview = () => {
68+
type TabValue = 'DATA' | 'CUSTOMIZE';
69+
const [selectedTab, setSelectedTab] = useState<TabValue>('DATA');
70+
71+
const handleTabClick = (item: { label: string; id: TabValue }) => {
72+
setSelectedTab(item.id);
73+
};
74+
75+
return (
76+
<div className="flex flex-row justify-center gap-6">
77+
<div className="flex flex-[7] justify-center">
78+
<Image
79+
src=""
80+
alt="Chart Image"
81+
className="w-full rounded-4 border-1 border-solid border-greyExtralight object-contain"
82+
/>
83+
</div>
84+
<div className="flex flex-[3] flex-col rounded-4 border-2 border-solid border-greyExtralight p-3">
85+
<Tabs value={selectedTab}>
86+
<TabList fitted border>
87+
<Tab
88+
theme="dataSpace"
89+
value="DATA"
90+
onClick={() => handleTabClick({ label: 'DATA', id: 'DATA' })}
91+
>
92+
DATA
93+
</Tab>
94+
<Tab
95+
theme="dataSpace"
96+
value="CUSTOMIZE"
97+
onClick={() =>
98+
handleTabClick({ label: 'CUSTOMIZE', id: 'CUSTOMIZE' })
99+
}
100+
>
101+
CUSTOMIZE
102+
</Tab>
103+
</TabList>
104+
</Tabs>
105+
106+
{selectedTab === 'DATA' ? (
107+
<div>
108+
<Select
109+
name="selectDataset"
110+
label="Select Dataset"
111+
options={[]}
112+
required
113+
/>
114+
<Select
115+
name="selectResource"
116+
label="Select Resource"
117+
options={[]}
118+
required
119+
/>
120+
<Select
121+
name="selectChartType"
122+
label="Select Chart Type"
123+
options={[]}
124+
required
125+
/>
126+
</div>
127+
) : (
128+
<div></div>
129+
)}
130+
</div>
131+
</div>
132+
);
133+
};

0 commit comments

Comments
 (0)