-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCardPage.tsx
More file actions
40 lines (36 loc) · 1.02 KB
/
CardPage.tsx
File metadata and controls
40 lines (36 loc) · 1.02 KB
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
import { ComponentClass, FC } from 'react';
import { Col, Pagination, Row } from 'react-bootstrap';
import { SearchPageMeta } from '../../models/System';
export interface CardPageProps extends SearchPageMeta {
Card: ComponentClass<Record<string, unknown>> | FC<Record<string, unknown>>;
cardLinkOf?: (id: string) => string;
pageLinkOf: (page: number) => string;
}
export const CardPage: FC<CardPageProps> = ({
Card,
cardLinkOf,
currentPage,
pageIndex,
pageCount,
pageLinkOf,
}) => (
<>
<Row className="g-3 my-3" xs={1} md={2} lg={3}>
{currentPage.map(item => (
<Col key={item.id as string}>
<Card className="h-100" linkOf={cardLinkOf} {...item} />
</Col>
))}
</Row>
<Pagination className="justify-content-center" size="lg">
<Pagination.Prev
href={pageLinkOf(pageIndex - 1)}
disabled={pageIndex === 1}
/>
<Pagination.Next
href={pageLinkOf(pageIndex + 1)}
disabled={pageIndex === pageCount}
/>
</Pagination>
</>
);