generated from idea2app/Next-Bootstrap-ts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scroll-list.tsx
50 lines (42 loc) · 1.46 KB
/
scroll-list.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
import { Loading } from 'idea-react';
import { GitRepository, RepositoryModel } from 'mobx-github';
import { observer } from 'mobx-react';
import { ScrollList } from 'mobx-restful-table';
import { cache, compose, errorLogger, translator } from 'next-ssr-middleware';
import { FC } from 'react';
import { Col, Container, Row } from 'react-bootstrap';
import { GitCard } from '../components/Git/Card';
import { PageHead } from '../components/PageHead';
import { repositoryStore } from '../models/Base';
import { i18n } from '../models/Translation';
export const getServerSideProps = compose(
errorLogger,
cache(),
translator(i18n),
async () => {
const list = await new RepositoryModel('Open-Source-Bazaar').getList();
return { props: JSON.parse(JSON.stringify({ list })) };
},
);
const ScrollListPage: FC<{ list: GitRepository[] }> = observer(({ list }) => (
<Container>
<PageHead title={i18n.t('scroll_list')} />
<h1 className="my-4">{i18n.t('scroll_list')}</h1>
{repositoryStore.downloading > 0 && <Loading />}
<ScrollList
translator={i18n}
store={repositoryStore}
renderList={allItems => (
<Row as="ul" className="list-unstyled g-4" xs={1} sm={2}>
{allItems.map(item => (
<Col key={item.id} as="li">
<GitCard className="h-100 shadow-sm" {...item} />
</Col>
))}
</Row>
)}
defaultData={list}
/>
</Container>
));
export default ScrollListPage;