diff --git a/src/components/OrchDelegatorViewer.js b/src/components/OrchDelegatorViewer.js
index fa591f8..15128f0 100644
--- a/src/components/OrchDelegatorViewer.js
+++ b/src/components/OrchDelegatorViewer.js
@@ -1,13 +1,43 @@
-import React from "react";
+import React, { useState, useEffect } from 'react';
import ScrollContainer from "react-indiana-drag-scroll";
import Address from "./OrchAddressViewer";
+import { Pagination } from "@mantine/core";
+
+const itemsPerPage = 10;
const OrchDelegatorViewer = (obj) => {
+ const [activePage, setPage] = useState(1);
let delegators = obj.delegators;
+ let sortedList = [];
if (delegators && delegators.length) {
+ let tmpCopy = [...delegators];
+ while (tmpCopy.length) {
+ let ticketIdx2 = tmpCopy.length - 1;
+ let largestIdx = 0;
+ let largestValue = 0;
+
+ // Find current O with most ticket wins in Eth
+ while (ticketIdx2 >= 0) {
+ const currentOrch = tmpCopy[ticketIdx2];
+ let thisVal = currentOrch.bondedAmount;
+
+ if (thisVal > largestValue) {
+ largestIdx = ticketIdx2;
+ largestValue = thisVal;
+ }
+ ticketIdx2 -= 1;
+ }
+ // Push current biggest list
+ sortedList.push(tmpCopy[largestIdx]);
+ // Remove from list
+ tmpCopy.splice(largestIdx, 1);
+ }
+
+ const totalPages = (delegators.length + (itemsPerPage - (delegators.length % itemsPerPage))) / itemsPerPage;
+
return (
-
+
{delegators.length} Current Delegators
@@ -15,22 +45,36 @@ const OrchDelegatorViewer = (obj) => {
{
- delegators.map((delObj, idx) => {
- return (
-
-
-
+ sortedList.map((delObj, idx) => {
+ const tmp = idx - ((activePage - 1) * itemsPerPage);
+ if (tmp >= 0 && tmp < itemsPerPage) {
+ return (
+
+
+
+
{parseFloat(delObj.bondedAmount).toFixed(2)} LPT since round {delObj.startRound}
+
-
-
{parseFloat(delObj.bondedAmount).toFixed(2)} LPT since round {delObj.startRound}
-
-
- )
+ )
+ }
+ return null;
})
}
+
+ {totalPages > 1 ?
+
+ : null}
+
)
diff --git a/src/components/WinnerMonth.js b/src/components/WinnerMonth.js
index 8b07f0f..0747d69 100644
--- a/src/components/WinnerMonth.js
+++ b/src/components/WinnerMonth.js
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react'
+import React, { useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { VictoryPie } from 'victory';
import Winner from '../components/WinnerStat';
diff --git a/src/components/eventViewer.js b/src/components/eventViewer.js
index 94f7a47..1101502 100644
--- a/src/components/eventViewer.js
+++ b/src/components/eventViewer.js
@@ -1,6 +1,7 @@
import React, { useState, useRef } from "react";
import EventButton from "./eventButton";
import ScrollContainer from 'react-indiana-drag-scroll';
+import { Pagination } from "@mantine/core";
import Filter from './filterComponent';
const thresholdStaking = 0.001;
@@ -18,8 +19,10 @@ const ticketTransferColour = "rgba(88, 91, 42, 0.3)";
const greyColour = "rgba(122, 128, 127, 0.4)";
const defaultIncrementMaxShown = 50;
+const itemsPerPage = 10;
const EventViewer = (obj) => {
+ const [activePage, setPage] = useState(1);
const listInnerRef = useRef();
const [filterActivated, setFilterActivated] = useState(true);
const [rewardActivated, setRewardActivated] = useState(true);
@@ -55,18 +58,6 @@ const EventViewer = (obj) => {
let unbondActivatedColour;
unbondActivatedColour = unbondActivated ? unbondColour : greyColour;
- const updateOnScroll = () => {
- if (unfiltered == 0) {
- return;
- }
- if (listInnerRef.current) {
- const { scrollTop, scrollHeight, clientHeight } = listInnerRef.current.container.current;
- if (scrollTop + clientHeight === scrollHeight) {
- obj.setMaxAmount(obj.maxAmount + defaultIncrementMaxShown);
- }
- }
- }
-
let eventList = [];
let thisEvent = {};
let updateEventsIdx = obj.updateEvents.length - 1;
@@ -428,57 +419,27 @@ const EventViewer = (obj) => {
console.log("bork");
}
-
- if (unfiltered < obj.maxAmount) {
- unfiltered++;
- if (prevBlock === thisEvent.blockNumber) {
- eventList.push(
);
- } else {
- prevBlock = thisEvent.blockNumber;
- eventList.push(
);
- }
+ unfiltered++;
+ if (prevBlock === thisEvent.blockNumber) {
+ eventList.push(
);
+ } else {
+ prevBlock = thisEvent.blockNumber;
+ eventList.push(
);
}
- else {
- hidden++;
- }
- }
-
- let showMoreButton;
- if (hidden == 0) {
- showMoreButton =
-
-
-
- ☑️ Reached end of results
-
-
-
- } else {
- showMoreButton =
-
-
-
-
-
}
let filterBit;
@@ -499,14 +460,30 @@ const EventViewer = (obj) => {
-
-
+
+
- {eventList}
-
- {showMoreButton}
+ {
+ eventList.map((delObj, idx) => {
+ const tmp = idx - ((activePage - 1) * itemsPerPage);
+ if (tmp >= 0 && tmp < itemsPerPage) {
+ return (
+
+
+
+
{idx}
+
+
+ {delObj}
+
+
+
+ )
+ }
+ return null;
+ })
+ }
@@ -555,6 +532,9 @@ const EventViewer = (obj) => {
+