-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
89 lines (85 loc) · 2.52 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import * as React from 'react';
import { Box, Tab, TabList, TabPanel, Tabs } from '@mui/joy';
import {
ChangelogContainer,
ChangelogList,
useChangelogs,
ChangelogListBase,
groupChangelogsByComponents,
GroupBy,
} from '../dist/updatehive-react';
export const App: React.FC = () => {
const API_KEY = import.meta.env.VITE_UPDATEHIVE_API_KEY as string;
const PRODUCT = import.meta.env.VITE_UPDATEHIVE_PRODUCT as string;
const serviceURL = import.meta.env.VITE_UPDATEHIVE_URL as string;
const { loading, error, data } = useChangelogs({
connection: {
API_KEY,
url: serviceURL,
},
changelogs: {
product: PRODUCT,
},
});
if (error) {
console.error(error);
}
return (
<Box>
<h1>UpdateHive - React Client Component</h1>
<h3>Examples using UpdateHive react components</h3>
<Tabs>
<TabList>
<Tab>Hook</Tab>
<Tab>Minimal</Tab>
<Tab>ChangelogList</Tab>
<Tab>Base</Tab>
</TabList>
<TabPanel value={0}>
<h3>Example using UpdateHive react hook</h3>
<div>
{loading || error || data === undefined ? (
<div>Loading changelogs ...</div>
) : (
<div>
<div className="hook table" key={'header'}>
<div className="hook div">Version</div>
<div className="hook div">Description</div>
</div>
{data.map((changelog, index) => (
<div className="hook table" key={`changelog-${index}`}>
<div className="hook div">{changelog.version}</div>
<div className="hook div">{changelog.description}</div>
</div>
))}
</div>
)}
</div>
</TabPanel>
<TabPanel value={1}>
<ChangelogContainer
API_KEY={API_KEY}
product={PRODUCT}
config={{ url: serviceURL }}
>
<ChangelogList groupBy={GroupBy.NONE} hideEntryType />
</ChangelogContainer>
</TabPanel>
<TabPanel value={2}>
<ChangelogContainer
API_KEY={API_KEY}
product={PRODUCT}
config={{ url: serviceURL }}
>
<ChangelogList />
</ChangelogContainer>
</TabPanel>
<TabPanel value={3}>
<ChangelogListBase
changelogs={data && groupChangelogsByComponents(data)}
/>
</TabPanel>
</Tabs>
</Box>
);
};