Skip to content

Commit

Permalink
0 tokens fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonmanRolls committed Feb 14, 2024
1 parent 66565d1 commit 79814db
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/pages/DelegateRanking.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ const DelegatesContainer = styled.div`
justify-content: center;
max-height: calc(100vh / 3);
overflow-y: auto;
pointer-events: ${(props) => (props.balance === 0 ? "none" : "auto")};
opacity: ${(props) => (props.balance === 0 ? 0.4 : 1)};
`;

const HeaderContainer = styled.div`
Expand Down Expand Up @@ -364,6 +366,7 @@ function CurrentDelegation({ tokens, selection, delegatedTo }) {
<Profile address={delegatedTo} size="small" />
</>
);

if (selection) {
text = (
<>
Expand All @@ -383,6 +386,14 @@ function CurrentDelegation({ tokens, selection, delegatedTo }) {
);
}

if (tokens === "0.00") {
text = (
<>
<span>You have no tokens to delegate.</span>
</>
);
}

return (
<CurrentDelegationContainer data-testid="current-delegation">
{text}
Expand Down Expand Up @@ -423,6 +434,9 @@ const ChooseYourDelegate = () => {
const [renderKey, setRenderKey] = useState(0);
const [search, setSearch] = useState("");

const simpleBalance =
!balanceLoading && balance ? Number(utils.formatEther(balance)) : 0;

return (
<WrappedNarrowColumn>
{!transactionDone && (
Expand Down Expand Up @@ -489,7 +503,7 @@ const ChooseYourDelegate = () => {
{address ? (
<WrappedCTAButton
text={"Enter ENS or address"}
type={"deny"}
type={simpleBalance === 0 ? "disabled" : "deny"}
onClick={() => {
if (address) {
history.push("/manual-delegates-no-claim");
Expand Down Expand Up @@ -531,7 +545,10 @@ const ChooseYourDelegate = () => {
{delegatesLoading ? (
<Loader center large />
) : (
<DelegatesContainer data-testid="delegates-list-container">
<DelegatesContainer
data-testid="delegates-list-container"
balance={simpleBalance}
>
{delegates.map((d) => (
<DelegateBox
{...d}
Expand Down

0 comments on commit 79814db

Please sign in to comment.