Skip to content

Commit

Permalink
Fix domain balances in colony home
Browse files Browse the repository at this point in the history
  • Loading branch information
ceolson01 committed Jan 15, 2020
1 parent 2d453c1 commit af75c22
Showing 1 changed file with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import { DialogType } from '~core/Dialog';
import withDialog from '~core/Dialog/withDialog';
import Heading from '~core/Heading';
import { DomainsMapType } from '~types/index';
import { useLoggedInUser, FullColonyFragment } from '~data/index';
import {
useLoggedInUser,
FullColonyFragment,
useTokenBalancesForDomainsQuery,
} from '~data/index';

import { canMoveTokens as canMoveTokensCheck } from '../../../../admin/checks';
import TokenItem from './TokenItem';

import styles from './ColonyFunding.css';
import { SpinnerLoader } from '~core/Preloaders';

const MSG = defineMessages({
buttonFund: {
Expand Down Expand Up @@ -49,7 +54,7 @@ const ColonyFunding = ({
[walletAddress, domains],
);

const { colonyAddress, tokens } = colony;
const { colonyAddress, tokens: colonyTokens } = colony;

const handleMoveTokens = useCallback(
() =>
Expand All @@ -63,6 +68,17 @@ const ColonyFunding = ({
[openDialog, colonyAddress, currentDomainId],
);

const {
data,
loading: isLoadingTokenBalances,
} = useTokenBalancesForDomainsQuery({
variables: {
colonyAddress,
domainIds: [currentDomainId],
tokenAddresses: colonyTokens.map(({ address }) => address),
},
});

return (
<div>
<Heading appearance={{ size: 'normal', weight: 'bold' }}>
Expand All @@ -77,15 +93,19 @@ const ColonyFunding = ({
</span>
)}
</Heading>
<ul>
{tokens.map(token => (
<TokenItem
currentDomainId={currentDomainId}
key={token.address}
token={token}
/>
))}
</ul>
{data && !isLoadingTokenBalances ? (
<ul>
{data.colony.tokens.map(token => (
<TokenItem
currentDomainId={currentDomainId}
key={token.address}
token={token}
/>
))}
</ul>
) : (
<SpinnerLoader />
)}
</div>
);
};
Expand Down

0 comments on commit af75c22

Please sign in to comment.