Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the max total rows of the tables and add pagination #1739

Merged
merged 7 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions components/Table/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type PaginationProps = {
pageCount: number;
canNextPage: boolean;
canPreviousPage: boolean;
compact: boolean;
setPage: (page: number) => void;
previousPage: () => void;
nextPage: () => void;
Expand All @@ -24,6 +25,7 @@ const Pagination: FC<PaginationProps> = React.memo(
pageCount,
canNextPage = true,
canPreviousPage = true,
compact = false,
setPage,
nextPage,
previousPage,
Expand All @@ -34,7 +36,7 @@ const Pagination: FC<PaginationProps> = React.memo(
const toLastPage = () => setPage(pageCount - 1);

return (
<PaginationContainer>
<PaginationContainer compact={compact}>
<span>
<ArrowButton onClick={firstPage} disabled={!canPreviousPage}>
<LeftEndArrowIcon />
Expand Down Expand Up @@ -67,9 +69,9 @@ const PageInfo = styled.span`
color: ${(props) => props.theme.colors.selectedTheme.gray};
`;

const PaginationContainer = styled(GridDivCenteredCol)`
const PaginationContainer = styled(GridDivCenteredCol)<{ compact: boolean }>`
grid-template-columns: auto 1fr auto;
padding: 15px 12px;
padding: ${(props) => (props.compact ? '10px' : '15px')} 12px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
justify-items: center;
Expand Down
5 changes: 4 additions & 1 deletion components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type TablePalette = 'primary';

const CARD_HEIGHT = '40px';
const MAX_PAGE_ROWS = 100;
const MAX_TOTAL_ROWS = 1000;
const MAX_TOTAL_ROWS = 9999;

type ColumnWithSorting<D extends object = {}> = Column<D> & {
sortType?: string | ((rowA: Row<any>, rowB: Row<any>) => -1 | 1);
Expand Down Expand Up @@ -66,6 +66,7 @@ type TableProps = {
sortBy?: object[];
showShortList?: boolean;
lastRef?: any;
compactPagination?: boolean;
};

export const Table: FC<TableProps> = ({
Expand All @@ -86,6 +87,7 @@ export const Table: FC<TableProps> = ({
showShortList,
sortBy = [],
lastRef = null,
compactPagination = false,
}) => {
const memoizedColumns = useMemo(
() => columns,
Expand Down Expand Up @@ -209,6 +211,7 @@ export const Table: FC<TableProps> = ({
</TableContainer>
{showPagination && !showShortList && data.length > (pageSize ?? MAX_PAGE_ROWS) ? (
<Pagination
compact={compactPagination}
pageIndex={pageIndex}
pageCount={pageCount}
canNextPage={canNextPage}
Expand Down
2 changes: 1 addition & 1 deletion constants/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const DEFAULT_NUMBER_OF_TRADES: number = 16;
export const MAX_TIMESTAMP: number = 8640000000000000;

// for Fee History
export const DEFAULT_NUMBER_OF_FUTURES_FEE: number = 5000;
export const DEFAULT_NUMBER_OF_FUTURES_FEE: number = 9999;

// leverage adjustment
export const DEFAULT_NP_LEVERAGE_ADJUSTMENT: number = 0.9975;
Expand Down
7 changes: 6 additions & 1 deletion sections/dashboard/Stake/EscrowTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ const EscrowTable = () => {
<DesktopOnlyView>
<StyledTable
data={escrowData}
showPagination={false}
compactPagination={true}
pageSize={10}
showPagination={true}
columnsDeps={columnsDeps}
columns={[
{
Expand Down Expand Up @@ -165,6 +167,9 @@ const EscrowTable = () => {
<MobileOrTabletView>
<StyledTable
data={escrowData}
compactPagination={true}
pageSize={5}
showPagination={true}
columnsDeps={columnsDeps}
columns={[
{
Expand Down