Skip to content

Commit

Permalink
fix: added initial filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Dec 12, 2024
1 parent 29db517 commit cf4010d
Show file tree
Hide file tree
Showing 20 changed files with 1,358 additions and 82 deletions.
64 changes: 50 additions & 14 deletions src/components/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTheme } from '@mui/system';
import { Box, useTheme } from '@mui/system';
import InitialPagination from 'rc-pagination';
import { useState } from 'react';
import React, { useState } from 'react';

import { PAGE_SIZE } from '../configs/configs';
import { texts } from '../helpers/texts/texts';
Expand All @@ -13,13 +13,17 @@ export interface PaginationProps {
withoutQuery?: boolean;
borderSize?: number;
isSmall?: boolean;
setCurrentPageState?: (page: number) => void;
filtering?: boolean;
}

export function Pagination({
totalItems,
forcePage,
borderSize = 10,
isSmall,
setCurrentPageState,
filtering,
}: PaginationProps) {
const theme = useTheme();

Expand Down Expand Up @@ -57,7 +61,7 @@ export function Pagination({
'.rc-pagination-prev, .rc-pagination-next': {
display: 'inline-flex',
flex: 1,
a: {
'a, .Pagination_item': {
width: '100%',
cursor: 'pointer',
position: 'relative',
Expand Down Expand Up @@ -117,7 +121,7 @@ export function Pagination({
},
},
'.rc-pagination-disabled': {
a: {
'a, .Pagination_item': {
cursor: 'not-allowed',
'&:before': {
color: '$textDisabled',
Expand All @@ -129,7 +133,7 @@ export function Pagination({
},
},
'.rc-pagination-next': {
a: {
'a, .Pagination_item': {
justifyContent: 'flex-end',
ml: 8,
mr: 15,
Expand All @@ -146,7 +150,7 @@ export function Pagination({
},
},
'.rc-pagination-prev': {
a: {
'a, .Pagination_item': {
flexDirection: 'row-reverse',
justifyContent: 'flex-end',
mr: 8,
Expand All @@ -165,7 +169,7 @@ export function Pagination({
},
'.rc-pagination-item, .rc-pagination-jump-prev, .rc-pagination-jump-next':
{
a: {
'a, .Pagination_item': {
color: '$textDisabled',
display: 'inline-flex',
alignItems: 'center',
Expand Down Expand Up @@ -210,7 +214,7 @@ export function Pagination({
},
},
'&-active': {
a: {
'a, .Pagination_item': {
cursor: 'default',
color: '$text',
'&:after': {
Expand All @@ -220,7 +224,7 @@ export function Pagination({
},
},
hover: {
a: {
'a, .Pagination_item': {
color: theme.palette.$text,
span: {
color: theme.palette.$text,
Expand Down Expand Up @@ -262,27 +266,59 @@ export function Pagination({
}}
itemRender={(current, type) => {
if (type === 'page') {
return (
return setCurrentPageState && filtering ? (
<Box
className="Pagination_item"
onClick={() => setCurrentPageState(current)}>
<span>{current}</span>
</Box>
) : (
<Link href={`/${current}/`} scroll>
<span>{current}</span>
</Link>
);
}
if (type === 'prev') {
return <Link href={`/${current}/`} scroll />;
return setCurrentPageState && filtering ? (
<Box
className="Pagination_item"
onClick={() => setCurrentPageState(current)}
/>
) : (
<Link href={`/${current}/`} scroll />
);
}
if (type === 'next') {
return <Link href={`/${current}/`} scroll />;
return setCurrentPageState && filtering ? (
<Box
className="Pagination_item"
onClick={() => setCurrentPageState(current)}
/>
) : (
<Link href={`/${current}/`} scroll />
);
}
if (type === 'jump-prev') {
return (
return setCurrentPageState && filtering ? (
<Box
className="Pagination_item"
onClick={() => setCurrentPageState(current)}>
<span>...</span>
</Box>
) : (
<Link href={`/${current}/`} scroll>
<span>...</span>
</Link>
);
}
if (type === 'jump-next') {
return (
return setCurrentPageState && filtering ? (
<Box
className="Pagination_item"
onClick={() => setCurrentPageState(current)}>
<span>...</span>
</Box>
) : (
<Link href={`/${current}/`} scroll>
<span>...</span>
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function ProposalDetailsInitializer({
useEffect(() => {
if (proposalData && !proposalData.formattedData.isFinished) {
startActiveProposalDetailsPolling(+id);
() => stopActiveProposalDetailsPolling();
return () => stopActiveProposalDetailsPolling();
}
}, [proposalData?.proposalData.id]);

Expand Down
Loading

1 comment on commit cf4010d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.