From fbf42076800c2327642256bf13ef24fffa9c2c5d Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Sun, 20 Apr 2025 09:51:57 +0200 Subject: [PATCH] Add theme --- src/components/Minting/Minting.tsx | 78 +++++++++++++++--------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/src/components/Minting/Minting.tsx b/src/components/Minting/Minting.tsx index de16e09..84697c8 100644 --- a/src/components/Minting/Minting.tsx +++ b/src/components/Minting/Minting.tsx @@ -9,31 +9,20 @@ import { DialogTitle, Divider, IconButton, - InputBase, - InputLabel, Snackbar, Typography, + useTheme, } from '@mui/material'; -import React, { - useCallback, - useContext, - useEffect, - useMemo, - useState, -} from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import CloseIcon from '@mui/icons-material/Close'; -import { MyContext, getBaseApiReact } from '../../App'; +import { getBaseApiReact } from '../../App'; import { executeEvent, subscribeToEvent, unsubscribeFromEvent, } from '../../utils/events'; import { getFee, getNameOrAddress } from '../../background'; -import CopyToClipboard from 'react-copy-to-clipboard'; -import { AddressBox } from '../../styles/App-styles'; import { Spacer } from '../../common/Spacer'; -import Copy from '../../assets/svgs/Copy.svg'; -import { Loader } from '../Loader'; import { FidgetSpinner } from 'react-loader-spinner'; import { useModal } from '../../common/useModal'; @@ -56,15 +45,18 @@ export const Minting = ({ const [isLoading, setIsLoading] = useState(false); const { show: showKey, message } = useModal(); const { isShow: isShowNext, onOk, show: showNext } = useModal(); + const theme = useTheme(); const [info, setInfo] = useState(null); const [names, setNames] = useState({}); const [accountInfos, setAccountInfos] = useState({}); const [showWaitDialog, setShowWaitDialog] = useState(false); + const isPartOfMintingGroup = useMemo(() => { if (groups?.length === 0) return false; return !!groups?.find((item) => item?.groupId?.toString() === '694'); }, [groups]); + const getMintingAccounts = useCallback(async () => { try { const url = `${getBaseApiReact()}/admin/mintingaccounts`; @@ -107,7 +99,7 @@ export const Minting = ({ }); } } catch (error) { - // error + console.log(error); } }; @@ -133,6 +125,7 @@ export const Minting = ({ setAccountInfo(data); } } catch (error) { + console.log(error); } finally { if (!others) { setIsLoading(false); @@ -254,7 +247,6 @@ export const Minting = ({ window .sendMessage( 'ADMIN_ACTION', - { type: 'removemintingaccount', value: val, @@ -358,7 +350,6 @@ export const Minting = ({ if (findRewardShare) { return true; // Exit early if found } - await sleep(pollingInterval); // Wait before the next poll } @@ -511,7 +502,7 @@ export const Minting = ({ const _blocksNeed = () => { if (accountInfo?.level === 0) { - return 7200; + return 7200; // TODO manage these magic numbers in a proper location } else if (accountInfo?.level === 1) { return 72000; } else if (accountInfo?.level === 2) { @@ -562,11 +553,11 @@ export const Minting = ({ fullScreen sx={{ '& .MuiDialog-paper': { + height: '100vh', margin: 0, maxWidth: '100%', - width: '100%', - height: '100vh', overflow: 'hidden', // Prevent scrollbars + width: '100%', }, }} > @@ -583,6 +574,7 @@ export const Minting = ({ > + )} Account: {handleNames(accountInfo?.address)} + Level: {accountInfo?.level} + blocks remaining until next level: {_levelUpBlocks()} + This node is minting: {nodeInfos?.isMintingPossible?.toString()} @@ -630,11 +625,11 @@ export const Minting = ({ {isPartOfMintingGroup && !accountIsMinting && ( + + ))} @@ -744,7 +741,7 @@ export const Minting = ({ {!isPartOfMintingGroup && ( @@ -768,7 +765,7 @@ export const Minting = ({ size="small" sx={{ backgroundColor: 'var(--green)', - color: 'black', + color: theme.palette.text.primary, fontWeight: 'bold', opacity: 0.7, @@ -802,6 +799,7 @@ export const Minting = ({ {isShowNext ? 'Confirmed' : 'Please Wait'} + {!isShowNext && (