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

Feature/testnet #85

Merged
merged 7 commits into from
Feb 12, 2022
2 changes: 1 addition & 1 deletion src/components/Chart/ApexPie.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function ApexPie(props) {

return (
<Chart
key={Math.random()}
key={options.theme.mode}
options={options}
series={series}
type="donut"
Expand Down
27 changes: 9 additions & 18 deletions src/components/Chart/ChartsApex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import { useNetwork } from 'hooks/useNetwork/useNetwork';

function ChartsApex() {
const { sharedState } = useAppContext();

const [isDarkMode] = useDarkMode();
let apexChartRef = useRef();

// * fetch the blocks first and extract the total number of contracts inside the trasactions
const [limit, setLimit] = useState(2 * 60);
Expand Down Expand Up @@ -193,22 +191,15 @@ function ChartsApex() {
// Bug tribute: chart not updating when updating state (fixed with adding random key)
// https://github.com/reactchartjs/react-chartjs-2/issues/90
return (
<div>
{/* <input
type="number"
value={limit}
onChange={(e) => setLimit(e.target.value)}></input> */}
<Chart
className={styles.container}
ref={apexChartRef}
key={Math.random()}
options={chartState.options}
series={chartState.series}
height={190}
width={'100%'}
type="area"
/>
</div>
<Chart
className={styles.container}
key={chartState.options.theme.mode}
options={chartState.options}
series={chartState.series}
height={190}
width={'100%'}
type="area"
/>
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Panel2/Panel2.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function Panel2(props) {

return (
<Rail className={styles.panelTwoContainer} scrollSpeed={1.8}>
{network === NETWORKS.MAINNET && (
{network.name === NETWORKS.MAINNET.name && (
<DetailCard
type
icon={<GiTwoCoins color="white" size="2.25rem" />}
Expand Down
45 changes: 11 additions & 34 deletions src/pages/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ export default function Blocks(props) {
const [pageCount, setPageCount] = useState(1);
const [totalRows, setTotalRows] = useState(0);

const [mainnetPage, setMainnetPage] = useState({
pageSize: 10,
pageIndex: 0,
pageCount: 1,
totalRows: 0,
});

const [testnetPage, setTestnetPage] = useState({
pageSize: 10,
pageIndex: 0,
pageCount: 1,
totalRows: 0,
});

const columns = [
{
Header: 'Block',
Expand Down Expand Up @@ -68,18 +54,22 @@ export default function Blocks(props) {
getBlocks
);

useEffect(() => {
// reset all pagination props on network change
setPageSize(10);
setPageIndex(0);
setPageCount(1);
setTotalRows(0);
}, [network]);

useEffect(() => {
if (data) {
let height = data[0].height;
if (network == NETWORKS.MAINNET) {
if (height > totalRows) {
setTotalRows(height);
}
} else if (network == NETWORKS.TESTNET) {
setTotalRows(height); // temp fix , need to get the total rows from the testnet
if (height > totalRows) {
setTotalRows(height);
}
}
}, [data, pageSize, network]);
}, [data, pageSize]);

useEffect(() => {
setPageCount(totalPages(totalRows, pageSize));
Expand Down Expand Up @@ -128,16 +118,3 @@ export default function Blocks(props) {
);
}
}

// export async function getServerSideProps() {
// const resp = await fetch(
// `${process.env.NEXT_PUBLIC_NEXUS_BASE_URL}/ledger/list/blocks?limit=50`
// );
// const data = await resp.json();

// return {
// props: {
// data: data.result,
// },
// };
// }
10 changes: 9 additions & 1 deletion src/pages/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Transactions(props) {
const [totalRows, setTotalRows] = useState(0);
const [rows, setRows] = useState([]);

const {network, getTransactions} = useNetwork();
const { network, getTransactions } = useNetwork();
const { isLoading, data, error } = useQuery(
['transactions', pageIndex, pageSize, network.name],
getTransactions
Expand All @@ -37,6 +37,14 @@ export default function Transactions(props) {
}
}, [data]);

useEffect(() => {
// reset all pagination props on network change
setPageSize(10);
setPageIndex(0);
setPageCount(1);
setTotalRows(0);
}, [network]);

useEffect(() => {
if (data) {
// console.log(data)
Expand Down
7 changes: 7 additions & 0 deletions src/types/FooterTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
BsApple,
BsBook,
BsChatLeftText,
BsDiscord,
BsFileEarmarkText,
BsGithub,
BsGlobe2,
Expand Down Expand Up @@ -66,6 +67,12 @@ export const FooterTypes = {
label: 'Price Talk',
icon: (props) => <BsChatLeftText {...props} />,
},
{
href: 'https://discord.gg/CtSrw26Y',
target: '_blank',
label: 'Discord',
icon: (props) => <BsDiscord {...props} />,
},
],
},
WALLET_LINKS: {
Expand Down